fix: 修复 vchat 适配器路径错误和一些其他优化

This commit is contained in:
Soulter
2024-12-11 00:55:39 +08:00
parent c6bdac8835
commit e9e789da20
4 changed files with 15 additions and 30 deletions
+3 -24
View File
@@ -137,7 +137,7 @@ PROVIDER_CONFIG_TEMPLATE = {
# 平台适配器配置模板
ADAPTER_CONFIG_TEMPLATE = {
"qq_official": {
"qq_official(QQ)": {
"id": "default",
"name": "qq_official",
"enable": False,
@@ -146,14 +146,14 @@ ADAPTER_CONFIG_TEMPLATE = {
"enable_group_c2c": True,
"enable_guild_direct_message": True,
},
"aiocqhtp": {
"aiocqhtp(QQ)": {
"id": "default",
"name": "aiocqhttp",
"enable": False,
"ws_reverse_host": "",
"ws_reverse_port": 6199
},
"wechat": {
"vchat(微信)": {
"id": "default",
"name": "vchat",
"enable": False
@@ -218,8 +218,6 @@ CONFIG_METADATA_2 = {
"enable": {"description": "启用", "type": "bool", "hint": "是否启用该模型。未启用的模型将不会被使用。"},
"key": {"description": "API Key", "type": "list", "items": {"type": "string"}, "hint": "API Key 列表。填写好后输入回车即可添加 API Key。支持多个 API Key。"},
"api_base": {"description": "API Base URL", "type": "string", "hint": "API Base URL 请在在模型提供商处获得。支持 Ollama 开放的 API 地址。如果您确认填写正确但是使用时出现了 404 异常,可以尝试在地址末尾加上 `/v1`。"},
"prompt_prefix": {"description": "Prompt 前缀", "type": "text", "hint": "每次与 LLM 对话时在对话前加上的自定义文本。默认为空。"},
"default_personality": {"description": "默认人格", "type": "text", "hint": "在当前版本下,默认人格文本会被添加到 LLM 对话的 `system` 字段中。"},
"model_config": {
"description": "文本生成模型",
"type": "object",
@@ -230,25 +228,6 @@ CONFIG_METADATA_2 = {
"top_p": {"description": "Top P值", "type": "float"},
}
},
"image_generation_model_config": {
"description": "图像生成模型",
"type": "object",
"items": {
"enable": {"description": "启用", "type": "bool", "hint": "启用该功能需要提供商支持图像生成。如 dall-e-3"},
"model": {"description": "模型名称", "type": "string", "hint": "图像生成模型的名称,一般是小写的英文。如 dall-e-3"},
"size": {"description": "图像尺寸", "type": "string"},
"style": {"description": "图像风格", "type": "string"},
"quality": {"description": "图像质量", "type": "string"},
}
},
"embedding_model": {
"description": "文本嵌入模型",
"type": "object",
"items": {
"enable": {"description": "启用", "type": "bool", "hint": "启用该功能需要提供商支持文本嵌入。"},
"model": {"description": "模型名称", "type": "string", "hint": "文本嵌入模型的名称,一般是小写的英文。如 text-embedding-3-small"},
}
}
}
},
"provider_settings": {
+1 -1
View File
@@ -24,7 +24,7 @@ class PlatformManager():
case "qqofficial":
from .sources.qqofficial.qqofficial_platform_adapter import QQOfficialAdapter # noqa: F401
case "vchat":
from .sources.vchat.vchat_platform_adapter import VChatAdapter # noqa: F401
from .sources.vchat.vchat_platform_adapter import VChatPlatformAdapter # noqa: F401
async def initialize(self):
for platform in self.platforms_config:
@@ -65,7 +65,7 @@ class VChatPlatformAdapter(Platform):
async def _run(self):
await self.client.init()
await self.client.auto_login(hot_reload=True)
await self.client.auto_login(hot_reload=True, enable_cmd_qr=True)
await self.client.run()
def convert_message(self, msg: model.Message) -> AstrBotMessage:
+10 -4
View File
@@ -2,7 +2,7 @@ import logging
import jwt
import asyncio
import os
from quart import Quart, request
from quart import Quart, request, jsonify
from quart.logging import default_handler
from astrbot.core.core_lifecycle import AstrBotCoreLifecycle
from .routes import *
@@ -41,15 +41,21 @@ class AstrBotDashboard():
# claim jwt
token = request.headers.get("Authorization")
if not token:
return Response().error("未授权").__dict__
r = jsonify(Response().error("未授权").__dict__)
r.status_code = 401
return r
if token.startswith("Bearer "):
token = token[7:]
try:
jwt.decode(token, WEBUI_SK, algorithms=["HS256"])
except jwt.ExpiredSignatureError:
return Response().error("Token 过期").__dict__
r = jsonify(Response().error("Token 过期").__dict__)
r.status_code = 401
return r
except jwt.InvalidTokenError:
return Response().error("Token 无效").__dict__
r = jsonify(Response().error("Token 无效").__dict__)
r.status_code = 401
return r
async def shutdown_trigger_placeholder(self):