olivebot/agent/tools/Say.py

35 lines
913 B
Python
Raw Normal View History

2023-12-12 00:03:36 +08:00
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
2023-12-12 00:03:36 +08:00
class Say(BaseTool):
name = "语音输出工具"
description = """此工具用于语音输出,使用时请传入说话内容作为参数,例如:“该下班了,请注意休息”"""
2023-12-12 00:03:36 +08:00
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})
2023-12-12 00:03:36 +08:00
fay_booter.feiFei.on_interact(interact)
agent_service.agent.is_chat = True
2023-12-12 00:03:36 +08:00
return "语音输出了:" + para
if __name__ == "__main__":
tool = Say()
info = tool.run("该下班了,请注意休息")
print(info)