Replies: 1 comment 2 replies
-
To create a custom tool based on from langflow.base.langchain_utilities.model import LCToolComponent
from langflow.field_typing import Tool
from langflow.schema import Data
import requests
class TemperatureComponent(LCToolComponent):
name: str = "TemperatureComponent"
description: str = "Returns the current temperature."
def build_tool(self) -> Tool:
return Tool(name="TemperatureTool", description="Returns current temperature")
def run_model(self) -> Data:
# Example API call to get the current temperature
response = requests.get("https://api.weatherapi.com/v1/current.json?key=YOUR_API_KEY&q=London")
temperature = response.json().get("current", {}).get("temp_c", "N/A")
return Data(data=f"Current temperature: {temperature}°C") Replace |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
@dosu-bot provide an example of custom tool that based on LCToolComponent and have no inputs (for example, just returns current temperature)
Beta Was this translation helpful? Give feedback.
All reactions