{"record":{"id":"3de41691dc7602f3","repo":"OpenBMB/ChatDev","slug":"localembedding-requires-model-path-parameter","errorCode":null,"errorMessage":"LocalEmbedding requires model_path parameter","messagePattern":"LocalEmbedding requires model_path parameter","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"runtime/node/agent/memory/embedding.py","lineNumber":171,"sourceCode":"        elif self.chunk_strategy == 'weighted':\n            # Weighted aggregation (earlier chunks weigh more)\n            weights = [1.0 / (i + 1) for i in range(len(chunk_embeddings))]\n            total_weight = sum(weights)\n            return [sum(chunk[i] * weights[j] for j, chunk in enumerate(chunk_embeddings)) / total_weight \n                   for i in range(len(chunk_embeddings[0]))]\n        else:\n            # Default to the first chunk\n            return chunk_embeddings[0]\n\nclass LocalEmbedding(EmbeddingBase):\n    def __init__(self, embedding_config: EmbeddingConfig):\n        super().__init__(embedding_config)\n        self.model_path = embedding_config.params.get('model_path')\n        self.device = embedding_config.params.get('device', 'cpu')\n        self._fallback_dim = 768  # Default; updated after first successful call\n        \n        if not self.model_path:\n            raise ValueError(\"LocalEmbedding requires model_path parameter\")\n        \n        # Load the local embedding model (e.g., sentence-transformers)\n        try:\n            from sentence_transformers import SentenceTransformer\n            self.model = SentenceTransformer(self.model_path, device=self.device)\n        except ImportError:\n            raise ImportError(\"sentence-transformers is required for LocalEmbedding\")\n\n    def get_embedding(self, text):\n        # Preprocess text before encoding\n        processed_text = self._preprocess_text(text)\n        \n        if not processed_text:\n            return [0.0] * self._fallback_dim\n        \n        try:\n            embedding = self.model.encode(processed_text, convert_to_tensor=False)\n            result = embedding.tolist()","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/OpenBMB/ChatDev/blob/4fb2db0ea90375ce1059f44fe03ffbd191a7a169/runtime/node/agent/memory/embedding.py#L153-L189","documentation":"LocalEmbedding requires params.model_path to point at a local sentence-transformers model. Without it there is nothing to load, so __init__ raises before loading the model.","triggerScenarios":"provider='local' with no params dict or no 'model_path' key: EmbeddingConfig(provider='local', params={'device':'cpu'}) — device alone is not enough.","commonSituations":"Assuming 'local' downloads a default model; forgetting to include the path to the downloaded model directory; typo like 'modelPath' or 'path' in params.","solutions":["Add params={'model_path': '/path/to/model-or-repo-id'} to the embedding config","Use a valid sentence-transformers model id (e.g. 'sentence-transformers/all-MiniLM-L6-v2')","Verify the key is exactly 'model_path' (snake_case)"],"exampleFix":"# before\nEmbeddingConfig(provider='local', params={'device': 'cpu'})\n\n# after\nEmbeddingConfig(provider='local', params={'model_path': 'sentence-transformers/all-MiniLM-L6-v2', 'device': 'cpu'})","handlingStrategy":"validation","validationCode":"if embedding_config.provider == 'local' and not embedding_config.params.get('model_path'):\n    raise ConfigError('local embedding requires params.model_path')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Schema-validate params for local provider","Use exact key 'model_path'"],"tags":["embedding","local-model","missing-parameter"],"backgroundTag":"missing-config-parameter","analyzedSha":"4fb2db0ea90375ce1059f44fe03ffbd191a7a169","analyzedAt":"2026-08-27T14:35:29.622Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}