olivebot/agent/tools/Switch.py
xszyou a27ab9dfba 第3次更新
更换ReAct agent✓
修复Thread.timer管理逻辑✓
优化提示词减小返回格式出错概率(格式出错会导致重复执行)✓
消息窗里加上执行任务标记✓
更换gpt 3.5模型测试✓
2023-12-14 10:38:08 +08:00

29 lines
717 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import os
from typing import Any
import requests
from langchain.tools import BaseTool
class Switch(BaseTool):
name = "Switch"
description = "此工具用于控制箱内制冷设备A、制热设备(B)、内外通风设备(C)、浇水设备(D)、补光设备(E)、二氧化碳设备(F)的开关状态,参数格式:('A':'on')"
def __init__(self):
super().__init__()
async def _arun(self, *args: Any, **kwargs: Any) -> Any:
# 用例中没有用到 arun 不予具体实现
pass
def _run(self, para: str) -> str:
return para
if __name__ == "__main__":
tool = Switch()
info = tool.run("""{"name":"制热设备","switch":"on"}""")
print(info)