mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-08-01 07:09:50 +00:00
✨ 更新实例和工具模块,更换为OpenAI异步客户端进行聊天请求
This commit is contained in:
@ -16,6 +16,7 @@ from nonebot.log import logger
|
||||
from nonebot_plugin_alconna import Image as ImageMsg
|
||||
from nonebot_plugin_alconna import Text as TextMsg
|
||||
from nonebot_plugin_alconna import UniMessage
|
||||
from openai import AsyncOpenAI
|
||||
|
||||
from .config import config
|
||||
from .constants import *
|
||||
@ -102,6 +103,29 @@ async def make_chat(
|
||||
)
|
||||
|
||||
|
||||
async def make_chat_openai(
|
||||
client: AsyncOpenAI,
|
||||
msg: list,
|
||||
model_name: str,
|
||||
tools: Optional[list] = None,
|
||||
):
|
||||
"""使用 Openai SDK 调用ai获取回复
|
||||
|
||||
参数:
|
||||
client: 用于与AI模型进行通信
|
||||
msg: 消息内容
|
||||
model_name: 指定AI模型名
|
||||
tools: 工具列表"""
|
||||
return await client.chat.completions.create(
|
||||
messages=msg,
|
||||
model=model_name,
|
||||
tools=tools,
|
||||
temperature=config.marshoai_temperature,
|
||||
max_tokens=config.marshoai_max_tokens,
|
||||
top_p=config.marshoai_top_p,
|
||||
)
|
||||
|
||||
|
||||
def get_praises():
|
||||
global praises_json
|
||||
if praises_json is None:
|
||||
|
Reference in New Issue
Block a user