Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskerPRC committed Sep 11, 2024
1 parent 5f73004 commit 0e243e4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion infra_ai_service/api/ai_enhance/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ async def embed_text(input_data: TextInput):

@router.get("/status/")
async def status():
return await get_collection_status(collection_name)
return await get_collection_status()
1 change: 1 addition & 0 deletions infra_ai_service/api/ai_enhance/vector_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

router = APIRouter()


@router.post("/query/", response_model=SearchOutput)
async def vector_search(input_data: SearchInput):
return await perform_vector_search(input_data)
9 changes: 5 additions & 4 deletions infra_ai_service/service/embedding_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ async def create_embedding(content):
]
)

return EmbeddingOutput(id=point_id, embedding=embedding_vector.tolist())
return EmbeddingOutput(id=point_id,
embedding=embedding_vector.tolist())
except Exception as e:
raise HTTPException(status_code=400,
detail=f"Error processing embedding: {e}")


async def get_collection_status(collection_name):
async def get_collection_status():
try:
collection_info = qdrant_client.get_collection(collection_name)
return {
"collection_name": collection_name,
"vectors_count": collection_info.vectors_count,
"status": "ready" if collection_info.status == "green" else "not "
"ready"
"status": "ready" if collection_info.status == "green"
else "not ready"
}
except Exception as e:
raise HTTPException(status_code=400,
Expand Down
6 changes: 4 additions & 2 deletions infra_ai_service/service/search_service.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from fastapi import HTTPException
import logging

from infra_ai_service.model.model import SearchOutput, SearchResult, SearchInput
from infra_ai_service.model.model import SearchOutput, SearchResult, \
SearchInput
from infra_ai_service.sdk.qdrant import qdrant_client, collection_name, \
fastembed_model

Expand Down Expand Up @@ -48,4 +49,5 @@ async def perform_vector_search(input_data: SearchInput):
logger.error(f"Error performing vector search: {str(e)}",
exc_info=True)
raise HTTPException(status_code=500,
detail=f"Error performing vector search: {str(e)}")
detail=f"Error performing vector search: "
f"{str(e)}")

0 comments on commit 0e243e4

Please sign in to comment.