Merge pull request #13812 from hwzhuhao/refactor/log

refactor: replace print statements with logging
This commit is contained in:
Tim Jaeryang Baek 2025-05-14 15:27:13 +04:00 committed by GitHub
commit c7e3ae9f39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View File

@ -651,7 +651,7 @@ def apply_params_to_form_data(form_data, model):
convert_logit_bias_input_to_json(params["logit_bias"]) convert_logit_bias_input_to_json(params["logit_bias"])
) )
except Exception as e: except Exception as e:
print(f"Error parsing logit_bias: {e}") log.exception(f"Error parsing logit_bias: {e}")
return form_data return form_data

View File

@ -37,6 +37,7 @@ from open_webui.models.tools import Tools
from open_webui.models.users import UserModel from open_webui.models.users import UserModel
from open_webui.utils.plugin import load_tool_module_by_id from open_webui.utils.plugin import load_tool_module_by_id
from open_webui.env import ( from open_webui.env import (
SRC_LOG_LEVELS,
AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA, AIOHTTP_CLIENT_TIMEOUT_TOOL_SERVER_DATA,
AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL, AIOHTTP_CLIENT_SESSION_TOOL_SERVER_SSL,
) )
@ -44,6 +45,7 @@ from open_webui.env import (
import copy import copy
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
log.setLevel(SRC_LOG_LEVELS["MODELS"])
def get_async_tool_function_and_apply_extra_params( def get_async_tool_function_and_apply_extra_params(
@ -477,7 +479,7 @@ async def get_tool_server_data(token: str, url: str) -> Dict[str, Any]:
"specs": convert_openapi_to_tool_payload(res), "specs": convert_openapi_to_tool_payload(res),
} }
print("Fetched data:", data) log.info("Fetched data:", data)
return data return data
@ -510,7 +512,7 @@ async def get_tool_servers_data(
results = [] results = []
for (idx, server, url, _), response in zip(server_entries, responses): for (idx, server, url, _), response in zip(server_entries, responses):
if isinstance(response, Exception): if isinstance(response, Exception):
print(f"Failed to connect to {url} OpenAPI tool server") log.error(f"Failed to connect to {url} OpenAPI tool server")
continue continue
results.append( results.append(
@ -620,5 +622,5 @@ async def execute_tool_server(
except Exception as err: except Exception as err:
error = str(err) error = str(err)
print("API Request Error:", error) log.exception("API Request Error:", error)
return {"error": error} return {"error": error}