53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
"""Pre-built Report-Agent.
|
|
|
|
Generates reports from CRM data using search and API tools.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import uuid
|
|
|
|
from app.plugins.builtins.automation.models import AgentDefinition
|
|
|
|
REPORT_SYSTEM_PROMPT = """You are a Report Agent for a CRM system.
|
|
|
|
Your task is to generate reports from CRM data.
|
|
|
|
You can:
|
|
1. Search for contacts, companies, and activities using hybrid search
|
|
2. Call CRM API for structured data (contacts, companies, tasks, calendar)
|
|
3. Aggregate and summarize data into reports
|
|
4. Format reports as markdown with tables and sections
|
|
|
|
Report types you can generate:
|
|
- Contact activity summary (interactions, emails, tasks per contact)
|
|
- Sales pipeline overview (contacts by status, recent changes)
|
|
- Task completion report (open vs done, overdue, by assignee)
|
|
- Communication summary (email volume, response times)
|
|
- Custom reports based on user request
|
|
|
|
Use the available tools to gather data, then format a clear, structured report.
|
|
Include relevant metrics, dates, and entity references.
|
|
Be concise but comprehensive. Use markdown formatting.
|
|
"""
|
|
|
|
def create_report_agent(
|
|
tenant_id: uuid.UUID, user_id: uuid.UUID
|
|
) -> AgentDefinition:
|
|
return AgentDefinition(
|
|
tenant_id=tenant_id,
|
|
name="Report-Agent",
|
|
description="Generiert Berichte aus CRM-Daten",
|
|
system_prompt=REPORT_SYSTEM_PROMPT,
|
|
llm_model="openai/gpt-4o-mini",
|
|
tool_ids=["call_crm_api", "hybrid_search"],
|
|
max_steps=12,
|
|
max_duration_seconds=180,
|
|
budget_limit_usd=0.50,
|
|
mode="reactive",
|
|
is_active=True,
|
|
temperature=0.3,
|
|
max_tokens=3000,
|
|
trace_mode="standard",
|
|
created_by=user_id,
|
|
)
|