Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mem0-ts/src/oss/src/config/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export class ConfigManager {
? userConf.apiKey
: defaultConf.apiKey,
model: finalModel,
url: userConf?.url,
url: userConf?.url || userConf?.baseURL,
baseURL: userConf?.baseURL || userConf?.url,
modelProperties:
userConf?.modelProperties !== undefined
? userConf.modelProperties
Expand Down Expand Up @@ -80,7 +81,8 @@ export class ConfigManager {
}

return {
baseURL: userConf?.baseURL || defaultConf.baseURL,
baseURL: userConf?.baseURL || userConf?.url || defaultConf.baseURL,
url: userConf?.url || userConf?.baseURL || defaultConf.baseURL,
apiKey:
userConf?.apiKey !== undefined
? userConf.apiKey
Expand Down
2 changes: 1 addition & 1 deletion mem0-ts/src/oss/src/embeddings/ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class OllamaEmbedder implements Embedder {

constructor(config: EmbeddingConfig) {
this.ollama = new Ollama({
host: config.url || "http://localhost:11434",
host: config.url || config.baseURL || "http://localhost:11434",
});
this.model = config.model || "nomic-embed-text:latest";
this.ensureModelExists().catch((err) => {
Expand Down
6 changes: 5 additions & 1 deletion mem0-ts/src/oss/src/llms/anthropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ export class AnthropicLLM implements LLM {
max_tokens: 4096,
});

return response.content[0].text;
const firstContent = response.content[0];
if (firstContent.type === "text") {
return firstContent.text;
}
throw new Error("Expected text content block but received different type");
}

async generateChat(messages: Message[]): Promise<LLMResponse> {
Expand Down
5 changes: 4 additions & 1 deletion mem0-ts/src/oss/src/llms/ollama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export class OllamaLLM implements LLM {

constructor(config: LLMConfig) {
this.ollama = new Ollama({
host: config.config?.url || "http://localhost:11434",
host:
config.config?.url ||
config.config?.baseURL ||
"http://localhost:11434",
});
this.model = config.model || "llama3.1:8b";
this.ensureModelExists().catch((err) => {
Expand Down
4 changes: 4 additions & 0 deletions mem0-ts/src/oss/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface EmbeddingConfig {
apiKey?: string;
model?: string | any;
url?: string;
baseURL?: string;
modelProperties?: Record<string, any>;
}

Expand All @@ -40,6 +41,7 @@ export interface HistoryStoreConfig {
export interface LLMConfig {
provider?: string;
baseURL?: string;
url?: string;
config?: Record<string, any>;
apiKey?: string;
model?: string | any;
Expand Down Expand Up @@ -118,6 +120,7 @@ export const MemoryConfigSchema = z.object({
apiKey: z.string().optional(),
model: z.union([z.string(), z.any()]).optional(),
baseURL: z.string().optional(),
url: z.string().optional(),
}),
}),
vectorStore: z.object({
Expand All @@ -137,6 +140,7 @@ export const MemoryConfigSchema = z.object({
model: z.union([z.string(), z.any()]).optional(),
modelProperties: z.record(z.string(), z.any()).optional(),
baseURL: z.string().optional(),
url: z.string().optional(),
}),
}),
historyDbPath: z.string().optional(),
Expand Down