commit some debug log

This commit is contained in:
weiweiw 2025-01-06 17:04:34 +08:00
parent 68bd4ffef1
commit b225390080
3 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,7 @@
from __future__ import annotations from __future__ import annotations
import json import json
import logging
import re import re
from typing import Any, Callable, Dict, Optional, Tuple, Type, Union from typing import Any, Callable, Dict, Optional, Tuple, Type, Union
@ -31,6 +32,7 @@ def _new_parse_input(
"""Convert tool input to pydantic model.""" """Convert tool input to pydantic model."""
input_args = self.args_schema input_args = self.args_schema
if isinstance(tool_input, str): if isinstance(tool_input, str):
print(f"tool_input:{tool_input}")
if input_args is not None: if input_args is not None:
key_ = next(iter(input_args.__fields__.keys())) key_ = next(iter(input_args.__fields__.keys()))
input_args.validate({key_: tool_input}) input_args.validate({key_: tool_input})
@ -38,6 +40,7 @@ def _new_parse_input(
else: else:
if input_args is not None: if input_args is not None:
result = input_args.parse_obj(tool_input) result = input_args.parse_obj(tool_input)
logging.info(f"result:{result}")
return result.dict() return result.dict()
@ -45,6 +48,7 @@ def _new_to_args_and_kwargs(self, tool_input: Union[str, Dict]) -> Tuple[Tuple,
# For backwards compatibility, if run_input is a string, # For backwards compatibility, if run_input is a string,
# pass as a positional argument. # pass as a positional argument.
if isinstance(tool_input, str): if isinstance(tool_input, str):
logging.info(f"tool_input:{tool_input}")
return (tool_input,), {} return (tool_input,), {}
else: else:
# for tool defined with `*args` parameters # for tool defined with `*args` parameters
@ -55,6 +59,7 @@ def _new_to_args_and_kwargs(self, tool_input: Union[str, Dict]) -> Tuple[Tuple,
# .search_api # .search_api
if "args" in tool_input: if "args" in tool_input:
args = tool_input["args"] args = tool_input["args"]
logging.info(f"args:{args}")
if args is None: if args is None:
tool_input.pop("args") tool_input.pop("args")
return (), tool_input return (), tool_input

View File

@ -4,7 +4,6 @@
import logging import logging
import requests import requests
import warnings
from chatchat.server.pydantic_v1 import Field from chatchat.server.pydantic_v1 import Field
from chatchat.server.utils import get_tool_config from chatchat.server.utils import get_tool_config
@ -17,7 +16,6 @@ def weather_check(
): ):
"""Use this tool to check the weather at a specific city""" """Use this tool to check the weather at a specific city"""
# warnings.filterwarnings("ignore", message="Unverified HTTPS request")
print(f"weather_check tool内部调用city{city}") print(f"weather_check tool内部调用city{city}")
tool_config = get_tool_config("weather_check") tool_config = get_tool_config("weather_check")
api_key = tool_config.get("api_key") api_key = tool_config.get("api_key")

View File

@ -58,7 +58,6 @@ if __name__ == "__main__":
sac.MenuItem("多功能对话", icon="chat"), sac.MenuItem("多功能对话", icon="chat"),
sac.MenuItem("RAG 对话", icon="database"), sac.MenuItem("RAG 对话", icon="database"),
sac.MenuItem("知识库管理", icon="hdd-stack"), sac.MenuItem("知识库管理", icon="hdd-stack"),
sac.MenuItem("LLM对话", icon="chat"),
], ],
key="selected_page", key="selected_page",
open_index=0, open_index=0,