From 03daffc4bbae7340102413237cc9b7f84e292225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B8=D1=80=D0=B8=D0=BB=D0=BB=20=D0=9A=D1=83=D1=82?= =?UTF-8?q?=D0=BB=D0=B0=D1=85=D0=BC=D0=B5=D1=82=D0=BE=D0=B2?= Date: Wed, 27 May 2026 13:20:23 +0000 Subject: [PATCH] add tools.py --- tools.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tools.py b/tools.py index f5f2e61..b68e819 100644 --- a/tools.py +++ b/tools.py @@ -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}."