mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
2482317ccc
320 files reformatted. One-time alignment to match the ruff format check added to CI in #4812.
23 lines
603 B
Python
23 lines
603 B
Python
from langchain.tools import tool
|
|
from pathlib import Path
|
|
import csv
|
|
|
|
# Read data at module load time to avoid file I/O issues in
|
|
# LangGraph Cloud's sandboxed tool execution environment.
|
|
_csv_path = Path(__file__).parent / "db.csv"
|
|
with open(_csv_path) as _f:
|
|
_cached_data = list(csv.DictReader(_f))
|
|
|
|
|
|
@tool
|
|
def query_data(query: str):
|
|
"""
|
|
Query the database, takes natural language. Always call before showing a chart or graph.
|
|
"""
|
|
import time
|
|
|
|
print(
|
|
f"[A2UI-DEBUG] query_data called: query='{query[:60]}' at {time.strftime('%H:%M:%S')}"
|
|
)
|
|
return _cached_data
|