commit some debug log
This commit is contained in:
parent
52bf829a84
commit
fd1a46ffd9
|
|
@ -40,7 +40,7 @@ LLM_MODEL_CONFIG:
|
||||||
prompt_name: default
|
prompt_name: default
|
||||||
callbacks: false
|
callbacks: false
|
||||||
llm_model:
|
llm_model:
|
||||||
model: 'qwen2-instruct'
|
model: ''
|
||||||
temperature: 0.9
|
temperature: 0.9
|
||||||
max_tokens: 4096
|
max_tokens: 4096
|
||||||
history_len: 10
|
history_len: 10
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
||||||
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
|
||||||
|
|
||||||
from langchain.agents import tool
|
from langchain.agents import tool
|
||||||
from langchain_core.tools import BaseTool
|
from langchain_core.tools import BaseTool
|
||||||
|
from chatchat.utils import build_logger
|
||||||
from chatchat.server.knowledge_base.kb_doc_api import DocumentWithVSId
|
from chatchat.server.knowledge_base.kb_doc_api import DocumentWithVSId
|
||||||
from chatchat.server.pydantic_v1 import BaseModel, Extra
|
from chatchat.server.pydantic_v1 import BaseModel, Extra
|
||||||
|
|
||||||
|
|
@ -24,6 +23,7 @@ BaseTool.Config.extra = Extra.allow
|
||||||
################################### TODO: workaround to langchain #15855
|
################################### TODO: workaround to langchain #15855
|
||||||
# patch BaseTool to support tool parameters defined using pydantic Field
|
# patch BaseTool to support tool parameters defined using pydantic Field
|
||||||
|
|
||||||
|
logger = build_logger()
|
||||||
|
|
||||||
def _new_parse_input(
|
def _new_parse_input(
|
||||||
self,
|
self,
|
||||||
|
|
@ -32,8 +32,9 @@ def _new_parse_input(
|
||||||
"""Convert tool input to pydantic model."""
|
"""Convert tool input to pydantic model."""
|
||||||
try:
|
try:
|
||||||
input_args = self.args_schema
|
input_args = self.args_schema
|
||||||
|
logger.info(f"input_args:{input_args}, tool_input:{tool_input}")
|
||||||
if isinstance(tool_input, str):
|
if isinstance(tool_input, str):
|
||||||
logging.info(f"tool_input:{tool_input}")
|
logger.info(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})
|
||||||
|
|
@ -41,18 +42,18 @@ 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}")
|
logger.info(f"result:{result}")
|
||||||
return result.dict()
|
return result.dict()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = f"Caught exception: {e}"
|
msg = f"Caught exception: {e}"
|
||||||
logging.error(f"{e.__class__.__name__}: {msg}")
|
logger.error(f"{e.__class__.__name__}: {msg}")
|
||||||
|
|
||||||
|
|
||||||
def _new_to_args_and_kwargs(self, tool_input: Union[str, Dict]) -> Tuple[Tuple, Dict]:
|
def _new_to_args_and_kwargs(self, tool_input: Union[str, Dict]) -> Tuple[Tuple, Dict]:
|
||||||
# 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}")
|
logger.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
|
||||||
|
|
@ -63,7 +64,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}")
|
logger.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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue