01c19c13e8
*实现agent ReAct与LLM chain自动切换逻辑✓ 聊天窗区分任务消息✓ 修复删除日程bug✓ 优化远程音频逻辑✓ 等待处理引入加载中效果✓ 优化prompt以解决日程任务递归调用问题✓ 修复一次性日程清除的bug✓
35 lines
913 B
Python
35 lines
913 B
Python
import os
|
|
from typing import Any
|
|
|
|
import requests
|
|
from langchain.tools import BaseTool
|
|
import fay_booter
|
|
from core.interact import Interact
|
|
from agent import agent_service
|
|
|
|
|
|
class Say(BaseTool):
|
|
name = "语音输出工具"
|
|
description = """此工具用于语音输出,使用时请传入说话内容作为参数,例如:“该下班了,请注意休息”"""
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
|
|
async def _arun(self, *args: Any, **kwargs: Any) -> Any:
|
|
# 用例中没有用到 arun 不予具体实现
|
|
pass
|
|
|
|
|
|
def _run(self, para: str) -> str:
|
|
interact = Interact("audio", 1, {'user': '', 'msg': para})
|
|
fay_booter.feiFei.on_interact(interact)
|
|
agent_service.agent.is_chat = True
|
|
return "语音输出了:" + para
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
tool = Say()
|
|
info = tool.run("该下班了,请注意休息")
|
|
print(info)
|