16 lines
494 B
Python
16 lines
494 B
Python
import logging
|
|
|
|
from .models import AgentRun
|
|
from .langgraph_adapter import SimpleAgent
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def run_agent(agent: SimpleAgent, prompt: str) -> str:
|
|
"""Run the agent and store an AgentRun record using the Django ORM."""
|
|
out = agent.run(prompt)
|
|
try:
|
|
AgentRun.objects.create(agent_name=agent.name, input_text=prompt, output_text=out)
|
|
except Exception:
|
|
logger.exception("Failed to persist agent run via Django ORM")
|
|
return out
|