[WIP] Translate mixed English comments to Chinese (#3256)
* Initial plan * Changes before error encountered Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: LIghtJUNction <106986785+LIghtJUNction@users.noreply.github.com>
This commit is contained in:
@@ -134,10 +134,10 @@ class ChatRoute(Route):
|
|||||||
if not conversation_id:
|
if not conversation_id:
|
||||||
return Response().error("conversation_id is empty").__dict__
|
return Response().error("conversation_id is empty").__dict__
|
||||||
|
|
||||||
# append user message
|
# 追加用户消息
|
||||||
webchat_conv_id = await self._get_webchat_conv_id_from_conv_id(conversation_id)
|
webchat_conv_id = await self._get_webchat_conv_id_from_conv_id(conversation_id)
|
||||||
|
|
||||||
# Get conversation-specific queues
|
# 获取会话特定的队列
|
||||||
back_queue = webchat_queue_mgr.get_or_create_back_queue(webchat_conv_id)
|
back_queue = webchat_queue_mgr.get_or_create_back_queue(webchat_conv_id)
|
||||||
|
|
||||||
new_his = {"type": "user", "message": message}
|
new_his = {"type": "user", "message": message}
|
||||||
@@ -200,7 +200,7 @@ class ChatRoute(Route):
|
|||||||
or not streaming
|
or not streaming
|
||||||
or type == "break"
|
or type == "break"
|
||||||
):
|
):
|
||||||
# append bot message
|
# 追加机器人消息
|
||||||
new_his = {"type": "bot", "message": result_text}
|
new_his = {"type": "bot", "message": result_text}
|
||||||
await self.platform_history_mgr.insert(
|
await self.platform_history_mgr.insert(
|
||||||
platform_id="webchat",
|
platform_id="webchat",
|
||||||
@@ -212,7 +212,7 @@ class ChatRoute(Route):
|
|||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
logger.exception(f"WebChat stream unexpected error: {e}", exc_info=True)
|
logger.exception(f"WebChat stream unexpected error: {e}", exc_info=True)
|
||||||
|
|
||||||
# Put message to conversation-specific queue
|
# 将消息放入会话特定的队列
|
||||||
chat_queue = webchat_queue_mgr.get_or_create_queue(webchat_conv_id)
|
chat_queue = webchat_queue_mgr.get_or_create_queue(webchat_conv_id)
|
||||||
await chat_queue.put(
|
await chat_queue.put(
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class AstrBotDashboard:
|
|||||||
allowed_endpoints = ["/api/auth/login", "/api/file"]
|
allowed_endpoints = ["/api/auth/login", "/api/file"]
|
||||||
if any(request.path.startswith(prefix) for prefix in allowed_endpoints):
|
if any(request.path.startswith(prefix) for prefix in allowed_endpoints):
|
||||||
return None
|
return None
|
||||||
# claim jwt
|
# 声明 JWT
|
||||||
token = request.headers.get("Authorization")
|
token = request.headers.get("Authorization")
|
||||||
if not token:
|
if not token:
|
||||||
r = jsonify(Response().error("未授权").__dict__)
|
r = jsonify(Response().error("未授权").__dict__)
|
||||||
|
|||||||
12
main.py
12
main.py
@@ -11,7 +11,7 @@ from astrbot.core.initial_loader import InitialLoader
|
|||||||
from astrbot.core.utils.astrbot_path import get_astrbot_data_path
|
from astrbot.core.utils.astrbot_path import get_astrbot_data_path
|
||||||
from astrbot.core.utils.io import download_dashboard, get_dashboard_version
|
from astrbot.core.utils.io import download_dashboard, get_dashboard_version
|
||||||
|
|
||||||
# add parent path to sys.path
|
# 将父目录添加到 sys.path
|
||||||
sys.path.append(Path(__file__).parent.as_posix())
|
sys.path.append(Path(__file__).parent.as_posix())
|
||||||
|
|
||||||
logo_tmpl = r"""
|
logo_tmpl = r"""
|
||||||
@@ -34,7 +34,7 @@ def check_env():
|
|||||||
os.makedirs("data/plugins", exist_ok=True)
|
os.makedirs("data/plugins", exist_ok=True)
|
||||||
os.makedirs("data/temp", exist_ok=True)
|
os.makedirs("data/temp", exist_ok=True)
|
||||||
|
|
||||||
# workaround for issue #181
|
# 针对问题 #181 的临时解决方案
|
||||||
mimetypes.add_type("text/javascript", ".js")
|
mimetypes.add_type("text/javascript", ".js")
|
||||||
mimetypes.add_type("text/javascript", ".mjs")
|
mimetypes.add_type("text/javascript", ".mjs")
|
||||||
mimetypes.add_type("application/json", ".json")
|
mimetypes.add_type("application/json", ".json")
|
||||||
@@ -53,7 +53,7 @@ async def check_dashboard_files(webui_dir: str | None = None):
|
|||||||
if os.path.exists(data_dist_path):
|
if os.path.exists(data_dist_path):
|
||||||
v = await get_dashboard_version()
|
v = await get_dashboard_version()
|
||||||
if v is not None:
|
if v is not None:
|
||||||
# has file
|
# 存在文件
|
||||||
if v == f"v{VERSION}":
|
if v == f"v{VERSION}":
|
||||||
logger.info("WebUI 版本已是最新。")
|
logger.info("WebUI 版本已是最新。")
|
||||||
else:
|
else:
|
||||||
@@ -88,16 +88,16 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
check_env()
|
check_env()
|
||||||
|
|
||||||
# start log broker
|
# 启动日志代理
|
||||||
log_broker = LogBroker()
|
log_broker = LogBroker()
|
||||||
LogManager.set_queue_handler(logger, log_broker)
|
LogManager.set_queue_handler(logger, log_broker)
|
||||||
|
|
||||||
# check dashboard files
|
# 检查仪表板文件
|
||||||
webui_dir = asyncio.run(check_dashboard_files(args.webui_dir))
|
webui_dir = asyncio.run(check_dashboard_files(args.webui_dir))
|
||||||
|
|
||||||
db = db_helper
|
db = db_helper
|
||||||
|
|
||||||
# print logo
|
# 打印 logo
|
||||||
logger.info(logo_tmpl)
|
logger.info(logo_tmpl)
|
||||||
|
|
||||||
core_lifecycle = InitialLoader(db, log_broker)
|
core_lifecycle = InitialLoader(db, log_broker)
|
||||||
|
|||||||
Reference in New Issue
Block a user