This commit is contained in:
Michael Poluektov 2024-08-10 12:11:41 +01:00
parent 589efcdc5f
commit 23f1bee7bd

View File

@ -677,7 +677,8 @@ 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:
raise Exception("No user message found")
# 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
if model["owned_by"] == "ollama": if model["owned_by"] == "ollama":
@ -722,9 +723,7 @@ class ChatCompletionMiddleware(BaseHTTPMiddleware):
self.ollama_stream_wrapper(response.body_iterator, data_items), self.ollama_stream_wrapper(response.body_iterator, data_items),
) )
return response return response
else:
return response
async def _receive(self, body: bytes): async def _receive(self, body: bytes):
return {"type": "http.request", "body": body, "more_body": False} return {"type": "http.request", "body": body, "more_body": False}