From 90e0b88c969ba32567eaab534c07383e2562a18a Mon Sep 17 00:00:00 2001 From: Chuck <403chuck@gmail.com> Date: Thu, 18 Apr 2024 14:45:12 +0800 Subject: [PATCH] fix: out of index while stream begin --- free_ask_internet.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/free_ask_internet.py b/free_ask_internet.py index 62b395d..af016ba 100644 --- a/free_ask_internet.py +++ b/free_ask_internet.py @@ -203,6 +203,8 @@ def chat(prompt, model:str,llm_auth_token:str,llm_base_url:str,using_custom_llm= max_tokens=1024,temperature=0.2 ): stream_resp = chunk.dict() + if len(stream_resp["choices"]) == 0: + continue token = stream_resp["choices"][0]["delta"].get("content", "") if token: