add tools.py

This commit is contained in:
2026-05-27 13:20:23 +00:00
parent 5beafcde6e
commit 03daffc4bb
+17 -14
View File
@@ -1,17 +1,20 @@
""" import os
Utility tools used by the deep agent.
The functions are decorated with `@tool` from langchain and can be called by the agent.
"""
from langchain.tools import tool from langchain.tools import tool
@tool @tool
def echo(text: str) -> str: def get_price(symbol: str) -> str:
"""Return the same text useful for demonstration.""" """Return the current price for a given stock symbol.
return f"Echo: {text}" For demo purposes, this function returns a mocked value.
In a real implementation you would query an API such as Yahoo Finance or Alpha Vantage.
@tool """
def add(a: int, b: int) -> int: # Mocked response replace with real API call
"""Add two integers.""" prices = {
return a + b "AAPL": 150.12,
"GOOG": 2750.45,
"MSFT": 299.87,
"TSLA": 720.33,
}
price = prices.get(symbol.upper(), None)
if price is None:
return f"Price for {symbol} not found."
return f"The current price of {symbol.upper()} is ${price:.2f}."