Files
agent-s-rag-pamyatyu/src/tools.py
T
2026-06-29 17:42:08 +03:00

41 lines
822 B
Python

from langchain.tools import tool
from typing import List
@tool
def add_numbers(a: int, b: int) -> int:
"""
Add two numbers and return the sum.
Parameters
----------
a : int
The first number.
b : int
The second number.
Returns
-------
int
The sum of a and b.
"""
return a + b
@tool
def search_item(items: List[str], query: str) -> List[str]:
"""
Search for items containing the query string (case-insensitive).
Parameters
----------
items : List[str]
The list of items to search.
query : str
The search query.
Returns
-------
List[str]
A list of items that contain the query string.
"""
query_lower = query.lower()
return [item for item in items if query_lower in item.lower()]