Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding email into one-shot-answer #73

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions backend/danswer/one_shot_answer/answer_question.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from collections.abc import Iterator
from typing import cast

from sqlalchemy.orm import Session

from danswer.chat.chat_utils import reorganize_citations
from danswer.chat.models import CitationInfo
from danswer.chat.models import DanswerAnswerPiece
Expand Down Expand Up @@ -62,6 +60,7 @@
from danswer.utils.logger import setup_logger
from danswer.utils.timing import log_generator_function_time
from ee.danswer.server.query_and_chat.utils import create_temporary_persona
from sqlalchemy.orm import Session

logger = setup_logger()

Expand Down Expand Up @@ -108,6 +107,8 @@ def stream_answer_objects(
4. [always] Details on the final AI response message that is created
"""
user_id = user.id if user is not None else None
user_email = user.email if user is not None else None

query_msg = query_req.messages[-1]
history = query_req.messages[:-1]

Expand Down Expand Up @@ -193,9 +194,11 @@ def stream_answer_objects(
search_tool = SearchTool(
db_session=db_session,
user=user,
evaluation_type=LLMEvaluationType.SKIP
if DISABLE_LLM_DOC_RELEVANCE
else query_req.evaluation_type,
evaluation_type=(
LLMEvaluationType.SKIP
if DISABLE_LLM_DOC_RELEVANCE
else query_req.evaluation_type
),
persona=persona,
retrieval_options=query_req.retrieval_options,
prompt_config=prompt_config,
Expand All @@ -216,6 +219,7 @@ def stream_answer_objects(

answer = Answer(
question=query_msg.message,
user_email=user_email,
answer_style_config=answer_config,
prompt_config=PromptConfig.from_model(prompt),
llm=get_main_llm_from_tuple(get_llms_for_persona(persona=persona)),
Expand Down Expand Up @@ -281,10 +285,10 @@ def stream_answer_objects(

if packet.response is not None:
for evaluation in packet.response:
document_based_response[
evaluation.document_id
] = RelevanceAnalysis(
relevant=evaluation.relevant, content=evaluation.content
document_based_response[evaluation.document_id] = (
RelevanceAnalysis(
relevant=evaluation.relevant, content=evaluation.content
)
)

evaluation_response = DocumentRelevance(
Expand Down
Loading