mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-08 19:58:27 +00:00
proxy llm, support stream format (#190)
This commit is contained in:
commit
17b190b691
@ -76,7 +76,13 @@ def proxyllm_generate_stream(model, tokenizer, params, device, context_len=2048)
|
|||||||
for line in res.iter_lines():
|
for line in res.iter_lines():
|
||||||
if line:
|
if line:
|
||||||
decoded_line = line.decode("utf-8")
|
decoded_line = line.decode("utf-8")
|
||||||
|
try:
|
||||||
json_line = json.loads(decoded_line)
|
json_line = json.loads(decoded_line)
|
||||||
print(json_line)
|
print(json_line)
|
||||||
text += json_line["choices"][0]["message"]["content"]
|
text += json_line["choices"][0]["message"]["content"]
|
||||||
yield text
|
yield text
|
||||||
|
except Exception as e:
|
||||||
|
text += decoded_line
|
||||||
|
yield json.loads(text)["choices"][0]["message"]["content"]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user