refac
This commit is contained in:
1 parent
f7e07f3ca1
commit
a9c5c787b9
1 file changed
+12
-10
@@ -3658,9 +3658,9 @@ async def streaming_chat_response_handler(response, ctx):
|
|||||||
current_response_tool_call['function']['name'] = delta_name
|
current_response_tool_call['function']['name'] = delta_name
|
||||||
|
|
||||||
if delta_arguments:
|
if delta_arguments:
|
||||||
current_response_tool_call['function']['arguments'] += (
|
current_response_tool_call['function'][
|
||||||
delta_arguments
|
'arguments'
|
||||||
)
|
] += delta_arguments
|
||||||
|
|
||||||
# Emit pending tool calls in real-time
|
# Emit pending tool calls in real-time
|
||||||
if response_tool_calls:
|
if response_tool_calls:
|
||||||
@@ -3682,12 +3682,12 @@ async def streaming_chat_response_handler(response, ctx):
|
|||||||
'status': 'in_progress',
|
'status': 'in_progress',
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
pending_output = output + pending_fc_items
|
|
||||||
await event_emitter(
|
await event_emitter(
|
||||||
{
|
{
|
||||||
'type': 'chat:completion',
|
'type': 'chat:completion',
|
||||||
'data': {
|
'data': {
|
||||||
'content': serialize_output(pending_output),
|
'content': serialize_output(full_output() + pending_fc_items),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -3980,9 +3980,9 @@ async def streaming_chat_response_handler(response, ctx):
|
|||||||
'index': len(responses_api_tool_calls),
|
'index': len(responses_api_tool_calls),
|
||||||
'function': {
|
'function': {
|
||||||
'name': item.get('name', ''),
|
'name': item.get('name', ''),
|
||||||
'arguments': arguments
|
'arguments': (
|
||||||
if isinstance(arguments, str)
|
arguments if isinstance(arguments, str) else json.dumps(arguments)
|
||||||
else json.dumps(arguments),
|
),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -4410,7 +4410,8 @@ async def streaming_chat_response_handler(response, ctx):
|
|||||||
code = sanitize_code(code)
|
code = sanitize_code(code)
|
||||||
|
|
||||||
if CODE_INTERPRETER_BLOCKED_MODULES:
|
if CODE_INTERPRETER_BLOCKED_MODULES:
|
||||||
blocking_code = textwrap.dedent(f"""
|
blocking_code = textwrap.dedent(
|
||||||
|
f"""
|
||||||
import builtins
|
import builtins
|
||||||
|
|
||||||
BLOCKED_MODULES = {CODE_INTERPRETER_BLOCKED_MODULES}
|
BLOCKED_MODULES = {CODE_INTERPRETER_BLOCKED_MODULES}
|
||||||
@@ -4426,7 +4427,8 @@ async def streaming_chat_response_handler(response, ctx):
|
|||||||
return _real_import(name, globals, locals, fromlist, level)
|
return _real_import(name, globals, locals, fromlist, level)
|
||||||
|
|
||||||
builtins.__import__ = restricted_import
|
builtins.__import__ = restricted_import
|
||||||
""")
|
"""
|
||||||
|
)
|
||||||
code = blocking_code + '\n' + code
|
code = blocking_code + '\n' + code
|
||||||
|
|
||||||
if request.app.state.config.CODE_INTERPRETER_ENGINE == 'pyodide':
|
if request.app.state.config.CODE_INTERPRETER_ENGINE == 'pyodide':
|
||||||
|
|||||||
Reference in new issue
Block a user