fix minor embedding error
Browse files
src/know_lang_bot/code_parser/summarizer.py
CHANGED
@@ -70,7 +70,7 @@ class CodeSummarizer:
|
|
70 |
model=self.config.llm.embedding_model,
|
71 |
input=text
|
72 |
)
|
73 |
-
return response['
|
74 |
else:
|
75 |
raise ValueError(f"Unsupported embedding provider: {self.config.llm.embedding_provider}")
|
76 |
|
@@ -114,7 +114,7 @@ class CodeSummarizer:
|
|
114 |
# Store in ChromaDB
|
115 |
self.collection.add(
|
116 |
documents=[summary],
|
117 |
-
embeddings=
|
118 |
metadatas=[metadata.model_dump()],
|
119 |
ids=[chunk_id]
|
120 |
)
|
|
|
70 |
model=self.config.llm.embedding_model,
|
71 |
input=text
|
72 |
)
|
73 |
+
return response['embeddings']
|
74 |
else:
|
75 |
raise ValueError(f"Unsupported embedding provider: {self.config.llm.embedding_provider}")
|
76 |
|
|
|
114 |
# Store in ChromaDB
|
115 |
self.collection.add(
|
116 |
documents=[summary],
|
117 |
+
embeddings=embedding,
|
118 |
metadatas=[metadata.model_dump()],
|
119 |
ids=[chunk_id]
|
120 |
)
|
tests/test_summarizer.py
CHANGED
@@ -100,7 +100,7 @@ async def test_process_and_store_chunk_with_embedding(
|
|
100 |
mock_agent.run = AsyncMock(return_value=mock_run_result)
|
101 |
|
102 |
# Setup mock embedding response
|
103 |
-
mock_embedding = {'
|
104 |
mock_ollama.embed = Mock(return_value=mock_embedding)
|
105 |
|
106 |
summarizer = CodeSummarizer(config)
|
@@ -122,8 +122,8 @@ async def test_process_and_store_chunk_with_embedding(
|
|
122 |
assert add_call is not None
|
123 |
|
124 |
kwargs = add_call[1]
|
125 |
-
assert len(kwargs['embeddings']) ==
|
126 |
-
assert kwargs['embeddings']
|
127 |
assert kwargs['documents'][0] == mock_run_result.data
|
128 |
assert kwargs['ids'][0] == f"{sample_chunks[0].file_path}:{sample_chunks[0].start_line}-{sample_chunks[0].end_line}"
|
129 |
|
|
|
100 |
mock_agent.run = AsyncMock(return_value=mock_run_result)
|
101 |
|
102 |
# Setup mock embedding response
|
103 |
+
mock_embedding = {'embeddings': [0.1, 0.2, 0.3]} # Sample embedding vector
|
104 |
mock_ollama.embed = Mock(return_value=mock_embedding)
|
105 |
|
106 |
summarizer = CodeSummarizer(config)
|
|
|
122 |
assert add_call is not None
|
123 |
|
124 |
kwargs = add_call[1]
|
125 |
+
assert len(kwargs['embeddings']) == 3
|
126 |
+
assert kwargs['embeddings'] == mock_embedding['embeddings']
|
127 |
assert kwargs['documents'][0] == mock_run_result.data
|
128 |
assert kwargs['ids'][0] == f"{sample_chunks[0].file_path}:{sample_chunks[0].start_line}-{sample_chunks[0].end_line}"
|
129 |
|