olivebot/agent/tools/Weather.py
xszyou 875ed28b58 初始上传
初始上传
2023-12-12 00:03:36 +08:00

28 lines
659 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 Weather(BaseTool):
name = "weather"
description = "Use for searching weather at a specific location"
def __init__(self):
super().__init__()
async def _arun(self, *args: Any, **kwargs: Any) -> Any:
# 用例中没有用到 arun 不予具体实现
pass
def _run(self, para: str) -> str:
return "今天天气晴朗风和日丽气温25度空气十分清新心情美美哒"
if __name__ == "__main__":
weather_tool = Weather()
weather_info = weather_tool.run("成都")
print(weather_info)