Spaces:
Running
Running
File size: 1,086 Bytes
c8e458d 6011d47 c8e458d 6011d47 c8e458d 6011d47 c8e458d 6011d47 c8e458d 6011d47 c8e458d 6011d47 c8e458d 6011d47 c8e458d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
from langchain_core.tools import tool
import csv
@tool
def register_purchase_request(product: str, price: float):
"""Register a purchase request."""
try:
with open("purchase_requests.csv", "a") as f:
writer = csv.writer(f)
writer.writerow([product, price])
except Exception as e:
pass
return {
"dialog_state": ["Financial_Management"],
"messages": [
{
"type": "text",
"content": f"Registering a purchase request for {product} at {price}"
}
]
}
@tool
def view_expense_report(info: str):
"""View an expense report."""
try:
with open("expense_reports.csv", "r") as f:
reader = csv.reader(f)
expense_reports = list(reader)
except Exception as e:
expense_reports = []
return {
"dialog_state": ["Financial_Management"],
"messages": [
{
"type": "text",
"content": f"Expense report: {expense_reports}"
}
]
} |