chore: format

This commit is contained in:
Timothy Jaeryang Baek
2026-02-28 21:28:59 -06:00
parent 43c30428a6
commit 1357dc6737
70 changed files with 3295 additions and 355 deletions
+13 -10
View File
@@ -930,10 +930,9 @@ def process_tool_result(
else:
tool_result = tool_result.body.decode("utf-8", "replace")
elif (
tool_type in EXTERNAL_TOOL_TYPES
and isinstance(tool_result, tuple)
) or (direct_tool and isinstance(tool_result, list) and len(tool_result) == 2):
elif (tool_type in EXTERNAL_TOOL_TYPES and isinstance(tool_result, tuple)) or (
direct_tool and isinstance(tool_result, list) and len(tool_result) == 2
):
tool_result, tool_response_headers = tool_result
try:
@@ -1232,7 +1231,10 @@ async def chat_completion_tools_handler(
if event_emitter:
await display_file_handler(
tool_function_name, tool_function_params, tool_result, event_emitter
tool_function_name,
tool_function_params,
tool_result,
event_emitter,
)
if tool_result_files:
@@ -4223,7 +4225,10 @@ async def streaming_chat_response_handler(response, ctx):
)
await display_file_handler(
tool_function_name, tool_function_params, tool_result, event_emitter
tool_function_name,
tool_function_params,
tool_result,
event_emitter,
)
# Extract citation sources from tool results
@@ -4408,8 +4413,7 @@ async def streaming_chat_response_handler(response, ctx):
code = sanitize_code(code)
if CODE_INTERPRETER_BLOCKED_MODULES:
blocking_code = textwrap.dedent(
f"""
blocking_code = textwrap.dedent(f"""
import builtins
BLOCKED_MODULES = {CODE_INTERPRETER_BLOCKED_MODULES}
@@ -4425,8 +4429,7 @@ async def streaming_chat_response_handler(response, ctx):
return _real_import(name, globals, locals, fromlist, level)
builtins.__import__ = restricted_import
"""
)
""")
code = blocking_code + "\n" + code
if (
+18 -21
View File
@@ -144,8 +144,6 @@ def get_updated_tool_function(function: Callable, extra_params: dict):
return function
async def get_tools(
request: Request, tool_ids: list[str], user: UserModel, extra_params: dict
) -> dict[str, dict]:
@@ -909,19 +907,21 @@ async def set_terminal_servers(request: Request):
enabled = connection.get("enabled", True)
server_configs.append({
"url": connection.get("url", ""),
"key": connection.get("key", ""),
"auth_type": connection.get("auth_type", "bearer"),
"path": connection.get("path", "/openapi.json"),
"spec_type": "url",
# get_tool_servers_data reads config.enable to filter active servers
"config": {"enable": enabled},
"info": {
"id": connection.get("id", ""),
"name": connection.get("name", ""),
},
})
server_configs.append(
{
"url": connection.get("url", ""),
"key": connection.get("key", ""),
"auth_type": connection.get("auth_type", "bearer"),
"path": connection.get("path", "/openapi.json"),
"spec_type": "url",
# get_tool_servers_data reads config.enable to filter active servers
"config": {"enable": enabled},
"info": {
"id": connection.get("id", ""),
"name": connection.get("name", ""),
},
}
)
request.app.state.TERMINAL_SERVERS = await get_tool_servers_data(server_configs)
@@ -965,9 +965,7 @@ async def get_terminal_tools(
- Builds callables that route through the terminal proxy
"""
connections = request.app.state.config.TERMINAL_SERVER_CONNECTIONS or []
connection = next(
(c for c in connections if c.get("id") == terminal_id), None
)
connection = next((c for c in connections if c.get("id") == terminal_id), None)
if connection is None:
log.warning(f"Terminal server not found: {terminal_id}")
return {}
@@ -1007,9 +1005,7 @@ async def get_terminal_tools(
headers["Authorization"] = f"Bearer {oauth_token.get('access_token', '')}"
# auth_type == "none": no Authorization header
terminal_cwd = await get_terminal_cwd(
connection.get("url", ""), headers, cookies
)
terminal_cwd = await get_terminal_cwd(connection.get("url", ""), headers, cookies)
tools_dict = {}
for spec in specs:
@@ -1033,6 +1029,7 @@ async def get_terminal_tools(
params=kwargs,
server_data=srv_data,
)
return tool_function
tool_function = make_tool_function(function_name, server_data, headers, cookies)