This commit is contained in:
Timothy J. Baek 2024-09-13 01:07:03 -04:00
parent 8a4b3e6bc9
commit a1f3ece528

View File

@ -586,13 +586,16 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
if len(contexts) > 0: if len(contexts) > 0:
context_string = "/n".join(contexts).strip() context_string = "/n".join(contexts).strip()
prompt = get_last_user_message(body["messages"]) prompt = get_last_user_message(body["messages"])
if prompt is None: if prompt is None:
raise Exception("No user message found") raise Exception("No user message found")
if rag_app.state.config.RELEVANCE_THRESHOLD == 0: if (
if context_string.strip() == "": rag_app.state.config.RELEVANCE_THRESHOLD == 0
log.debug( and context_string.strip() == ""
f"With a 0 relevancy threshold for RAG, the context cannot be empty" ):
) log.debug(
f"With a 0 relevancy threshold for RAG, the context cannot be empty"
)
# Workaround for Ollama 2.0+ system prompt issue # Workaround for Ollama 2.0+ system prompt issue
# TODO: replace with add_or_update_system_message # TODO: replace with add_or_update_system_message