Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e830351691 |
@@ -93,6 +93,7 @@ export class ConfigManager {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
baseURL: userConf?.baseURL || defaultConf.baseURL,
|
baseURL: userConf?.baseURL || defaultConf.baseURL,
|
||||||
|
url: userConf?.url,
|
||||||
apiKey:
|
apiKey:
|
||||||
userConf?.apiKey !== undefined
|
userConf?.apiKey !== undefined
|
||||||
? userConf.apiKey
|
? userConf.apiKey
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export class OllamaLLM implements LLM {
|
|||||||
|
|
||||||
constructor(config: LLMConfig) {
|
constructor(config: LLMConfig) {
|
||||||
this.ollama = new Ollama({
|
this.ollama = new Ollama({
|
||||||
host: config.config?.url || "http://localhost:11434",
|
host: config.url || config.baseURL || "http://localhost:11434",
|
||||||
});
|
});
|
||||||
this.model = config.model || "llama3.1:8b";
|
this.model = config.model || "llama3.1:8b";
|
||||||
this.ensureModelExists().catch((err) => {
|
this.ensureModelExists().catch((err) => {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ export interface HistoryStoreConfig {
|
|||||||
export interface LLMConfig {
|
export interface LLMConfig {
|
||||||
provider?: string;
|
provider?: string;
|
||||||
baseURL?: string;
|
baseURL?: string;
|
||||||
|
url?: string;
|
||||||
config?: Record<string, any>;
|
config?: Record<string, any>;
|
||||||
apiKey?: string;
|
apiKey?: string;
|
||||||
model?: string | any;
|
model?: string | any;
|
||||||
@@ -143,6 +144,7 @@ export const MemoryConfigSchema = z.object({
|
|||||||
model: z.union([z.string(), z.any()]).optional(),
|
model: z.union([z.string(), z.any()]).optional(),
|
||||||
modelProperties: z.record(z.string(), z.any()).optional(),
|
modelProperties: z.record(z.string(), z.any()).optional(),
|
||||||
baseURL: z.string().optional(),
|
baseURL: z.string().optional(),
|
||||||
|
url: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
historyDbPath: z.string().optional(),
|
historyDbPath: z.string().optional(),
|
||||||
|
|||||||
@@ -85,4 +85,80 @@ describe("ConfigManager", () => {
|
|||||||
expect(config.vectorStore.config.dimension).toBe(768);
|
expect(config.vectorStore.config.dimension).toBe(768);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("mergeConfig - LLM url passthrough for Ollama", () => {
|
||||||
|
const baseEmbedder = {
|
||||||
|
provider: "openai",
|
||||||
|
config: { apiKey: "test-key" },
|
||||||
|
};
|
||||||
|
const baseVectorStore = {
|
||||||
|
provider: "memory",
|
||||||
|
config: { collectionName: "test" },
|
||||||
|
};
|
||||||
|
|
||||||
|
it("should preserve url in LLM config when provided", () => {
|
||||||
|
const config = ConfigManager.mergeConfig({
|
||||||
|
embedder: baseEmbedder,
|
||||||
|
vectorStore: baseVectorStore,
|
||||||
|
llm: {
|
||||||
|
provider: "ollama",
|
||||||
|
config: { model: "llama3.2:3b", url: "http://10.0.0.100:11434" },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(config.llm.config.url).toBe("http://10.0.0.100:11434");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should prefer baseURL over url when both are provided", () => {
|
||||||
|
const config = ConfigManager.mergeConfig({
|
||||||
|
embedder: baseEmbedder,
|
||||||
|
vectorStore: baseVectorStore,
|
||||||
|
llm: {
|
||||||
|
provider: "ollama",
|
||||||
|
config: {
|
||||||
|
model: "llama3.2:3b",
|
||||||
|
baseURL: "http://custom:11434",
|
||||||
|
url: "http://fallback:11434",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(config.llm.config.baseURL).toBe("http://custom:11434");
|
||||||
|
expect(config.llm.config.url).toBe("http://fallback:11434");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should use default baseURL when no url or baseURL provided", () => {
|
||||||
|
const config = ConfigManager.mergeConfig({
|
||||||
|
embedder: baseEmbedder,
|
||||||
|
vectorStore: baseVectorStore,
|
||||||
|
llm: {
|
||||||
|
provider: "ollama",
|
||||||
|
config: { model: "llama3.2:3b" },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(config.llm.config.url).toBeUndefined();
|
||||||
|
expect(config.llm.config.baseURL).toBe("https://api.openai.com/v1");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should preserve url in embedder config (existing behavior)", () => {
|
||||||
|
const config = ConfigManager.mergeConfig({
|
||||||
|
embedder: {
|
||||||
|
provider: "ollama",
|
||||||
|
config: {
|
||||||
|
model: "nomic-embed-text",
|
||||||
|
url: "http://10.0.0.100:11434",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
vectorStore: baseVectorStore,
|
||||||
|
llm: {
|
||||||
|
provider: "ollama",
|
||||||
|
config: { model: "llama3.2:3b", url: "http://10.0.0.100:11434" },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(config.embedder.config.url).toBe("http://10.0.0.100:11434");
|
||||||
|
expect(config.llm.config.url).toBe("http://10.0.0.100:11434");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user