Files
2026-05-27 13:20:23 +00:00

21 lines
659 B
Python
Raw Permalink 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 langchain.tools import tool
@tool
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}."