mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 07:27:15 +08:00
feat(agent): 在系统提示词中注入MoviePilot配置信息
This commit is contained in:
@@ -57,4 +57,7 @@ Specific markdown rules:
|
|||||||
{markdown_spec}
|
{markdown_spec}
|
||||||
</markdown_spec>
|
</markdown_spec>
|
||||||
|
|
||||||
Today's date: {current_date}
|
<system_info>
|
||||||
|
{moviepilot_info}
|
||||||
|
- 今日日期: {current_date}
|
||||||
|
</system_info>
|
||||||
|
|||||||
@@ -83,15 +83,62 @@ class PromptManager:
|
|||||||
"DO NOT output any content whatsoever until your final summary reply."
|
"DO NOT output any content whatsoever until your final summary reply."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# MoviePilot系统信息
|
||||||
|
moviepilot_info = self._get_moviepilot_info()
|
||||||
|
|
||||||
# 始终替换占位符,避免后续 .format() 时因残留花括号报 KeyError
|
# 始终替换占位符,避免后续 .format() 时因残留花括号报 KeyError
|
||||||
base_prompt = base_prompt.format(
|
base_prompt = base_prompt.format(
|
||||||
markdown_spec=markdown_spec,
|
markdown_spec=markdown_spec,
|
||||||
verbose_spec=verbose_spec,
|
verbose_spec=verbose_spec,
|
||||||
current_date=strftime("%Y-%m-%d")
|
current_date=strftime("%Y-%m-%d"),
|
||||||
|
moviepilot_info=moviepilot_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
return base_prompt
|
return base_prompt
|
||||||
|
|
||||||
|
def _get_moviepilot_info(self) -> str:
|
||||||
|
"""
|
||||||
|
获取MoviePilot系统信息,用于注入到系统提示词中
|
||||||
|
"""
|
||||||
|
import socket
|
||||||
|
|
||||||
|
try:
|
||||||
|
hostname = socket.gethostname()
|
||||||
|
ip_address = socket.gethostbyname(hostname)
|
||||||
|
except Exception:
|
||||||
|
hostname = "localhost"
|
||||||
|
ip_address = "127.0.0.1"
|
||||||
|
|
||||||
|
config_path = str(settings.CONFIG_PATH)
|
||||||
|
log_path = str(settings.LOG_PATH)
|
||||||
|
|
||||||
|
api_port = settings.PORT
|
||||||
|
api_path = settings.API_V1_STR
|
||||||
|
|
||||||
|
if settings.APP_DOMAIN:
|
||||||
|
domain = settings.APP_DOMAIN
|
||||||
|
if domain.startswith("http://") or domain.startswith("https://"):
|
||||||
|
api_url = f"{domain}{api_path}"
|
||||||
|
else:
|
||||||
|
api_url = f"https://{domain}{api_path}"
|
||||||
|
else:
|
||||||
|
api_url = f"http://{ip_address}:{api_port}{api_path}"
|
||||||
|
|
||||||
|
api_token = settings.API_TOKEN or "未设置"
|
||||||
|
|
||||||
|
info_lines = [
|
||||||
|
f"- 主机名: {hostname}",
|
||||||
|
f"- IP地址: {ip_address}",
|
||||||
|
f"- API地址: {api_url}",
|
||||||
|
f"- API端口: {api_port}",
|
||||||
|
f"- API路径: {api_path}",
|
||||||
|
f"- API令牌: {api_token}",
|
||||||
|
f"- 配置文件目录: {config_path}",
|
||||||
|
f"- 日志文件目录: {log_path}",
|
||||||
|
]
|
||||||
|
|
||||||
|
return "\n".join(info_lines)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _generate_formatting_instructions(caps: ChannelCapabilities) -> str:
|
def _generate_formatting_instructions(caps: ChannelCapabilities) -> str:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user