This commit is contained in:
2026-05-13 05:10:51 +03:00
parent 3848dd82d9
commit cd8d2683c0
10 changed files with 1173 additions and 53 deletions
+24 -1
View File
@@ -1,4 +1,5 @@
import {Ollama} from "ollama";
import {z} from "zod";
export function asNonEmptyString(value: unknown): string | undefined {
return typeof value === "string" && value.trim().length > 0
@@ -78,7 +79,7 @@ export async function unloadAllOllamaModels(ollama: Ollama, exceptFor?: string[]
);
await Promise.all(unloadPromises);
console.log("All models have been requested to unload" + exceptFor?.length ? ` except for [${exceptFor?.join(", ")}].` : ".");
console.log("All models have been requested to unload" + (exceptFor?.length ? ` except for [${exceptFor?.join(", ")}].` : "."));
} catch (error) {
console.error("Error unloading models:", error);
}
@@ -100,3 +101,25 @@ export async function loadOllamaModel(model: string, ollama: Ollama, contextLeng
return false;
}
}
export type ToolPlanStep = {
t: string;
h: string;
from: string;
};
export type RouterPlan = {
s: ToolPlanStep[];
m: string;
};
export const ToolPlanStepSchema = z.object({
t: z.string(),
h: z.string(),
from: z.string(),
});
export const RouterPlanSchema = z.object({
s: z.array(ToolPlanStepSchema),
m: z.string()
});