Skip to content

Commit

Permalink
Remove ANSWERABLE text from model out (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhongsun96 authored Sep 1, 2023
1 parent d73d81c commit 06c1afc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion backend/danswer/secondary_llm_flows/query_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ def stream_query_answerability(user_query: str) -> Iterator[str]:
tokens = get_default_llm().stream(filled_llm_prompt)
reasoning_pat_found = False
model_output = ""
hold_answerable = ""
for token in tokens:
model_output = model_output + token

if ANSWERABLE_PAT in model_output:
continue

if not reasoning_pat_found and REASONING_PAT in model_output:
reasoning_pat_found = True
remaining = model_output[len(REASONING_PAT) :]
Expand All @@ -96,7 +100,13 @@ def stream_query_answerability(user_query: str) -> Iterator[str]:
continue

if reasoning_pat_found:
yield get_json_line(asdict(DanswerAnswerPiece(answer_piece=token)))
hold_answerable = hold_answerable + token
if hold_answerable == ANSWERABLE_PAT[: len(hold_answerable)]:
continue
yield get_json_line(
asdict(DanswerAnswerPiece(answer_piece=hold_answerable))
)
hold_answerable = ""

reasoning = extract_answerability_reasoning(model_output)
answerable = extract_answerability_bool(model_output)
Expand Down

1 comment on commit 06c1afc

@vercel
Copy link

@vercel vercel bot commented on 06c1afc Sep 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.