mirror of https://github.com/Mai-with-u/MaiBot.git
Merge branch 'debug' of https://github.com/SengokuCola/MaiMBot into debug
commit
71193c4d28
|
|
@ -0,0 +1,26 @@
|
||||||
|
# 您不应该修改默认值,这个文件被仓库索引,请修改.env.prod
|
||||||
|
ENVIRONMENT=prod
|
||||||
|
HOST=127.0.0.1
|
||||||
|
PORT=8080
|
||||||
|
|
||||||
|
COMMAND_START=["/"]
|
||||||
|
|
||||||
|
# 插件配置
|
||||||
|
PLUGINS=["src2.plugins.chat"]
|
||||||
|
|
||||||
|
# 默认配置
|
||||||
|
MONGODB_HOST=127.0.0.1
|
||||||
|
MONGODB_PORT=27017
|
||||||
|
DATABASE_NAME=MegBot
|
||||||
|
|
||||||
|
MONGODB_USERNAME = "" # 默认空值
|
||||||
|
MONGODB_PASSWORD = "" # 默认空值
|
||||||
|
MONGODB_AUTH_SOURCE = "" # 默认空值
|
||||||
|
|
||||||
|
#key and url
|
||||||
|
CHAT_ANY_WHERE_KEY=
|
||||||
|
SILICONFLOW_KEY=
|
||||||
|
CHAT_ANY_WHERE_BASE_URL=https://api.chatanywhere.tech/v1
|
||||||
|
SILICONFLOW_BASE_URL=https://api.siliconflow.cn/v1/
|
||||||
|
DEEP_SEEK_KEY=
|
||||||
|
DEEP_SEEK_BASE_URL=https://api.deepseek.com/v1
|
||||||
|
|
@ -14,7 +14,7 @@ reasoning_content.bat
|
||||||
reasoning_window.bat
|
reasoning_window.bat
|
||||||
queue_update.txt
|
queue_update.txt
|
||||||
memory_graph.gml
|
memory_graph.gml
|
||||||
.env.dev
|
.env.*
|
||||||
|
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
|
|
@ -147,7 +147,6 @@ celerybeat.pid
|
||||||
*.sage.py
|
*.sage.py
|
||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env
|
|
||||||
.venv
|
.venv
|
||||||
env/
|
env/
|
||||||
venv/
|
venv/
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@ FROM nonebot/nb-cli:latest
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
COPY . /MaiMBot/
|
COPY . /MaiMBot/
|
||||||
WORKDIR /MaiMBot
|
WORKDIR /MaiMBot
|
||||||
RUN mv config/env.example config/.env \
|
RUN mv config/bot_config_toml config/bot_config.toml
|
||||||
&& mv config/bot_config_toml config/bot_config.toml
|
|
||||||
RUN pip install --upgrade -r requirements.txt
|
RUN pip install --upgrade -r requirements.txt
|
||||||
VOLUME [ "/MaiMBot/config" ]
|
VOLUME [ "/MaiMBot/config" ]
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ services:
|
||||||
- mongodb:/data/db
|
- mongodb:/data/db
|
||||||
- mongodbCONFIG:/data/configdb
|
- mongodbCONFIG:/data/configdb
|
||||||
image: mongo:latest
|
image: mongo:latest
|
||||||
|
|
||||||
maimbot:
|
maimbot:
|
||||||
container_name: maimbot
|
container_name: maimbot
|
||||||
environment:
|
environment:
|
||||||
|
|
@ -41,8 +41,8 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- maimbotCONFIG:/MaiMBot/config
|
- maimbotCONFIG:/MaiMBot/config
|
||||||
- maimbotDATA:/MaiMBot/data
|
- maimbotDATA:/MaiMBot/data
|
||||||
|
- ./.env.prod:/MaiMBot/.env.prod
|
||||||
image: sengokucola/maimbot:latest
|
image: sengokucola/maimbot:latest
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
maimbotCONFIG:
|
maimbotCONFIG:
|
||||||
|
|
@ -51,4 +51,5 @@ volumes:
|
||||||
napcatCONFIG:
|
napcatCONFIG:
|
||||||
mongodb:
|
mongodb:
|
||||||
mongodbCONFIG:
|
mongodbCONFIG:
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
|
|
@ -20,7 +20,7 @@ class LLMModel:
|
||||||
self.model_name = model_name
|
self.model_name = model_name
|
||||||
self.params = kwargs
|
self.params = kwargs
|
||||||
|
|
||||||
async def generate_response(self, prompt: str) -> Tuple[str, str]:
|
def generate_response(self, prompt: str) -> Tuple[str, str]:
|
||||||
"""根据输入的提示生成模型的响应"""
|
"""根据输入的提示生成模型的响应"""
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {self.api_key}",
|
"Authorization": f"Bearer {self.api_key}",
|
||||||
|
|
@ -39,17 +39,16 @@ class LLMModel:
|
||||||
api_url = f"{self.base_url.rstrip('/')}/chat/completions"
|
api_url = f"{self.base_url.rstrip('/')}/chat/completions"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
response = requests.post(api_url, headers=headers, json=data)
|
||||||
async with session.post(api_url, headers=headers, json=data) as response:
|
response.raise_for_status() # 检查响应状态
|
||||||
response.raise_for_status() # 检查响应状态
|
|
||||||
|
result = response.json()
|
||||||
result = await response.json()
|
if "choices" in result and len(result["choices"]) > 0:
|
||||||
if "choices" in result and len(result["choices"]) > 0:
|
content = result["choices"][0]["message"]["content"]
|
||||||
content = result["choices"][0]["message"]["content"]
|
reasoning_content = result["choices"][0]["message"].get("reasoning_content", "")
|
||||||
reasoning_content = result["choices"][0]["message"].get("reasoning_content", "")
|
return content, reasoning_content # 返回内容和推理内容
|
||||||
return content, reasoning_content # 返回内容和推理内容
|
return "没有返回结果", "" # 返回两个值
|
||||||
return "没有返回结果", "" # 返回两个值
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"请求失败: {str(e)}", "" # 返回错误信息和空字符串
|
return f"请求失败: {str(e)}", "" # 返回错误信息和空字符串
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue