mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
refactor(prompt): 优化MoviePilot系统信息注入,统一日期与环境信息展示
This commit is contained in:
@@ -59,5 +59,4 @@ Specific markdown rules:
|
|||||||
|
|
||||||
<system_info>
|
<system_info>
|
||||||
{moviepilot_info}
|
{moviepilot_info}
|
||||||
- 今日日期: {current_date}
|
|
||||||
</system_info>
|
</system_info>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"""提示词管理器"""
|
"""提示词管理器"""
|
||||||
|
import socket
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from time import strftime
|
from time import strftime
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
@@ -12,6 +12,7 @@ from app.schemas import (
|
|||||||
MessageChannel,
|
MessageChannel,
|
||||||
ChannelCapabilityManager,
|
ChannelCapabilityManager,
|
||||||
)
|
)
|
||||||
|
from app.utils.system import SystemUtils
|
||||||
|
|
||||||
|
|
||||||
class PromptManager:
|
class PromptManager:
|
||||||
@@ -90,49 +91,44 @@ class PromptManager:
|
|||||||
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"),
|
|
||||||
moviepilot_info=moviepilot_info,
|
moviepilot_info=moviepilot_info,
|
||||||
)
|
)
|
||||||
|
|
||||||
return base_prompt
|
return base_prompt
|
||||||
|
|
||||||
def _get_moviepilot_info(self) -> str:
|
@staticmethod
|
||||||
|
def _get_moviepilot_info() -> str:
|
||||||
"""
|
"""
|
||||||
获取MoviePilot系统信息,用于注入到系统提示词中
|
获取MoviePilot系统信息,用于注入到系统提示词中
|
||||||
"""
|
"""
|
||||||
import socket
|
# 获取主机名和IP地址
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
ip_address = socket.gethostbyname(hostname)
|
ip_address = socket.gethostbyname(hostname)
|
||||||
except Exception:
|
except Exception: # noqa
|
||||||
hostname = "localhost"
|
hostname = "localhost"
|
||||||
ip_address = "127.0.0.1"
|
ip_address = "127.0.0.1"
|
||||||
|
|
||||||
|
# 配置文件和日志文件目录
|
||||||
config_path = str(settings.CONFIG_PATH)
|
config_path = str(settings.CONFIG_PATH)
|
||||||
log_path = str(settings.LOG_PATH)
|
log_path = str(settings.LOG_PATH)
|
||||||
|
|
||||||
|
# API地址构建
|
||||||
api_port = settings.PORT
|
api_port = settings.PORT
|
||||||
api_path = settings.API_V1_STR
|
api_path = settings.API_V1_STR
|
||||||
|
|
||||||
if settings.APP_DOMAIN:
|
# API令牌
|
||||||
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 "未设置"
|
api_token = settings.API_TOKEN or "未设置"
|
||||||
|
|
||||||
info_lines = [
|
info_lines = [
|
||||||
|
f"- 当前日期: {strftime('%Y-%m-%d')}",
|
||||||
|
f"- 运行环境: {SystemUtils.platform} {'docker' if SystemUtils.is_docker() else ''}",
|
||||||
f"- 主机名: {hostname}",
|
f"- 主机名: {hostname}",
|
||||||
f"- IP地址: {ip_address}",
|
f"- IP地址: {ip_address}",
|
||||||
f"- API地址: {api_url}",
|
|
||||||
f"- API端口: {api_port}",
|
f"- API端口: {api_port}",
|
||||||
f"- API路径: {api_path}",
|
f"- API路径: {api_path}",
|
||||||
f"- API令牌: {api_token}",
|
f"- API令牌: {api_token}",
|
||||||
|
f"- 外网域名: {settings.APP_DOMAIN or '未设置'}",
|
||||||
f"- 配置文件目录: {config_path}",
|
f"- 配置文件目录: {config_path}",
|
||||||
f"- 日志文件目录: {log_path}",
|
f"- 日志文件目录: {log_path}",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user