本篇文章是基于langchain-chatchat-0.3.0配置好bing_key的前提下,出现下面的报错,这个位置上对源码进行修改,方可以正常使用网络搜索。

{'status': 4, 'tool_name': 'search_internet', 'tool_input': {'query': {'title': '大模型最新消息', 'description': '关于大模型的最新进展和研究动态', 'type': 'string'}}, 'text': 'Thought: 我需要搜索相关信息。\nAction: search_internet\nAction Input: {"query": {"title": "大模型最新消息", "description": "关于大模型的最新进展和研究动态", "type": "string"}}'}
<class 'pydantic.v1.main.search_internetSchema'>
{'run_id': 'bc9ddd1b-a7a0-451f-97fb-2def62f9630b', 'status': 6, 'tool': 'search_internet', 'tool_input': "{'query': {'title': '大模型最新消息', 'description': '关于大模型的最新进展和研究动态', 'type': 'string'}}"}
2024-06-28 16:23:39,575 root         674266 ERROR    1 validation error for search_internetSchema
query
  str type expected (type=type_error.str)
Traceback (most recent call last):
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/chatchat/server/utils.py", line 46, in wrap_done
    await fn
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2536, in ainvoke
    input = await step.ainvoke(
            ^^^^^^^^^^^^^^^^^^^
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain/chains/base.py", line 212, in ainvoke
    raise e
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain/chains/base.py", line 203, in ainvoke
    await self._acall(inputs, run_manager=run_manager)
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain/agents/agent.py", line 1481, in _acall
    next_step_output = await self._atake_next_step(
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain/agents/agent.py", line 1275, in _atake_next_step
    [
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain/agents/agent.py", line 1275, in <listcomp>
    [
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain/agents/agent.py", line 1359, in _aiter_next_step
    result = await asyncio.gather(
             ^^^^^^^^^^^^^^^^^^^^^
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain/agents/agent.py", line 1392, in _aperform_agent_action
    observation = await tool.arun(
                  ^^^^^^^^^^^^^^^^
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain_core/tools.py", line 520, in arun
    raise e
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/langchain_core/tools.py", line 497, in arun
    parsed_input = self._parse_input(tool_input)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/chatchat/server/agent/tools_factory/tools_registry.py", line 38, in _new_parse_input
    result = input_args.parse_obj(tool_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/pydantic/v1/main.py", line 526, in parse_obj
    return cls(**obj)
           ^^^^^^^^^^
  File "/etc/miniconda3/envs/chatchat/lib/python3.11/site-packages/pydantic/v1/main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for search_internetSchema
query
  str type expected (type=type_error.str)
2024-06-28 16:23:39,577 root         674266 ERROR    ValidationError: Caught exception: 1 validation error for search_internetSchema
query
  str type expected (type=type_error.str)```

这个时候我们需要在/root/miniconda3/envs/chatchat_0.3.0/lib/python3.11/site-packages/chatchat/webui_pages/dialogue/dialogue.py,这个文件中的dialogue/dialogue.py在420行的位置上,将下面的代码替换掉之前的代码,就可以解决启动不了网络搜索页面报错的问题

这里个需要注意的点是,先不要勾选页面上的agent功能。 修改之后,最后成功运行如下:

最后成功运行如下:

t

GitHub 加速计划 / la / Langchain-Chatchat
30.39 K
5.33 K
下载
Langchain-Chatchat(原Langchain-ChatGLM)基于 Langchain 与 ChatGLM 等语言模型的本地知识库问答 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM) QA app with langchain
最近提交(Master分支:1 个月前 )
86d4e825 3 个月前
10eb8e93 3 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐