Merge pull request #5378 from thiswillbeyourgithub/fix_RAG_and_web

fix: RAG and Web Search + RAG enhancements
This commit is contained in:
Timothy Jaeryang Baek
2024-09-13 05:38:53 +01:00
committed by GitHub
3 changed files with 72 additions and 29 deletions

View File

@@ -588,6 +588,11 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
prompt = get_last_user_message(body["messages"])
if prompt is None:
raise Exception("No user message found")
if rag_app.state.config.RELEVANCE_THRESHOLD == 0:
assert context_string.strip(), (
"With a 0 relevancy threshold for RAG, the context cannot "
"be empty"
)
# Workaround for Ollama 2.0+ system prompt issue
# TODO: replace with add_or_update_system_message
if model["owned_by"] == "ollama":