vlff李飞飞 commited on
Commit
f175aee
·
1 Parent(s): 16eee82

update oai

Browse files
Files changed (1) hide show
  1. qwen_agent/llm/qwen_oai.py +2 -2
qwen_agent/llm/qwen_oai.py CHANGED
@@ -326,8 +326,7 @@ def create_chat_completion(request: ChatCompletionRequest):
326
  if request.functions:
327
  raise Exception("Invalid request: Function calling is not yet implemented for stream mode.")
328
  generate = predict(query, history, request.model, stop_words, gen_kwargs)
329
- print(generate)
330
- return json.loads(generate)
331
  # return EventSourceResponse(generate, media_type="text/event-stream")
332
 
333
  stop_words_ids = [tokenizer.encode(s) for s in stop_words] if stop_words else None
@@ -506,6 +505,7 @@ class QwenChatAsOAI1(BaseChatModel):
506
  stream=True)
507
  # TODO: error handling
508
  for chunk in response:
 
509
  if hasattr(chunk.choices[0].delta, 'content'):
510
  yield chunk.choices[0].delta.content
511
 
 
326
  if request.functions:
327
  raise Exception("Invalid request: Function calling is not yet implemented for stream mode.")
328
  generate = predict(query, history, request.model, stop_words, gen_kwargs)
329
+ return generate
 
330
  # return EventSourceResponse(generate, media_type="text/event-stream")
331
 
332
  stop_words_ids = [tokenizer.encode(s) for s in stop_words] if stop_words else None
 
505
  stream=True)
506
  # TODO: error handling
507
  for chunk in response:
508
+ chunk = json.loads(chunk)
509
  if hasattr(chunk.choices[0].delta, 'content'):
510
  yield chunk.choices[0].delta.content
511