Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 800c9d8344 | |||
| f132964436 |
@@ -19,7 +19,6 @@ from astrbot.core.astr_agent_hooks import MAIN_AGENT_HOOKS
|
|||||||
from astrbot.core.astr_agent_run_util import AgentRunner
|
from astrbot.core.astr_agent_run_util import AgentRunner
|
||||||
from astrbot.core.astr_agent_tool_exec import FunctionToolExecutor
|
from astrbot.core.astr_agent_tool_exec import FunctionToolExecutor
|
||||||
from astrbot.core.astr_main_agent_resources import (
|
from astrbot.core.astr_main_agent_resources import (
|
||||||
CHATUI_EXTRA_PROMPT,
|
|
||||||
CHATUI_SPECIAL_DEFAULT_PERSONA_PROMPT,
|
CHATUI_SPECIAL_DEFAULT_PERSONA_PROMPT,
|
||||||
EXECUTE_SHELL_TOOL,
|
EXECUTE_SHELL_TOOL,
|
||||||
FILE_DOWNLOAD_TOOL,
|
FILE_DOWNLOAD_TOOL,
|
||||||
@@ -259,6 +258,8 @@ async def _ensure_persona_and_skills(
|
|||||||
return
|
return
|
||||||
|
|
||||||
# get persona ID
|
# get persona ID
|
||||||
|
|
||||||
|
# 1. from session service config - highest priority
|
||||||
persona_id = (
|
persona_id = (
|
||||||
await sp.get_async(
|
await sp.get_async(
|
||||||
scope="umo",
|
scope="umo",
|
||||||
@@ -269,14 +270,15 @@ async def _ensure_persona_and_skills(
|
|||||||
).get("persona_id")
|
).get("persona_id")
|
||||||
|
|
||||||
if not persona_id:
|
if not persona_id:
|
||||||
persona_id = req.conversation.persona_id or cfg.get("default_personality")
|
# 2. from conversation setting - second priority
|
||||||
if persona_id is None or persona_id != "[%None]":
|
persona_id = req.conversation.persona_id
|
||||||
default_persona = plugin_context.persona_manager.selected_default_persona_v3
|
|
||||||
if default_persona:
|
if persona_id == "[%None]":
|
||||||
persona_id = default_persona["name"]
|
# explicitly set to no persona
|
||||||
if event.get_platform_name() == "webchat":
|
pass
|
||||||
persona_id = "_chatui_default_"
|
elif persona_id is None:
|
||||||
req.system_prompt += CHATUI_SPECIAL_DEFAULT_PERSONA_PROMPT
|
# 3. from config default persona setting - last priority
|
||||||
|
persona_id = cfg.get("default_personality")
|
||||||
|
|
||||||
persona = next(
|
persona = next(
|
||||||
builtins.filter(
|
builtins.filter(
|
||||||
@@ -291,6 +293,11 @@ async def _ensure_persona_and_skills(
|
|||||||
req.system_prompt += f"\n# Persona Instructions\n\n{prompt}\n"
|
req.system_prompt += f"\n# Persona Instructions\n\n{prompt}\n"
|
||||||
if begin_dialogs := copy.deepcopy(persona.get("_begin_dialogs_processed")):
|
if begin_dialogs := copy.deepcopy(persona.get("_begin_dialogs_processed")):
|
||||||
req.contexts[:0] = begin_dialogs
|
req.contexts[:0] = begin_dialogs
|
||||||
|
else:
|
||||||
|
# special handling for webchat persona
|
||||||
|
if event.get_platform_name() == "webchat" and persona_id != "[%None]":
|
||||||
|
persona_id = "_chatui_default_"
|
||||||
|
req.system_prompt += CHATUI_SPECIAL_DEFAULT_PERSONA_PROMPT
|
||||||
|
|
||||||
# Inject skills prompt
|
# Inject skills prompt
|
||||||
skills_cfg = cfg.get("skills", {})
|
skills_cfg = cfg.get("skills", {})
|
||||||
@@ -931,7 +938,6 @@ async def build_main_agent(
|
|||||||
|
|
||||||
if event.get_platform_name() == "webchat":
|
if event.get_platform_name() == "webchat":
|
||||||
asyncio.create_task(_handle_webchat(event, req, provider))
|
asyncio.create_task(_handle_webchat(event, req, provider))
|
||||||
req.system_prompt += f"\n{CHATUI_EXTRA_PROMPT}\n"
|
|
||||||
|
|
||||||
if req.func_tool and req.func_tool.tools:
|
if req.func_tool and req.func_tool.tools:
|
||||||
tool_prompt = (
|
tool_prompt = (
|
||||||
|
|||||||
@@ -78,9 +78,6 @@ CHATUI_SPECIAL_DEFAULT_PERSONA_PROMPT = (
|
|||||||
"You listen more than you speak, respect uncertainty, avoid forcing quick conclusions or grand narratives, "
|
"You listen more than you speak, respect uncertainty, avoid forcing quick conclusions or grand narratives, "
|
||||||
"and prefer clear, restrained language over unnecessary emotional embellishment. At your core, you value "
|
"and prefer clear, restrained language over unnecessary emotional embellishment. At your core, you value "
|
||||||
"empathy, clarity, autonomy, and meaning, favoring steady, sustainable progress over judgment or dramatic leaps."
|
"empathy, clarity, autonomy, and meaning, favoring steady, sustainable progress over judgment or dramatic leaps."
|
||||||
)
|
|
||||||
|
|
||||||
CHATUI_EXTRA_PROMPT = (
|
|
||||||
'When you answered, you need to add a follow up question / summarization but do not add "Follow up" words. '
|
'When you answered, you need to add a follow up question / summarization but do not add "Follow up" words. '
|
||||||
"Such as, user asked you to generate codes, you can add: Do you need me to run these codes for you?"
|
"Such as, user asked you to generate codes, you can add: Do you need me to run these codes for you?"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user