File size: 922 Bytes
7fafb5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98a0172
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


# AGENT SELECTOR - core/agent_selector.py

"""

LLM-Based Agent Selector - If no rule fires, we send the input to the LLM with a prompt asking which agent should respond

"""

from core.llm_client import ask_llm
from core.agent_triggers import RULE_TRIGGERS

def rule_based_selection(user_input):
    for agent, keywords in RULE_TRIGGERS.items():
        for keyword in keywords:
            if keyword.lower() in user_input.lower():
                return agent  # Immediate match
    return None  # No rule match

def llm_based_selection(user_input):
    prompt = f"""

    Based on the user's input, which agent should respond?

    The user says: "{user_input}"



    Options: dream, shadow, myth, epistemic, bpsy, jred.

    Choose the most relevant agent and justify your choice.

    Respond with only the agent name.

    """
    response = ask_llm(prompt)
    return response.strip().lower()