Knowledge core processing updated for embeddings interface change (#681)

Knowledge core fixed: 
- trustgraph-flow/trustgraph/tables/knowledge.py - v.vector, v.chunk_id
- trustgraph-base/trustgraph/messaging/translators/document_loading.py -
  chunk.vector
- trustgraph-base/trustgraph/messaging/translators/knowledge.py -
  entity.vector
- trustgraph-flow/trustgraph/gateway/dispatch/serialize.py - entity.vector,
  chunk.vector

Test fixtures fixed:
- tests/unit/test_storage/conftest.py - All mock entities/chunks use vector
- tests/unit/test_query/conftest.py - All mock requests use vector
- tests/unit/test_query/test_doc_embeddings_pinecone_query.py - All mock
  messages use vector

These changes align with commit f2ae0e86 which changed the schema from
vectors: list[list[float]] to vector: list[float].
This commit is contained in:
cybermaggedon 2026-03-10 13:28:16 +00:00 committed by GitHub
parent 84941ce645
commit 57eda65674
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 32 additions and 46 deletions

View file

@ -37,7 +37,7 @@ def mock_qdrant_client():
def mock_graph_embeddings_request():
"""Mock graph embeddings request message"""
mock_message = MagicMock()
mock_message.vectors = [[0.1, 0.2, 0.3]]
mock_message.vector = [0.1, 0.2, 0.3]
mock_message.limit = 5
mock_message.user = 'test_user'
mock_message.collection = 'test_collection'
@ -46,9 +46,9 @@ def mock_graph_embeddings_request():
@pytest.fixture
def mock_graph_embeddings_multiple_vectors():
"""Mock graph embeddings request with multiple vectors"""
"""Mock graph embeddings request with multiple vectors (legacy name, now single vector)"""
mock_message = MagicMock()
mock_message.vectors = [[0.1, 0.2], [0.3, 0.4]]
mock_message.vector = [0.1, 0.2, 0.3, 0.4]
mock_message.limit = 3
mock_message.user = 'multi_user'
mock_message.collection = 'multi_collection'
@ -82,7 +82,7 @@ def mock_graph_embeddings_uri_response():
def mock_document_embeddings_request():
"""Mock document embeddings request message"""
mock_message = MagicMock()
mock_message.vectors = [[0.1, 0.2, 0.3]]
mock_message.vector = [0.1, 0.2, 0.3]
mock_message.limit = 5
mock_message.user = 'test_user'
mock_message.collection = 'test_collection'
@ -91,9 +91,9 @@ def mock_document_embeddings_request():
@pytest.fixture
def mock_document_embeddings_multiple_vectors():
"""Mock document embeddings request with multiple vectors"""
"""Mock document embeddings request with multiple vectors (legacy name, now single vector)"""
mock_message = MagicMock()
mock_message.vectors = [[0.1, 0.2], [0.3, 0.4]]
mock_message.vector = [0.1, 0.2, 0.3, 0.4]
mock_message.limit = 3
mock_message.user = 'multi_user'
mock_message.collection = 'multi_collection'
@ -139,9 +139,9 @@ def mock_large_query_response():
@pytest.fixture
def mock_mixed_dimension_vectors():
"""Mock request with vectors of different dimensions"""
"""Mock request with vector (legacy name suggested mixed dimensions, now single vector)"""
mock_message = MagicMock()
mock_message.vectors = [[0.1, 0.2], [0.3, 0.4, 0.5]] # 2D and 3D
mock_message.vector = [0.1, 0.2, 0.3, 0.4, 0.5]
mock_message.limit = 5
mock_message.user = 'dim_user'
mock_message.collection = 'dim_collection'

View file

@ -18,10 +18,7 @@ class TestPineconeDocEmbeddingsQueryProcessor:
def mock_query_message(self):
"""Create a mock query message for testing"""
message = MagicMock()
message.vectors = [
[0.1, 0.2, 0.3],
[0.4, 0.5, 0.6]
]
message.vector = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
message.limit = 5
message.user = 'test_user'
message.collection = 'test_collection'
@ -242,12 +239,9 @@ class TestPineconeDocEmbeddingsQueryProcessor:
@pytest.mark.asyncio
async def test_query_document_embeddings_different_vector_dimensions(self, processor):
"""Test querying with vectors of different dimensions using same index"""
"""Test querying with single vector (legacy test name, schema now uses single vector)"""
message = MagicMock()
message.vectors = [
[0.1, 0.2], # 2D vector
[0.3, 0.4, 0.5, 0.6] # 4D vector
]
message.vector = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6]
message.limit = 5
message.user = 'test_user'
message.collection = 'test_collection'
@ -437,13 +431,9 @@ class TestPineconeDocEmbeddingsQueryProcessor:
@pytest.mark.asyncio
async def test_query_document_embeddings_vector_accumulation(self, processor):
"""Test that results from multiple vectors are properly accumulated"""
"""Test that results from single vector query are returned (legacy multi-vector test)"""
message = MagicMock()
message.vectors = [
[0.1, 0.2, 0.3],
[0.4, 0.5, 0.6],
[0.7, 0.8, 0.9]
]
message.vector = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
message.limit = 2
message.user = 'test_user'
message.collection = 'test_collection'