Add CI
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
# ruff: noqa: INP001
|
||||
"""Google Cloud Vector Search client."""
|
||||
|
||||
import asyncio
|
||||
@@ -6,8 +5,9 @@ from collections.abc import Sequence
|
||||
|
||||
from gcloud.aio.auth import Token
|
||||
|
||||
from ..logging import log_structured_entry
|
||||
from ..models import SearchResult, SourceNamespace
|
||||
from knowledge_search_mcp.logging import log_structured_entry
|
||||
from knowledge_search_mcp.models import SearchResult, SourceNamespace
|
||||
|
||||
from .base import BaseGoogleCloudClient
|
||||
from .storage import GoogleCloudFileStorage
|
||||
|
||||
@@ -94,7 +94,7 @@ class GoogleCloudVectorSearch(BaseGoogleCloudClient):
|
||||
log_structured_entry(
|
||||
"Vector search query failed - endpoint not configured",
|
||||
"ERROR",
|
||||
{"error": msg}
|
||||
{"error": msg},
|
||||
)
|
||||
raise RuntimeError(msg)
|
||||
|
||||
@@ -113,8 +113,8 @@ class GoogleCloudVectorSearch(BaseGoogleCloudClient):
|
||||
"deployed_index_id": deployed_index_id,
|
||||
"neighbor_count": limit,
|
||||
"endpoint_id": endpoint_id,
|
||||
"embedding_dimension": len(query)
|
||||
}
|
||||
"embedding_dimension": len(query),
|
||||
},
|
||||
)
|
||||
|
||||
datapoint: dict = {"feature_vector": list(query)}
|
||||
@@ -149,10 +149,10 @@ class GoogleCloudVectorSearch(BaseGoogleCloudClient):
|
||||
{
|
||||
"status": response.status,
|
||||
"response_body": body,
|
||||
"deployed_index_id": deployed_index_id
|
||||
}
|
||||
"deployed_index_id": deployed_index_id,
|
||||
},
|
||||
)
|
||||
raise RuntimeError(msg)
|
||||
raise RuntimeError(msg) # noqa: TRY301
|
||||
data = await response.json()
|
||||
|
||||
neighbors = data.get("nearestNeighbors", [{}])[0].get("neighbors", [])
|
||||
@@ -161,15 +161,15 @@ class GoogleCloudVectorSearch(BaseGoogleCloudClient):
|
||||
"INFO",
|
||||
{
|
||||
"neighbors_found": len(neighbors),
|
||||
"deployed_index_id": deployed_index_id
|
||||
}
|
||||
"deployed_index_id": deployed_index_id,
|
||||
},
|
||||
)
|
||||
|
||||
if not neighbors:
|
||||
log_structured_entry(
|
||||
"No neighbors found in vector search",
|
||||
"WARNING",
|
||||
{"deployed_index_id": deployed_index_id}
|
||||
{"deployed_index_id": deployed_index_id},
|
||||
)
|
||||
return []
|
||||
|
||||
@@ -185,7 +185,7 @@ class GoogleCloudVectorSearch(BaseGoogleCloudClient):
|
||||
log_structured_entry(
|
||||
"Fetching content for search results",
|
||||
"INFO",
|
||||
{"file_count": len(content_tasks)}
|
||||
{"file_count": len(content_tasks)},
|
||||
)
|
||||
|
||||
file_streams = await asyncio.gather(*content_tasks)
|
||||
@@ -206,12 +206,9 @@ class GoogleCloudVectorSearch(BaseGoogleCloudClient):
|
||||
log_structured_entry(
|
||||
"Vector search completed successfully",
|
||||
"INFO",
|
||||
{
|
||||
"results_count": len(results),
|
||||
"deployed_index_id": deployed_index_id
|
||||
}
|
||||
{"results_count": len(results), "deployed_index_id": deployed_index_id},
|
||||
)
|
||||
return results
|
||||
return results # noqa: TRY300
|
||||
|
||||
except Exception as e:
|
||||
log_structured_entry(
|
||||
@@ -220,7 +217,7 @@ class GoogleCloudVectorSearch(BaseGoogleCloudClient):
|
||||
{
|
||||
"error": str(e),
|
||||
"error_type": type(e).__name__,
|
||||
"deployed_index_id": deployed_index_id
|
||||
}
|
||||
"deployed_index_id": deployed_index_id,
|
||||
},
|
||||
)
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user