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
10 changes: 2 additions & 8 deletions src/ogx/providers/utils/memory/openai_vector_store_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,14 +1121,8 @@ async def openai_search_vector_store(
)

except Exception as e:
# Log the error and return empty results
logger.error("Error searching vector store", vector_store_id=vector_store_id, error=str(e))
return VectorStoreSearchResponsePage(
search_query=request.query if isinstance(request.query, list) else [request.query],
data=[],
has_more=False,
next_page=None,
)
logger.error("Failed to search vector store", vector_store_id=vector_store_id, error=str(e))
raise

def _build_reranker_params(
self,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/vector_io/test_openai_vector_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -3585,7 +3585,7 @@ def test_openai_vector_store_with_chunks(
filtered_search = compat_client.vector_stores.search(
vector_store_id=vector_store.id,
query="artificial intelligence",
filters={"topic": "ai"},
filters={"type": "eq", "key": "topic", "value": "ai"},
max_num_results=5,
)

Expand Down
26 changes: 26 additions & 0 deletions tests/unit/providers/vector_io/test_vector_io_stores_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,32 @@ async def mock_query_chunks(*args, **kwargs):
assert result.search_query == ["test query"] # Original query preserved


async def test_search_vector_store_propagates_backend_errors(vector_io_adapter):
"""Test that exceptions from the vector store backend propagate to the caller."""
vector_store_id = "test_store_error"
vector_io_adapter.openai_vector_stores[vector_store_id] = {
"id": vector_store_id,
"name": "Test Store",
"description": "",
"vector_store_id": "test_db",
"embedding_model": "test/embedding",
}

async def mock_query_chunks(*args, **kwargs):
raise KeyError("chunk_content")

vector_io_adapter.query_chunks = mock_query_chunks

from ogx_api import OpenAISearchVectorStoreRequest

request = OpenAISearchVectorStoreRequest(query="test query", max_num_results=5)
with pytest.raises(KeyError, match="chunk_content"):
await vector_io_adapter.openai_search_vector_store(
vector_store_id=vector_store_id,
request=request,
)


async def test_create_gin_index_executes_correct_sql():
from ogx.providers.remote.vector_io.pgvector.config import PGVectorHNSWVectorIndex
from ogx.providers.remote.vector_io.pgvector.pgvector import PGVectorIndex
Expand Down
Loading