70 lines
2.6 KiB
Python
70 lines
2.6 KiB
Python
from sqlalchemy import select
|
|
from sqlalchemy.orm import Session
|
|
|
|
from .models import AgentMessageTemplate
|
|
|
|
DEFAULT_AGENT_TEMPLATES = [
|
|
{
|
|
"slug": "agent_run_completion",
|
|
"name": "Agent Run Success",
|
|
"description": (
|
|
"Notify end users when an Urmi AI agent run completes, with a dynamic "
|
|
"View Report button linking to the completion report."
|
|
),
|
|
"header_text": "Agent Run Complete",
|
|
"body_preview": (
|
|
"Hello {{customer_name}}, your agent run is complete, you can access "
|
|
"the completion report at your URMI AI Portal."
|
|
),
|
|
"footer_text": "Thanks and regards, team - URMI AI",
|
|
"meta_template_name": "agent_run_completion",
|
|
"language": "en",
|
|
"category": "utility",
|
|
"parameters": [
|
|
{
|
|
"name": "customer_name",
|
|
"type": "string",
|
|
"required": True,
|
|
"description": "Recipient display name shown in the greeting",
|
|
"example": "Suyash",
|
|
},
|
|
{
|
|
"name": "report_group",
|
|
"type": "string",
|
|
"required": True,
|
|
"description": "Urmiport report group slug used in the hosted report URL",
|
|
"example": "acme-agent-runs",
|
|
},
|
|
{
|
|
"name": "report_id",
|
|
"type": "string",
|
|
"required": True,
|
|
"description": "Report postfix appended after the report group in the View Report button URL",
|
|
"example": "run-abc123",
|
|
},
|
|
],
|
|
"button_label": "View Report",
|
|
"button_url_base": "https://urmiai.com/reports/",
|
|
},
|
|
]
|
|
|
|
|
|
def seed_agent_message_templates(db: Session) -> None:
|
|
for item in DEFAULT_AGENT_TEMPLATES:
|
|
existing = db.scalar(select(AgentMessageTemplate).where(AgentMessageTemplate.slug == item["slug"]))
|
|
if existing:
|
|
existing.name = item["name"]
|
|
existing.description = item["description"]
|
|
existing.header_text = item["header_text"]
|
|
existing.body_preview = item["body_preview"]
|
|
existing.footer_text = item["footer_text"]
|
|
existing.meta_template_name = item["meta_template_name"]
|
|
existing.language = item["language"]
|
|
existing.category = item["category"]
|
|
existing.parameters = item["parameters"]
|
|
existing.button_label = item["button_label"]
|
|
existing.button_url_base = item["button_url_base"]
|
|
existing.is_active = True
|
|
else:
|
|
db.add(AgentMessageTemplate(**item))
|
|
db.commit()
|