mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-05-20 00:30:10 +02:00
Remove ANSWERABLE text from model out (#383)
This commit is contained in:
parent
d73d81c867
commit
06c1afce42
@ -85,9 +85,13 @@ def stream_query_answerability(user_query: str) -> Iterator[str]:
|
|||||||
tokens = get_default_llm().stream(filled_llm_prompt)
|
tokens = get_default_llm().stream(filled_llm_prompt)
|
||||||
reasoning_pat_found = False
|
reasoning_pat_found = False
|
||||||
model_output = ""
|
model_output = ""
|
||||||
|
hold_answerable = ""
|
||||||
for token in tokens:
|
for token in tokens:
|
||||||
model_output = model_output + token
|
model_output = model_output + token
|
||||||
|
|
||||||
|
if ANSWERABLE_PAT in model_output:
|
||||||
|
continue
|
||||||
|
|
||||||
if not reasoning_pat_found and REASONING_PAT in model_output:
|
if not reasoning_pat_found and REASONING_PAT in model_output:
|
||||||
reasoning_pat_found = True
|
reasoning_pat_found = True
|
||||||
remaining = model_output[len(REASONING_PAT) :]
|
remaining = model_output[len(REASONING_PAT) :]
|
||||||
@ -96,7 +100,13 @@ def stream_query_answerability(user_query: str) -> Iterator[str]:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if reasoning_pat_found:
|
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)
|
reasoning = extract_answerability_reasoning(model_output)
|
||||||
answerable = extract_answerability_bool(model_output)
|
answerable = extract_answerability_bool(model_output)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user