From 6113e0373366d29166a3732402e9fdb2c00d449a 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: Tue, 26 May 2026 13:53:34 +0000 Subject: [PATCH] add tools.py --- tools.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tools.py diff --git a/tools.py b/tools.py new file mode 100644 index 0000000..f4979c1 --- /dev/null +++ b/tools.py @@ -0,0 +1,37 @@ +""" +Utility module that defines the tool(s) used by the streaming agent. + +The project currently contains a single mock ``get_price`` function. The +implementation is intentionally tiny – it simply looks up a hard‑coded price +in a dictionary. In real projects this would be replaced with an API call or +database query. +""" + +from langchain.tools import tool + +@tool +def get_price(product: str, city: str) -> str: + """Return a fake price for *product* in *city*. + + Parameters + ---------- + product : str + Name of the product (e.g. ``milk``). + city : str + City where the price is requested. + + Returns + ------- + str + A string describing the price, e.g. ``"89 rubles"``. + """ + prices = { + ("milk", "kazan"): "89", + ("bread", "kazan"): "45", + ("coffee", "moscow"): "120", + } + key = (product.lower(), city.lower()) + price = prices.get(key, "unknown") + return f"{price} rubles" + +# End of tools.py