update: xai增加max_tokens,max_words等参数
This commit is contained in:
@@ -222,7 +222,7 @@ class AiBotPlugin(AbsExtraConfigPlugin):
|
|||||||
self.config.cur_model = self.config['platforms'][argus.split("#")[0]]['model']
|
self.config.cur_model = self.config['platforms'][argus.split("#")[0]]['model']
|
||||||
await event.react("✅")
|
await event.react("✅")
|
||||||
# 如果是openai或者是claude
|
# 如果是openai或者是claude
|
||||||
elif argus == 'openai' or argus == 'anthropic':
|
elif argus == 'openai' or argus == 'anthropic' or argus == 'xai':
|
||||||
if argus == self.config.cur_platform:
|
if argus == self.config.cur_platform:
|
||||||
await event.reply(f"current ai platform has be {argus}")
|
await event.reply(f"current ai platform has be {argus}")
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ async def get_system_context(plugin: AbsExtraConfigPlugin, platform: Platform, e
|
|||||||
"""
|
"""
|
||||||
获取聊天信息上下文
|
获取聊天信息上下文
|
||||||
"""
|
"""
|
||||||
async def get_chat_context(system_context: deque, plugin: AbsExtraConfigPlugin, platform: Platform, evt: MessageEvent) -> deque:
|
async def get_chat_context(system_context: deque, plugin: AbsExtraConfigPlugin, platform: Platform, evt: MessageEvent, hasAssistant: bool=True) -> deque:
|
||||||
# 用户历史聊天上下文
|
# 用户历史聊天上下文
|
||||||
chat_context = deque()
|
chat_context = deque()
|
||||||
# 计算系统提示词单词数
|
# 计算系统提示词单词数
|
||||||
@@ -111,8 +111,16 @@ async def get_chat_context(system_context: deque, plugin: AbsExtraConfigPlugin,
|
|||||||
except (KeyError, AttributeError):
|
except (KeyError, AttributeError):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# 如果当前的这条历史消息是机器人自己的,那么角色就要设置为assistant
|
# 如果没有assistant的角色,那么如果当前的对话消息是机器人的,忽略不要
|
||||||
|
if not hasAssistant:
|
||||||
|
if plugin.client.mxid == next_event.sender:
|
||||||
|
continue
|
||||||
|
else :
|
||||||
|
role = 'user'
|
||||||
|
else :
|
||||||
role = 'assistant' if plugin.client.mxid == next_event.sender else 'user'
|
role = 'assistant' if plugin.client.mxid == next_event.sender else 'user'
|
||||||
|
|
||||||
|
# 如果当前的这条历史消息是机器人自己的,那么角色就要设置为assistant
|
||||||
message = next_event['content']['body']
|
message = next_event['content']['body']
|
||||||
user = ''
|
user = ''
|
||||||
# 如果是允许多用户使用,那么就需要在每个历史消息前加上用户名
|
# 如果是允许多用户使用,那么就需要在每个历史消息前加上用户名
|
||||||
|
|||||||
Reference in New Issue
Block a user