From 24457dc286b60c3a4ad4b854bc8726ab1bcdef5a Mon Sep 17 00:00:00 2001 From: xuyuan23 <643854343@qq.com> Date: Tue, 13 Jun 2023 17:42:11 +0800 Subject: [PATCH] reformat file proxy_llm.py --- pilot/model/llm_out/proxy_llm.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pilot/model/llm_out/proxy_llm.py b/pilot/model/llm_out/proxy_llm.py index 6dd1bfc2b..e0ec78dd9 100644 --- a/pilot/model/llm_out/proxy_llm.py +++ b/pilot/model/llm_out/proxy_llm.py @@ -66,7 +66,7 @@ def proxyllm_generate_stream(model, tokenizer, params, device, context_len=2048) "messages": history, "temperature": params.get("temperature"), "max_tokens": params.get("max_new_tokens"), - "stream": True + "stream": True, } res = requests.post( @@ -76,12 +76,12 @@ def proxyllm_generate_stream(model, tokenizer, params, device, context_len=2048) text = "" for line in res.iter_lines(): if line: - json_data = line.split(b': ', 1)[1] + json_data = line.split(b": ", 1)[1] decoded_line = json_data.decode("utf-8") - if decoded_line.lower() != '[DONE]'.lower(): + if decoded_line.lower() != "[DONE]".lower(): obj = json.loads(json_data) - if obj['choices'][0]['delta'].get('content') is not None: - content = obj['choices'][0]['delta']['content'] + if obj["choices"][0]["delta"].get("content") is not None: + content = obj["choices"][0]["delta"]["content"] text += content yield text @@ -104,4 +104,4 @@ def proxyllm_generate_stream(model, tokenizer, params, device, context_len=2048) # json_line = json.loads(decoded_line) # print(json_line) # text += json_line["choices"][0]["message"]["content"] - # yield text \ No newline at end of file + # yield text