Refine model-driven intent routing
This commit is contained in:
parent
662e6a6e0f
commit
2ba18e0b35
|
|
@ -366,12 +366,12 @@ class AsyncRouter:
|
||||||
|
|
||||||
classification_prompt = f"""Классифицируй запрос пользователя: "{task_summary}"
|
classification_prompt = f"""Классифицируй запрос пользователя: "{task_summary}"
|
||||||
|
|
||||||
Правила:
|
Классы:
|
||||||
- execution: пользователь ХОЧЕТ выполнить действие (проверить, запустить, создать, удалить, найти, прочитать, записать)
|
- execution: чтобы ответить, агенту нужно обратиться к локальной среде, файлам, shell, tools, памяти, сети или выполнить проверку/операцию. Это включает вопросы о текущем состоянии ПК, установленных пакетах, файлах, процессах, времени работы, обновлениях, логах.
|
||||||
- conversation: пользователь просто отвечает, задаёт вопрос или хочет информацию
|
- conversation: можно ответить сразу из диалога и общих знаний, без проверки локальной среды и без tools.
|
||||||
- clarification_needed: непонятно что делать
|
- clarification_needed: нельзя понять, что именно пользователь хочет.
|
||||||
|
|
||||||
Ответь ОДНИМ словом: execution / conversation / clarification_needed"""
|
Верни ровно один токен без рассуждений: execution или conversation или clarification_needed"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = await classifier_model.generate(classification_prompt)
|
result = await classifier_model.generate(classification_prompt)
|
||||||
|
|
|
||||||
|
|
@ -23,21 +23,8 @@ MEMORY_STORE_PATTERNS = (
|
||||||
)
|
)
|
||||||
|
|
||||||
MEMORY_SEARCH_PATTERNS = (
|
MEMORY_SEARCH_PATTERNS = (
|
||||||
r"найди\s+(.+)",
|
|
||||||
r"вспомни\s+(.+)",
|
r"вспомни\s+(.+)",
|
||||||
r"search\s+(.+)",
|
r"search memory\s+(.+)",
|
||||||
r"find\s+(.+)",
|
|
||||||
)
|
|
||||||
|
|
||||||
SYSTEM_COMMAND_PATTERNS = (
|
|
||||||
(
|
|
||||||
re.compile(r"(сколько\s+времени\s+запущен|как\s+долго\s+работает|uptime|аптайм)", re.IGNORECASE),
|
|
||||||
"uptime -p",
|
|
||||||
),
|
|
||||||
(
|
|
||||||
re.compile(r"(проверь|посмотри|покажи).*(обновлен|обновл|updates|upgradable)", re.IGNORECASE),
|
|
||||||
"apt list --upgradable",
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -80,19 +67,6 @@ class IntentParser:
|
||||||
reason="User explicitly requested to search memory.",
|
reason="User explicitly requested to search memory.",
|
||||||
)
|
)
|
||||||
|
|
||||||
for pattern, command in SYSTEM_COMMAND_PATTERNS:
|
|
||||||
if pattern.search(normalized):
|
|
||||||
return ExecutionDirective(
|
|
||||||
type="tool",
|
|
||||||
payload={
|
|
||||||
"tool": "shell_exec",
|
|
||||||
"args": {"command": command},
|
|
||||||
},
|
|
||||||
requires_permission=True,
|
|
||||||
confidence=0.9,
|
|
||||||
reason="User explicitly requested local system information.",
|
|
||||||
)
|
|
||||||
|
|
||||||
for prefix in SHELL_PREFIXES:
|
for prefix in SHELL_PREFIXES:
|
||||||
if lowered.startswith(prefix):
|
if lowered.startswith(prefix):
|
||||||
command = normalized[len(prefix) :].strip()
|
command = normalized[len(prefix) :].strip()
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ INSTRUCTIONS:
|
||||||
1. Understand what user wants
|
1. Understand what user wants
|
||||||
2. Create step-by-step plan in natural language
|
2. Create step-by-step plan in natural language
|
||||||
3. Choose appropriate tools from available
|
3. Choose appropriate tools from available
|
||||||
|
4. If the user asks about the current local machine, filesystem, processes,
|
||||||
|
packages, logs, runtime state, or anything that must be observed rather than
|
||||||
|
answered from general knowledge, use an appropriate tool.
|
||||||
|
|
||||||
MODE: {mode_hint}
|
MODE: {mode_hint}
|
||||||
- If mode is "execution": create a plan with TOOL STEPS (shell_exec, file_write, etc)
|
- If mode is "execution": create a plan with TOOL STEPS (shell_exec, file_write, etc)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue