"git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "702ffdf61a519cf5e9ea8873997083029af5cb01"
Commit 784ee6f5 authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

fix: error handling

parent d936353d
...@@ -108,20 +108,26 @@ class RAGMiddleware(BaseHTTPMiddleware): ...@@ -108,20 +108,26 @@ class RAGMiddleware(BaseHTTPMiddleware):
for doc in docs: for doc in docs:
context = None context = None
if doc["type"] == "collection":
context = query_collection( try:
collection_names=doc["collection_names"], if doc["type"] == "collection":
query=query, context = query_collection(
k=rag_app.state.TOP_K, collection_names=doc["collection_names"],
embedding_function=rag_app.state.sentence_transformer_ef, query=query,
) k=rag_app.state.TOP_K,
else: embedding_function=rag_app.state.sentence_transformer_ef,
context = query_doc( )
collection_name=doc["collection_name"], else:
query=query, context = query_doc(
k=rag_app.state.TOP_K, collection_name=doc["collection_name"],
embedding_function=rag_app.state.sentence_transformer_ef, 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) relevant_contexts.append(context)
context_string = "" context_string = ""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment