mirror of
https://github.com/ianarawjo/ChainForge.git
synced 2025-03-14 08:16:37 +00:00
Add num_ctx to Ollama API call
This commit is contained in:
parent
6d878226ca
commit
0cf0944bf8
@ -1366,6 +1366,14 @@ const OllamaSettings: ModelSettingsDict = {
|
||||
"The JSON schema to use for structured outputs. Note that using structured outputs, you should still prompt the model to output JSON. (Supported by Ollama since Dec 6 2024. For more info, see https://ollama.com/blog/structured-outputs)",
|
||||
default: "",
|
||||
},
|
||||
num_ctx: {
|
||||
type: "integer",
|
||||
title: "num_ctx",
|
||||
description:
|
||||
"How many tokens to allow in the *input* to the model. Defaults to Ollama's default setting of 2048. You must increase this if your context is lengthy.",
|
||||
minimum: 1,
|
||||
default: 2048,
|
||||
},
|
||||
raw: {
|
||||
type: "boolean",
|
||||
title: "raw",
|
||||
|
@ -1205,6 +1205,7 @@ export async function call_ollama_provider(
|
||||
const model_type: string = params?.model_type ?? "text";
|
||||
const system_msg: string = params?.system_msg ?? "";
|
||||
const chat_history: ChatHistory | undefined = params?.chat_history;
|
||||
const format: Dict | string | undefined = params?.format;
|
||||
|
||||
// Cleanup
|
||||
for (const name of [
|
||||
@ -1213,6 +1214,7 @@ export async function call_ollama_provider(
|
||||
"model_type",
|
||||
"system_msg",
|
||||
"chat_history",
|
||||
"format",
|
||||
])
|
||||
if (params && name in params) delete params[name];
|
||||
|
||||
@ -1221,8 +1223,10 @@ export async function call_ollama_provider(
|
||||
const query: Dict = {
|
||||
model: ollama_model,
|
||||
stream: false,
|
||||
temperature,
|
||||
...params, // 'the rest' of the settings, passed from the front-end settings
|
||||
options: {
|
||||
temperature,
|
||||
...params, // 'the rest' of the settings, passed from the front-end settings
|
||||
},
|
||||
};
|
||||
|
||||
// If the model type is explicitly or implicitly set to "chat", pass chat history instead:
|
||||
@ -1245,9 +1249,9 @@ export async function call_ollama_provider(
|
||||
);
|
||||
|
||||
// If there are structured outputs specified, convert to an object:
|
||||
if (typeof query.format === "string" && query.format.trim().length > 0) {
|
||||
if (typeof format === "string" && format.trim().length > 0) {
|
||||
try {
|
||||
query.format = JSON.parse(query.format);
|
||||
query.format = JSON.parse(format);
|
||||
} catch (err) {
|
||||
throw Error(
|
||||
"Cannot parse structured output format into JSON: JSON schema is incorrectly structured.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user