feat(agent-core): 增加智能编排与模型工具基础
This commit is contained in:
1
agent_core/tools/__init__.py
Normal file
1
agent_core/tools/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
47
agent_core/tools/builtin_tools.py
Normal file
47
agent_core/tools/builtin_tools.py
Normal file
@@ -0,0 +1,47 @@
|
||||
def calculate_rate(user_input: str) -> dict:
|
||||
return {"rate": 1.0, "note": "模拟比例计算结果"}
|
||||
|
||||
|
||||
def query_demo_records(user_input: str) -> dict:
|
||||
try:
|
||||
from apps.audit.models import DemoBusinessRecord
|
||||
except Exception as exc:
|
||||
return {"records": [], "error": str(exc)}
|
||||
|
||||
queryset = DemoBusinessRecord.objects.all()
|
||||
tokens = {token.strip().lower() for token in user_input.split() if token.strip()}
|
||||
scenario_ids = set(queryset.values_list("scenario_id", flat=True))
|
||||
record_types = set(queryset.values_list("record_type", flat=True))
|
||||
matched_scenario_ids = scenario_ids & tokens
|
||||
matched_record_types = record_types & tokens
|
||||
if matched_scenario_ids:
|
||||
queryset = queryset.filter(scenario_id__in=matched_scenario_ids)
|
||||
if matched_record_types:
|
||||
queryset = queryset.filter(record_type__in=matched_record_types)
|
||||
records = [
|
||||
{
|
||||
"id": record.id,
|
||||
"scenario_id": record.scenario_id,
|
||||
"record_type": record.record_type,
|
||||
"title": record.title,
|
||||
"payload": record.payload,
|
||||
}
|
||||
for record in queryset[:20]
|
||||
]
|
||||
return {"records": records}
|
||||
|
||||
|
||||
def check_required_fields(user_input: str) -> dict:
|
||||
return {"missing_fields": [], "note": "模拟必填项检查结果"}
|
||||
|
||||
|
||||
def generate_action_items(user_input: str) -> dict:
|
||||
return {"items": [f"围绕问题继续核实:{user_input}"]}
|
||||
|
||||
|
||||
BUILTIN_TOOLS = {
|
||||
"calculate_rate": calculate_rate,
|
||||
"query_demo_records": query_demo_records,
|
||||
"check_required_fields": check_required_fields,
|
||||
"generate_action_items": generate_action_items,
|
||||
}
|
||||
Reference in New Issue
Block a user