NATS wildcards (node.*.capabilities.get) only work for subscriptions, not for publish. Switch to a dedicated broadcast subject (fabric.capabilities.discover) that all NCS instances subscribe to, enabling proper scatter-gather discovery across nodes. Made-with: Cursor
40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
from pathlib import Path
|
||
from crewai import Agent
|
||
from crews.agromatrix_crew.llm_factory import make_llm
|
||
|
||
_PROMPT_PATH = Path(__file__).parent.parent / "stepan_system_prompt_v2.txt"
|
||
|
||
|
||
def _load_system_prompt() -> str:
|
||
try:
|
||
return _PROMPT_PATH.read_text(encoding="utf-8")
|
||
except Exception:
|
||
return (
|
||
"Ти — Степан, операційний агент AgroMatrix. "
|
||
"Говориш коротко, по ділу, живою українською мовою. "
|
||
"Не пишеш сервісних повідомлень. Відповідаєш прямо."
|
||
)
|
||
|
||
|
||
def build_stepan(style_prefix: str = "") -> Agent:
|
||
"""
|
||
Будує агента Степана.
|
||
style_prefix — персоналізований prefix від style_adapter.build_style_prefix().
|
||
Якщо не передано — використовується базовий системний промпт.
|
||
"""
|
||
backstory = _load_system_prompt()
|
||
if style_prefix:
|
||
backstory = style_prefix.strip() + "\n\n" + backstory
|
||
return Agent(
|
||
role="Stepan (AgroMatrix Operational Agent)",
|
||
goal=(
|
||
"Відповідати на запити точно і людяно. "
|
||
"Делегувати під-агентам лише якщо без них неможливо. "
|
||
"Повертати консолідовану відповідь без технічного сміття."
|
||
),
|
||
backstory=backstory,
|
||
llm=make_llm(),
|
||
allow_delegation=True,
|
||
verbose=False,
|
||
)
|