add tools.py
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
"""
|
||||
Utility tools used by the deep agent.
|
||||
|
||||
The functions are decorated with `@tool` from langchain and can be called by the agent.
|
||||
"""
|
||||
|
||||
import os
|
||||
from langchain.tools import tool
|
||||
|
||||
@tool
|
||||
def echo(text: str) -> str:
|
||||
"""Return the same text – useful for demonstration."""
|
||||
return f"Echo: {text}"
|
||||
|
||||
@tool
|
||||
def add(a: int, b: int) -> int:
|
||||
"""Add two integers."""
|
||||
return a + b
|
||||
def get_price(symbol: str) -> str:
|
||||
"""Return the current price for a given stock symbol.
|
||||
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.
|
||||
"""
|
||||
# Mocked response – replace with real API call
|
||||
prices = {
|
||||
"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}."
|
||||
|
||||
Reference in New Issue
Block a user