Langchain-Chatchat icon indicating copy to clipboard operation
Langchain-Chatchat copied to clipboard

调用自定义Agent,查询天气,没有任何返回

Open jingzl opened this issue 1 year ago • 3 comments

问题描述 / Problem Description 选择对话,对话模式为自定义Agent问答,LLM模型为 chatglm3-6b。在kb_config.py中已配置好 SENIVERSE_API_KEY。

复现问题的步骤 / Steps to Reproduce 询问:今天北京的天气

预期的结果 / Expected Result 应该正常返回北京的天气信息。

实际结果 / Actual Result Thought: 我需要使用weather_check工具来检查天气预报。 然后没有结果。感觉没有调用 weather_check 工具,如何才能有结果呢?

环境信息 / Environment Information

  • langchain-ChatGLM 版本/commit 号:v0.2.10
  • 是否使用 Docker 部署(是/否):否
  • 使用的模型(ChatGLM2-6B / Qwen-7B 等):ChatGLM3-6B
  • 使用的 Embedding 模型(moka-ai/m3e-base 等):bge-large-zh-v1.5 @ cuda
  • 使用的向量库类型 (faiss / milvus / pg_vector 等): faiss
  • 操作系统及版本 / Operating system and version: ubuntu 20.04
  • Python 版本 / Python version: 3.11
  • 其他相关环境信息 / Other relevant environment information:

附加信息 / Additional Information image image

jingzl avatar Feb 25 '24 09:02 jingzl

🤖

嘿,@jingzl!我们又见面了😄 希望一切都好!

您遇到的问题可能是由于在提供的上下文中没有使用 SENIVERSE_API_KEY。您提供的代码并未显示 SENIVERSE_API_KEY 的使用,而这是获取天气数据所必需的。

SENIVERSE_API_KEY 应在获取天气数据的工具中使用。如果该工具没有使用这个密钥,它将无法获取天气数据,因此,代理将不会返回任何与天气相关的结果。

要解决这个问题,您需要确保负责获取天气数据的工具正确使用了 SENIVERSE_API_KEY。如果该工具是代码中的 tools 对象的一部分,您需要检查这个工具的实现,并确保它使用了 kb_config.py 中的 SENIVERSE_API_KEY。

遗憾的是,如果没有获取天气数据的工具的代码或 kb_config.py 文件,我无法提供更具体的解决方案。

此外,我在 Langchain-Chatchat 代码库中找到了一个类似的已解决问题。问题链接为:向模型提问模型没有回答,终端显示无法访问chatglm的api。建议的解决方案是更改配置文件中的端口号以解决地址已在使用中的错误。具体来说,更新 model_config.py 文件,为 chatglm2-6b 模型配置使用不同的端口,如 8889。同时,更新 server_config.py 文件以匹配新的端口号。

关于 weather_check 工具的具体功能,它在 Langchain-Chatchat 代码库中用于检查给定位置的当前天气。它通过向 Seniverse Weather API 发送请求来实现这一点。

weather 函数接受位置和 API 密钥作为参数。它使用这些参数构造一个 URL,并向 Seniverse Weather API 发送 GET 请求。如果请求成功(状态码 200),它会从响应中提取温度和天气描述,并将它们以字典的形式返回。如果请求不成功,它会引发异常。

weathercheck 函数是 weather 函数的简化版本,只需要位置作为参数。它使用位置和预定义的 API 密钥调用 weather 函数。

WeatherInput 类是一个 Pydantic 模型,代表了 weathercheck 函数的输入。它有一个字段,location,这是一个字符串,描述了城市名称,包括城市和县。

相关代码如下:

def weather(location: str, api_key: str):
    url = f"https://api.seniverse.com/v3/weather/now.json?key={api_key}&location={location}&language=zh-Hans&unit=c"
    response = requests.get(url)
    if response.status_code == 200:
        data = response.json()
        weather = {
            "temperature": data["results"][0]["now"]["temperature"],
            "description": data["results"][0]["now"]["text"],
        }
        return weather
    else:
        raise Exception(
            f"Failed to retrieve weather: {response.status_code}")

def weathercheck(location: str):
    return weather(location, SENIVERSE_API_KEY)

class WeatherInput(BaseModel):
    location: str = Field(description="City name,include city and county")

来源:

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

dosubot[bot] avatar Feb 25 '24 09:02 dosubot[bot]

好像智能助手 没有理解我的意思,我已经设置好了 心知天气 API KEY。 有其他人碰到这个问题吗? 现在是一个agent都没有调用成功,是哪里配置出了问题?

现在的情况如下:

今天武汉的天气如何? I will use the 'weather_check' tool to find out the current weather in Wuhan. 思考过程: I will use the 'weather_check' tool to find out the current weather in Wuhan.

然后就没有下文了。

jingzl avatar Feb 25 '24 10:02 jingzl

🤖

It seems like this user is facing some issues with the API configuration, @imClumsyPanda, your expertise would be greatly appreciated here.

dosubot[bot] avatar Feb 25 '24 10:02 dosubot[bot]

chatglm3要用glm的格式,其他事default

zRzRzRzRzRzRzR avatar Feb 28 '24 04:02 zRzRzRzRzRzRzR

@zRzRzRzRzRzRzR 你回复的这个是啥意思,有文档吗?

monkeydone avatar Feb 28 '24 12:02 monkeydone

1 2

jingzl avatar Feb 28 '24 12:02 jingzl

问题依旧

jingzl avatar Feb 28 '24 12:02 jingzl

temper拉到0.01 ,其他的话我没雨遇到了,我这是正常运行的

zRzRzRzRzRzRzR avatar Feb 28 '24 13:02 zRzRzRzRzRzRzR

请问解决了吗,我也是这个问题

HARUCCC avatar Mar 05 '24 02:03 HARUCCC

我也是遇到调用tool不成功的情况,即使是使用自带的计算器工具也基本和楼主的情况一样,思考过程表示需要调用相应的工具,然后就没有输出了

pyyj avatar Mar 07 '24 02:03 pyyj

遇到相同的问题,请问问题解决了吗

victorxst avatar Mar 08 '24 06:03 victorxst

chatglm3要用glm的格式,其他事default

请问chatglm3需要特有的什么格式,是提示的格式还是什么

pyyj avatar Mar 08 '24 11:03 pyyj

没有解决,问题依旧

jingzl avatar Mar 09 '24 08:03 jingzl

同样的问题,有人解决了嘛,调用本地的glm3大模型

LUJUN1 avatar Apr 18 '24 00:04 LUJUN1

同样的问题,有人解决了吗?????

liujie316316 avatar Apr 19 '24 08:04 liujie316316

相同的问题,有人解决吗?

Leiyanzangxiangsi avatar Apr 23 '24 06:04 Leiyanzangxiangsi