You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
700 B
31 lines
700 B
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
# @Time : 2025/3/16 16:38
|
|
# @Author : old-tom
|
|
# @File : basic_tool
|
|
# @Project : llmFunctionCallDemo
|
|
# @Desc :
|
|
|
|
import json
|
|
from langchain_core.tools import tool
|
|
|
|
@tool
|
|
def get_current_weather(location: str, unit: str = "celsius") -> str:
|
|
"""Get the current weather in a given location
|
|
|
|
Args:
|
|
location (str): location of the weather.
|
|
unit (str): unit of the tempuature.
|
|
|
|
Returns:
|
|
str: weather in the given location.
|
|
"""
|
|
|
|
weather_info = {
|
|
"location": location,
|
|
"temperature": "27",
|
|
"unit": unit,
|
|
"forecast": ["sunny", "windy"],
|
|
}
|
|
return json.dumps(weather_info)
|