Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用工具的时候可以取到中间过程的响应吗? #158

Closed
languanghao opened this issue Sep 5, 2024 · 3 comments
Closed

使用工具的时候可以取到中间过程的响应吗? #158

languanghao opened this issue Sep 5, 2024 · 3 comments

Comments

@languanghao
Copy link

  1. 向agent注册获取当前时间的工具
  2. 提问:今天天气怎么样
  3. 预期效果:希望能够在 output 进行输出格式控制,如果没有成功调用tool,则返回“我不了这个问题”

目前看到确实大模型返回了一个可以解析的JSON格式
[Final Response]

{
   "need_tool": false,
   "input_target_language": "中文",
   "tools_using": []
}

要怎么样才能取到 need_tool 这个字段的值?

@Maplemx
Copy link
Owner

Maplemx commented Sep 5, 2024

使用监听器:

def judgement_handler(data):
    pass

def tool_response_handler(data):
    pass

agent.add_event_listener("tool:judgement", judgement_handler)
agent.add_event_listener("tool:response", tool_response_handler)

@languanghao
Copy link
Author

languanghao commented Sep 7, 2024

@Maplemx 感谢大佬,试了下,事件名称应该如下才对:

agent
        .add_event_listener("tool:judgement", judgement_handler)
        .add_event_listener("tool:response", tool_response_handler)

@Maplemx
Copy link
Owner

Maplemx commented Sep 9, 2024

@Maplemx 感谢大佬,试了下,事件名称应该如下才对:

agent
        .add_event_listener("tool:judgement", judgement_handler)
        .add_event_listener("tool:response", tool_response_handler)

啊,对的,typo了

@Maplemx Maplemx pinned this issue Sep 18, 2024
@Maplemx Maplemx closed this as completed Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants