41 lines
822 B
Python
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()] |