Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions py/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,14 @@ def _choices(resp):

def map_chunk_no_stream(resp):
print_debug("[engine-chat] response: {}", resp)
return _choices(resp)[0].get('message', {}).get('content', '')
message = _choices(resp)[0].get('message', {})
return message.get('reasoning_content') or message.get('content') or ''

def map_chunk_stream(resp):
print_debug("[engine-chat] response: {}", resp)
return _choices(resp)[0].get('delta', {}).get('content', '')

delta = _choices(resp)[0].get('delta', {})
return delta.get('reasoning_content') or delta.get('content') or ''

map_chunk = map_chunk_stream if openai_options['stream'] else map_chunk_no_stream

return map(map_chunk, response)
Expand Down