mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-04-01 00:18:18 +02:00
Fix Weak Models Concurrency Issue (#811)
This commit is contained in:
parent
e0b87d9d4e
commit
5aa2de7a40
@ -199,6 +199,8 @@ DOC_TIME_DECAY = float(
|
||||
os.environ.get("DOC_TIME_DECAY") or 0.5 # Hits limit at 2 years by default
|
||||
)
|
||||
FAVOR_RECENT_DECAY_MULTIPLIER = 2
|
||||
# Currently this next one is not configurable via env
|
||||
DISABLE_LLM_QUERY_ANSWERABILITY = QA_PROMPT_OVERRIDE == "weak"
|
||||
DISABLE_LLM_FILTER_EXTRACTION = (
|
||||
os.environ.get("DISABLE_LLM_FILTER_EXTRACTION", "").lower() == "true"
|
||||
)
|
||||
|
@ -1,6 +1,7 @@
|
||||
import re
|
||||
from collections.abc import Iterator
|
||||
|
||||
from danswer.configs.app_configs import DISABLE_LLM_QUERY_ANSWERABILITY
|
||||
from danswer.direct_qa.interfaces import DanswerAnswerPiece
|
||||
from danswer.direct_qa.interfaces import StreamingError
|
||||
from danswer.llm.factory import get_default_llm
|
||||
@ -52,7 +53,18 @@ def get_query_answerability(user_query: str) -> tuple[str, bool]:
|
||||
return reasoning, answerable
|
||||
|
||||
|
||||
def stream_query_answerability(user_query: str) -> Iterator[str]:
|
||||
def stream_query_answerability(
|
||||
user_query: str, skip_check: bool = DISABLE_LLM_QUERY_ANSWERABILITY
|
||||
) -> Iterator[str]:
|
||||
if skip_check:
|
||||
yield get_json_line(
|
||||
QueryValidationResponse(
|
||||
reasoning="Query Answerability Eval feature is turned off",
|
||||
answerable=True,
|
||||
).dict()
|
||||
)
|
||||
return
|
||||
|
||||
messages = get_query_validation_messages(user_query)
|
||||
filled_llm_prompt = dict_based_prompt_to_langchain_prompt(messages)
|
||||
try:
|
||||
|
@ -104,6 +104,7 @@ def query_validation(
|
||||
def stream_query_validation(
|
||||
new_message_request: NewMessageRequest, _: User = Depends(current_user)
|
||||
) -> StreamingResponse:
|
||||
# Note if weak model prompt is chosen, this check does not occur
|
||||
query = new_message_request.query
|
||||
return StreamingResponse(
|
||||
stream_query_answerability(query), media_type="application/json"
|
||||
|
Loading…
x
Reference in New Issue
Block a user