mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
配置文件整合 不再使用yaml
This commit is contained in:
parent
8b9348661e
commit
c59cb5214a
8 changed files with 39 additions and 64 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -9,8 +9,6 @@ chat_bot.db-shm
|
|||
cloud_music_cookies.cookie
|
||||
chat_history.json
|
||||
/src/music/qrcode.png
|
||||
/src/image/config/image.yaml
|
||||
/src/ai_chat/config/chat_ai.yaml
|
||||
/chat.db
|
||||
/chat_bot.db-wal
|
||||
/chat_bot.db-shm
|
||||
|
|
@ -19,3 +17,4 @@ bili.cookie
|
|||
*.log
|
||||
.mp4
|
||||
/bili.cookie
|
||||
/src/configs/api_config.py
|
||||
|
|
|
|||
|
|
@ -1,15 +1,7 @@
|
|||
import os
|
||||
import openai
|
||||
import requests
|
||||
import yaml
|
||||
from src.my_sqlite.models.chat import GroupChatRole
|
||||
|
||||
with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8') as f:
|
||||
chat = yaml.load(f.read(), Loader=yaml.FullLoader).get('chat_ai')
|
||||
url = chat.get('v3url')
|
||||
key = chat.get('v3key')
|
||||
deepseek_url = chat.get('deepseek_url')
|
||||
deepseek_key = chat.get('deepseek_key')
|
||||
from src.configs.api_config import v3url, v3key, deepseek_url, deepseek_key
|
||||
|
||||
openai.api_key = deepseek_key
|
||||
openai.base_url = deepseek_url
|
||||
|
|
@ -21,7 +13,7 @@ async def v3_chat(group_openid,content):
|
|||
|
||||
await GroupChatRole.save_chat_history(group_openid, {"role": "user", "content": content})
|
||||
messages = await GroupChatRole.get_chat_history(group_openid)
|
||||
headers = {"Content-Type": "application/json", "Authorization": key}
|
||||
headers = {"Content-Type": "application/json", "Authorization": v3key}
|
||||
data = {
|
||||
"model": "gpt-3.5-turbo-0125",
|
||||
"messages": messages,
|
||||
|
|
@ -29,7 +21,7 @@ async def v3_chat(group_openid,content):
|
|||
"temperature": 0.5,
|
||||
"stream": False
|
||||
}
|
||||
response = requests.post(url, headers=headers, json=data)
|
||||
response = requests.post(v3url, headers=headers, json=data)
|
||||
reply_content = response.json().get('choices')[0].get('message').get('content')
|
||||
await GroupChatRole.save_chat_history(group_openid, {"role": "assistant", "content": reply_content})
|
||||
return reply_content
|
||||
|
|
@ -39,6 +31,12 @@ async def v3_chat(group_openid,content):
|
|||
来源:https://api.deepseek.com
|
||||
"""
|
||||
async def deepseek_chat(group_openid,content):
|
||||
"""
|
||||
ai 角色扮演聊天
|
||||
:param group_openid:
|
||||
:param content:
|
||||
:return:
|
||||
"""
|
||||
|
||||
await GroupChatRole.save_chat_history(group_openid, {"role": "user", "content": content})
|
||||
messages = await GroupChatRole.get_chat_history(group_openid)
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
chat_ai:
|
||||
admin_password: "<key>" # 设置管理员认证密码
|
||||
v3url: "<key>"
|
||||
v3key: "<key>"
|
||||
deepseek_url: "<key>"
|
||||
deepseek_key: "<key>"
|
||||
26
src/configs/api_config_example.py
Normal file
26
src/configs/api_config_example.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
app_id="<KEY>"
|
||||
bot_account= "<KEY>"
|
||||
|
||||
"""
|
||||
图床配置
|
||||
"""
|
||||
|
||||
# SMMS图床相关配置
|
||||
smms_token= "<KEY>" # sm.ms图床的token
|
||||
smms_image_upload_history= "https=//sm.ms/api/v2/upload_history" # sm.ms图床获取上传图片历史API地址
|
||||
|
||||
# 聚合图床相关配置
|
||||
ju_he_token= "<KEY>" # 聚合图床的token
|
||||
ju_he_image_list= "https=//api.superbed.cn/timeline" # 聚合图床获取上传图片历史API地址
|
||||
|
||||
"""
|
||||
AI
|
||||
"""
|
||||
admin_password= "123456"#默认注册管理员密码
|
||||
# 图灵机器人相关配置
|
||||
v3url= "https=//api.vveai.com/v1/chat/completions"
|
||||
v3key= "<KEY>"
|
||||
# DeepSeek相关配置
|
||||
deepseek_url= "https://api.deepseek.com"
|
||||
deepseek_key= "<KEY>"
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
image:
|
||||
app_id: "<KEY>"
|
||||
bot_account: "<KEY>"
|
||||
#SMMS图床相关配置
|
||||
smms_token: "<KEY>" # sm.ms图床的token
|
||||
smms_image_upload_history: "https://sm.ms/api/v2/upload_history" # sm.ms图床获取上传图片历史API地址
|
||||
#聚合图床相关配置
|
||||
ju_he_token: "<KEY>" # 聚合图床的token
|
||||
ju_he_image_list: "https://api.superbed.cn/timeline" # 聚合图床获取上传图片历史API地址
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,22 +1,11 @@
|
|||
import os
|
||||
import yaml
|
||||
import random
|
||||
import requests
|
||||
from PIL import Image, ImageDraw,ImageFont
|
||||
|
||||
from src.configs.path_config import image_local_path,image_local_qq_image_path,rua_png
|
||||
from src.configs.api_config import smms_token,smms_image_upload_history,ju_he_token,ju_he_image_list,app_id,bot_account
|
||||
|
||||
with open(os.getcwd() +'/src/image/config/image.yaml', 'r', encoding='utf-8') as f:
|
||||
image = yaml.load(f.read(), Loader=yaml.FullLoader).get('image')
|
||||
# image_local_path = image.get('image_local_path')
|
||||
# image_local_qq_image_path = image.get('image_local_qq_image_path')
|
||||
smms_token = image.get('smms_token')
|
||||
smms_image_upload_history = image.get('smms_image_upload_history')
|
||||
ju_he_token = image.get('ju_he_token')
|
||||
ju_he_image_list = image.get('ju_he_image_list')
|
||||
app_id = image.get('app_id')
|
||||
bot_account = image.get('bot_account')
|
||||
|
||||
# qq_image_save__path = os.getcwd()+'/'+image_local_qq_image_path
|
||||
|
||||
"""本地图片"""
|
||||
def get_image_names():
|
||||
|
|
|
|||
|
|
@ -1,19 +1,9 @@
|
|||
import re
|
||||
import os
|
||||
import yaml
|
||||
from nonebot.rule import to_me
|
||||
from nonebot.plugin import on_command
|
||||
from nonebot.adapters.qq import MessageEvent
|
||||
from src.my_sqlite.models.chat import ChatRole, GroupChatRole
|
||||
|
||||
with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8') as f1:
|
||||
chat = yaml.load(f1, Loader=yaml.FullLoader).get('chat_ai')
|
||||
admin_password = chat.get('admin_password')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
from src.configs.api_config import admin_password
|
||||
|
||||
|
||||
t1 = on_command("管理员注册", rule=to_me(), priority=10, block=True)
|
||||
|
|
|
|||
|
|
@ -14,11 +14,6 @@ import platform
|
|||
import psutil
|
||||
import time
|
||||
|
||||
with open(os.getcwd() + '/src/ai_chat/config/chat_ai.yaml', 'r', encoding='utf-8') as f1:
|
||||
chat = yaml.load(f1, Loader=yaml.FullLoader).get('chat_ai')
|
||||
admin_password = chat.get('admin_password')
|
||||
|
||||
|
||||
menu = ['/今日运势','/今日塔罗','/图','/点歌','/摸摸头','/群老婆','/今日老婆', "/开启ai","/关闭ai","/角色列表","/添加人设", "/更新人设", "/删除人设", "/切换人设", "/管理员注册",
|
||||
'/待办', '/test','/天气','我喜欢你', "❤", "/待办查询", "/新建待办", "/删除待办" ,"/cf","/B站搜索", "/BV搜索", "/喜报", "/悲报", "/奶龙", "/repo", "/info", "/menu"]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue