Skip to content

Commit

Permalink
fix: error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tjbck committed Mar 9, 2024
1 parent d936353 commit 784ee6f
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,26 @@ async def dispatch(self, request: Request, call_next):

for doc in docs:
context = None
if doc["type"] == "collection":
context = query_collection(
collection_names=doc["collection_names"],
query=query,
k=rag_app.state.TOP_K,
embedding_function=rag_app.state.sentence_transformer_ef,
)
else:
context = query_doc(
collection_name=doc["collection_name"],
query=query,
k=rag_app.state.TOP_K,
embedding_function=rag_app.state.sentence_transformer_ef,
)

try:
if doc["type"] == "collection":
context = query_collection(
collection_names=doc["collection_names"],
query=query,
k=rag_app.state.TOP_K,
embedding_function=rag_app.state.sentence_transformer_ef,
)
else:
context = query_doc(
collection_name=doc["collection_name"],
query=query,
k=rag_app.state.TOP_K,
embedding_function=rag_app.state.sentence_transformer_ef,
)
except Exception as e:
print(e)
context = None

relevant_contexts.append(context)

context_string = ""
Expand Down

0 comments on commit 784ee6f

Please sign in to comment.