Browse Source

fix: stream defaults to true, return request ID

Jun Siang Cheah 11 months ago
parent
commit
24c35c308d
1 changed files with 2 additions and 2 deletions
  1. 2 2
      backend/apps/ollama/main.py

+ 2 - 2
backend/apps/ollama/main.py

@@ -993,7 +993,7 @@ async def generate_chat_completion(
 
 
             def stream_content():
             def stream_content():
                 try:
                 try:
-                    if payload.get("stream", None):
+                    if payload.get("stream", True):
                         yield json.dumps({"id": request_id, "done": False}) + "\n"
                         yield json.dumps({"id": request_id, "done": False}) + "\n"
 
 
                     for chunk in r.iter_content(chunk_size=8192):
                     for chunk in r.iter_content(chunk_size=8192):
@@ -1522,7 +1522,7 @@ async def deprecated_proxy(
                     if path == "generate":
                     if path == "generate":
                         data = json.loads(body.decode("utf-8"))
                         data = json.loads(body.decode("utf-8"))
 
 
-                        if not ("stream" in data and data["stream"] == False):
+                        if data.get("stream", True):
                             yield json.dumps({"id": request_id, "done": False}) + "\n"
                             yield json.dumps({"id": request_id, "done": False}) + "\n"
 
 
                     elif path == "chat":
                     elif path == "chat":