repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | import { MemoryConfig, MemoryConfigSchema } from "../types"; |
| #2 | import { DEFAULT_MEMORY_CONFIG } from "./defaults"; |
| #3 | |
| #4 | export class ConfigManager { |
| #5 | static mergeConfig(userConfig: Partial<MemoryConfig> = {}): MemoryConfig { |
| #6 | const mergedConfig = { |
| #7 | version: userConfig.version || DEFAULT_MEMORY_CONFIG.version, |
| #8 | embedder: { |
| #9 | provider: |
| #10 | userConfig.embedder?.provider || |
| #11 | DEFAULT_MEMORY_CONFIG.embedder.provider, |
| #12 | config: (() => { |
| #13 | const defaultConf = DEFAULT_MEMORY_CONFIG.embedder.config; |
| #14 | const userConf = userConfig.embedder?.config; |
| #15 | let finalModel: string | any = defaultConf.model; |
| #16 | |
| #17 | if (userConf?.model && typeof userConf.model === "object") { |
| #18 | finalModel = userConf.model; |
| #19 | } else if (userConf?.model && typeof userConf.model === "string") { |
| #20 | finalModel = userConf.model; |
| #21 | } |
| #22 | |
| #23 | return { |
| #24 | apiKey: |
| #25 | userConf?.apiKey !== undefined |
| #26 | ? userConf.apiKey |
| #27 | : defaultConf.apiKey, |
| #28 | model: finalModel, |
| #29 | url: userConf?.url, |
| #30 | embeddingDims: userConf?.embeddingDims, |
| #31 | modelProperties: |
| #32 | userConf?.modelProperties !== undefined |
| #33 | ? userConf.modelProperties |
| #34 | : defaultConf.modelProperties, |
| #35 | }; |
| #36 | })(), |
| #37 | }, |
| #38 | vectorStore: { |
| #39 | provider: |
| #40 | userConfig.vectorStore?.provider || |
| #41 | DEFAULT_MEMORY_CONFIG.vectorStore.provider, |
| #42 | config: (() => { |
| #43 | const defaultConf = DEFAULT_MEMORY_CONFIG.vectorStore.config; |
| #44 | const userConf = userConfig.vectorStore?.config; |
| #45 | |
| #46 | // Prioritize user-provided client instance |
| #47 | if (userConf?.client && typeof userConf.client === "object") { |
| #48 | return { |
| #49 | client: userConf.client, |
| #50 | // Include other fields from userConf if necessary, or omit defaults |
| #51 | collectionName: userConf.collectionName, // Can be undefined |
| #52 | dimension: userConf.dimension || defaultConf.dimension, // Merge dimension |
| #53 | ...userConf, // Include any other passthrough fields from user |
| #54 | }; |
| #55 | } else { |
| #56 | // If no client provided, merge standard fields |
| #57 | return { |
| #58 | collectionName: |
| #59 | userConf?.collectionName || defaultConf.collectionName, |
| #60 | dimension: userConf?.dimension || defaultConf.dimension, |
| #61 | // Ensure client is not carried over from defaults if not provided by user |
| #62 | client: undefined, |
| #63 | // Include other passthrough fields from userConf even if no client |
| #64 | ...userConf, |
| #65 | }; |
| #66 | } |
| #67 | })(), |
| #68 | }, |
| #69 | llm: { |
| #70 | provider: |
| #71 | userConfig.llm?.provider || DEFAULT_MEMORY_CONFIG.llm.provider, |
| #72 | config: (() => { |
| #73 | const defaultConf = DEFAULT_MEMORY_CONFIG.llm.config; |
| #74 | const userConf = userConfig.llm?.config; |
| #75 | let finalModel: string | any = defaultConf.model; |
| #76 | |
| #77 | if (userConf?.model && typeof userConf.model === "object") { |
| #78 | finalModel = userConf.model; |
| #79 | } else if (userConf?.model && typeof userConf.model === "string") { |
| #80 | finalModel = userConf.model; |
| #81 | } |
| #82 | |
| #83 | return { |
| #84 | baseURL: userConf?.baseURL || defaultConf.baseURL, |
| #85 | apiKey: |
| #86 | userConf?.apiKey !== undefined |
| #87 | ? userConf.apiKey |
| #88 | : defaultConf.apiKey, |
| #89 | model: finalModel, |
| #90 | modelProperties: |
| #91 | userConf?.modelProperties !== undefined |
| #92 | ? userConf.modelProperties |
| #93 | : defaultConf.modelProperties, |
| #94 | }; |
| #95 | })(), |
| #96 | }, |
| #97 | historyDbPath: |
| #98 | userConfig.historyDbPath || DEFAULT_MEMORY_CONFIG.historyDbPath, |
| #99 | customPrompt: userConfig.customPrompt, |
| #100 | graphStore: { |
| #101 | ...DEFAULT_MEMORY_CONFIG.graphStore, |
| #102 | ...userConfig.graphStore, |
| #103 | }, |
| #104 | historyStore: { |
| #105 | ...DEFAULT_MEMORY_CONFIG.historyStore, |
| #106 | ...userConfig.historyStore, |
| #107 | }, |
| #108 | disableHistory: |
| #109 | userConfig.disableHistory || DEFAULT_MEMORY_CONFIG.disableHistory, |
| #110 | enableGraph: userConfig.enableGraph || DEFAULT_MEMORY_CONFIG.enableGraph, |
| #111 | }; |
| #112 | |
| #113 | // Validate the merged config |
| #114 | return MemoryConfigSchema.parse(mergedConfig); |
| #115 | } |
| #116 | } |
| #117 |