mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-14 06:30:57 +00:00
Merge pull request #1209 from wangcham/feat/wxoa-notice-msg
feat: add support for loading message in wxoa
This commit is contained in:
@@ -176,7 +176,7 @@ class OAClient():
|
|||||||
|
|
||||||
class OAClientForLongerResponse():
|
class OAClientForLongerResponse():
|
||||||
|
|
||||||
def __init__(self,token:str,EncodingAESKey:str,AppID:str,Appsecret:str):
|
def __init__(self,token:str,EncodingAESKey:str,AppID:str,Appsecret:str,LoadingMessage:str):
|
||||||
self.token = token
|
self.token = token
|
||||||
self.aes = EncodingAESKey
|
self.aes = EncodingAESKey
|
||||||
self.appid = AppID
|
self.appid = AppID
|
||||||
@@ -189,6 +189,7 @@ class OAClientForLongerResponse():
|
|||||||
"example":[],
|
"example":[],
|
||||||
}
|
}
|
||||||
self.access_token_expiry_time = None
|
self.access_token_expiry_time = None
|
||||||
|
self.loading_message = LoadingMessage
|
||||||
|
|
||||||
async def handle_callback_request(self):
|
async def handle_callback_request(self):
|
||||||
try:
|
try:
|
||||||
@@ -246,7 +247,7 @@ class OAClientForLongerResponse():
|
|||||||
to_user=from_user,
|
to_user=from_user,
|
||||||
from_user=to_user,
|
from_user=to_user,
|
||||||
create_time=int(time.time()),
|
create_time=int(time.time()),
|
||||||
content="AI正在思考中,请发送任意内容获取回答。"
|
content=self.loading_message
|
||||||
)
|
)
|
||||||
|
|
||||||
if user_msg_queue.get(from_user) and user_msg_queue[from_user][0]["content"]:
|
if user_msg_queue.get(from_user) and user_msg_queue[from_user][0]["content"]:
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from .. import migration
|
||||||
|
|
||||||
|
|
||||||
|
@migration.migration_class("wxoa-loading-message", 36)
|
||||||
|
class WxoaLoadingMessageMigration(migration.Migration):
|
||||||
|
"""迁移"""
|
||||||
|
|
||||||
|
async def need_migrate(self) -> bool:
|
||||||
|
"""判断当前环境是否需要运行此迁移"""
|
||||||
|
|
||||||
|
for adapter in self.ap.platform_cfg.data['platform-adapters']:
|
||||||
|
if adapter['adapter'] == 'officialaccount':
|
||||||
|
if 'LoadingMessage' not in adapter:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
async def run(self):
|
||||||
|
"""执行迁移"""
|
||||||
|
for adapter in self.ap.platform_cfg.data['platform-adapters']:
|
||||||
|
if adapter['adapter'] == 'officialaccount':
|
||||||
|
if 'LoadingMessage' not in adapter:
|
||||||
|
adapter['LoadingMessage'] = 'AI正在思考中,请发送任意内容获取回复。'
|
||||||
|
|
||||||
|
await self.ap.platform_cfg.dump_config()
|
||||||
@@ -11,7 +11,7 @@ from ..migrations import m015_gitee_ai_config, m016_dify_service_api, m017_dify_
|
|||||||
from ..migrations import m020_wecom_config, m021_lark_config, m022_lmstudio_config, m023_siliconflow_config, m024_discord_config, m025_gewechat_config
|
from ..migrations import m020_wecom_config, m021_lark_config, m022_lmstudio_config, m023_siliconflow_config, m024_discord_config, m025_gewechat_config
|
||||||
from ..migrations import m026_qqofficial_config, m027_wx_official_account_config, m028_aliyun_requester_config
|
from ..migrations import m026_qqofficial_config, m027_wx_official_account_config, m028_aliyun_requester_config
|
||||||
from ..migrations import m029_dashscope_app_api_config, m030_lark_config_cmpl, m031_dingtalk_config, m032_volcark_config
|
from ..migrations import m029_dashscope_app_api_config, m030_lark_config_cmpl, m031_dingtalk_config, m032_volcark_config
|
||||||
from ..migrations import m033_dify_thinking_config, m034_gewechat_file_url_config, m035_wxoa_mode
|
from ..migrations import m033_dify_thinking_config, m034_gewechat_file_url_config, m035_wxoa_mode, m036_wxoa_loading_message
|
||||||
|
|
||||||
@stage.stage_class("MigrationStage")
|
@stage.stage_class("MigrationStage")
|
||||||
class MigrationStage(stage.BootingStage):
|
class MigrationStage(stage.BootingStage):
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ class OfficialAccountAdapter(adapter.MessagePlatformAdapter):
|
|||||||
EncodingAESKey=config['EncodingAESKey'],
|
EncodingAESKey=config['EncodingAESKey'],
|
||||||
Appsecret=config['AppSecret'],
|
Appsecret=config['AppSecret'],
|
||||||
AppID=config['AppID'],
|
AppID=config['AppID'],
|
||||||
|
LoadingMessage=config['LoadingMessage']
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise KeyError("请设置微信公众号通信模式")
|
raise KeyError("请设置微信公众号通信模式")
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
"AppID":"",
|
"AppID":"",
|
||||||
"AppSecret":"",
|
"AppSecret":"",
|
||||||
"Mode":"drop",
|
"Mode":"drop",
|
||||||
|
"LoadingMessage":"AI正在思考中,请发送任意内容获取回复。",
|
||||||
"host": "0.0.0.0",
|
"host": "0.0.0.0",
|
||||||
"port": 2287
|
"port": 2287
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -391,6 +391,11 @@
|
|||||||
"description": "对于超过15s的响应的处理模式",
|
"description": "对于超过15s的响应的处理模式",
|
||||||
"enum": ["drop", "passive"]
|
"enum": ["drop", "passive"]
|
||||||
},
|
},
|
||||||
|
"LoadingMessage": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "AI正在思考中,请发送任意内容获取回复。",
|
||||||
|
"description": "当使用被动模式时,显示给用户的提示信息"
|
||||||
|
},
|
||||||
"host": {
|
"host": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "0.0.0.0",
|
"default": "0.0.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user