File size: 982 Bytes
d677097
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# agents/specialized/base.py
from core.llm_client import llm
from utils.prompts import get_today_prefix, get_chat_style


def build_result(agent_key: str) -> dict:
    """Estructura base de resultado para cualquier agente."""
    return {
        "agent": agent_key,
        "response": "",
        "success": True,
        "file_path": None,
        "file_type": None,
        "image_urls": [],
        "queries": None,
    }


async def call_llm(agent_key: str, role: str, task: str, context: dict = None) -> str:
    """Llama al LLM con el rol, tarea y contexto dados."""
    today = get_today_prefix()
    full_prompt = today + role + get_chat_style() + f"\n\nTarea asignada: {task}"

    if context:
        full_prompt += "\n\nContexto de otros agentes:\n" + "\n".join(
            [f"[{k.upper()}] {v[:300]}..." for k, v in context.items()]
        )

    messages = [{"role": "user", "content": full_prompt}]
    return await llm.call(agent_key, messages, temperature=0.45)