Skip to content

Commit

Permalink
feat: Added answer sources as string!
Browse files Browse the repository at this point in the history
  • Loading branch information
amindadgar committed Dec 2, 2024
1 parent f43fdd3 commit 8d2363a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions worker/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from llama_index.core.schema import NodeWithScore
from subquery import query_multiple_source
from utils.data_source_selector import DataSourceSelector
from utils.query_engine.prepare_answer_sources import PrepareAnswerSources
from utils.traceloop import init_tracing
from worker.celery import app


@app.task
def ask_question_auto_search(
community_id: str,
Expand All @@ -18,8 +18,10 @@ def ask_question_auto_search(
response, references = query_data_sources(
community_id=community_id, query=query
)
answer_sources = PrepareAnswerSources(threshold=0.7).prepare_answer_sources(nodes=references)
except Exception:
response = "Sorry, We cannot process your question at the moment."
answer_sources = ""
logging.error(
f"Errors raised while processing the question for community: {community_id}!"
)
Expand All @@ -28,7 +30,7 @@ def ask_question_auto_search(
"community_id": community_id,
"question": query,
"response": response,
"references": references,
"references": answer_sources,
}


Expand Down

0 comments on commit 8d2363a

Please sign in to comment.