正式添加aliyun平台,并修复一些bug,优化了日志系统
This commit is contained in:
@@ -20,9 +20,9 @@ class Clear:
|
||||
clean_nopermissoin_message = config.get("clean_nopermissoin_message")
|
||||
|
||||
if "{group_id}" in clean_one_success_message:
|
||||
clean_one_success_message.replace("{group_id}", self.group_id)
|
||||
clean_one_success_message = clean_one_success_message.replace("{group_id}", self.group_id)
|
||||
if "{group_id}" in clean_one_notfound_message:
|
||||
clean_one_notfound_message.replace("{group_id}", self.group_id)
|
||||
clean_one_notfound_message = clean_one_notfound_message.replace("{group_id}", self.group_id)
|
||||
|
||||
if self.is_root():
|
||||
if self.group_id == "all":
|
||||
|
||||
@@ -27,6 +27,9 @@ def main(message,qid,group_openid):
|
||||
elif ai_service == "xyit":
|
||||
from model.ai_models import xyit
|
||||
return xyit.main(message, group_openid)
|
||||
elif ai_service == "aliyun":
|
||||
from model.ai_models import aliyun
|
||||
return aliyun.main(message, group_openid)
|
||||
else:
|
||||
logger.error("未配置ai_service")
|
||||
return error_message
|
||||
|
||||
@@ -26,6 +26,8 @@ def main(message, group_openid):
|
||||
else:
|
||||
logger.info(f"找到 UUID: {uuid}")
|
||||
|
||||
logger.info("请求平台:aliyun")
|
||||
|
||||
# 发送请求
|
||||
response = Application.call(
|
||||
# 若没有配置环境变量,可用百炼API Key将下行替换为:api_key="sk-xxx"。但不建议在生产环境中直接将API Key硬编码到代码中,以减少API Key泄露风险。
|
||||
|
||||
@@ -22,9 +22,9 @@ def main(message, group_openid):
|
||||
uuid = get_uuid(group_openid)
|
||||
|
||||
if uuid == "":
|
||||
logging.info("未找到 UUID")
|
||||
logger.info("未找到 UUID")
|
||||
else:
|
||||
logging.info(f"找到 UUID: {uuid}")
|
||||
logger.info(f"找到 UUID: {uuid}")
|
||||
|
||||
url = f"{dify_ip}/v1/chat-messages" # 替换为实际的 API 地址
|
||||
|
||||
@@ -45,7 +45,7 @@ def main(message, group_openid):
|
||||
"auto_generate_name": True # (选填)自动生成标题,默认为 True
|
||||
}
|
||||
|
||||
logging.info("请求平台:dify")
|
||||
logger.info("请求平台:dify")
|
||||
|
||||
|
||||
# 发送 POST 请求
|
||||
@@ -54,7 +54,7 @@ def main(message, group_openid):
|
||||
|
||||
# 检查响应状态码
|
||||
if response.status_code == 200:
|
||||
logging.info("请求成功!返回结果:")
|
||||
logger.info("请求成功!返回结果:")
|
||||
response_data = response.json()
|
||||
print(response_data) # test
|
||||
# 存储uuid
|
||||
@@ -66,12 +66,12 @@ def main(message, group_openid):
|
||||
answer = response_data.get("answer", error_message)
|
||||
return answer
|
||||
else:
|
||||
logging.info(f"请求失败!状态码: {response.status_code}")
|
||||
logging.info(f"错误信息: {response.text}") # 打印错误信息
|
||||
logger.info(f"请求失败!状态码: {response.status_code}")
|
||||
logger.info(f"错误信息: {response.text}") # 打印错误信息
|
||||
return error_message
|
||||
|
||||
except Exception as e:
|
||||
logging.info(f"请求过程中出现异常: {e}")
|
||||
logger.info(f"请求过程中出现异常: {e}")
|
||||
return error_message
|
||||
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ def setup_logger(log_file=None, log_level=logging.INFO, max_bytes=10485760, back
|
||||
logging.Logger: 配置好的日志记录器
|
||||
"""
|
||||
# 创建logger
|
||||
logger = logging.getLogger('mcsmapi')
|
||||
logger = logging.getLogger('chatbot-napcat')
|
||||
logger.setLevel(log_level)
|
||||
logger.propagate = False
|
||||
|
||||
# 避免重复添加handler
|
||||
if logger.handlers:
|
||||
|
||||
Reference in New Issue
Block a user