Files
2026-05-26 13:53:34 +00:00

38 lines
975 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.
"""
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 hardcoded 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