mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-02-07 02:46:10 +08:00
✨ 优化OpenAI请求参数,默认传入NotGiven
This commit is contained in:
parent
17f18fa56a
commit
b28e6921c5
@ -449,7 +449,11 @@ with contextlib.suppress(ImportError): # 优化先不做()
|
||||
client=client,
|
||||
model_name=model_name,
|
||||
msg=[
|
||||
get_prompt(),
|
||||
(
|
||||
get_prompt()
|
||||
if model_name.lower() not in NO_SYSPROMPT_MODELS
|
||||
else None
|
||||
),
|
||||
UserMessage(
|
||||
content=f"*{user_nickname}{config.marshoai_poke_suffix}"
|
||||
),
|
||||
|
@ -14,7 +14,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 openai import AsyncOpenAI, NotGiven
|
||||
from zhDateTime import DateTime
|
||||
|
||||
from .config import config
|
||||
@ -25,6 +25,8 @@ nickname_json = None # 记录昵称
|
||||
praises_json = None # 记录夸赞名单
|
||||
loaded_target_list = [] # 记录已恢复备份的上下文的列表
|
||||
|
||||
NOT_GIVEN = NotGiven()
|
||||
|
||||
# 时间参数相关
|
||||
if config.marshoai_enable_time_prompt:
|
||||
_weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
|
||||
@ -141,13 +143,13 @@ async def make_chat_openai(
|
||||
model_name: 指定AI模型名
|
||||
tools: 工具列表
|
||||
"""
|
||||
return await client.chat.completions.create(
|
||||
return await client.chat.completions.create( # type: ignore
|
||||
messages=msg,
|
||||
model=model_name,
|
||||
tools=tools,
|
||||
temperature=config.marshoai_temperature,
|
||||
max_tokens=config.marshoai_max_tokens,
|
||||
top_p=config.marshoai_top_p,
|
||||
tools=tools or NOT_GIVEN,
|
||||
temperature=config.marshoai_temperature or NOT_GIVEN,
|
||||
max_tokens=config.marshoai_max_tokens or NOT_GIVEN,
|
||||
top_p=config.marshoai_top_p or NOT_GIVEN,
|
||||
timeout=config.marshoai_timeout,
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user