瀏覽代碼

fix: set correct top_p params of ali qwen model

master
Han Fangyuan 11 月之前
父節點
當前提交
c8910b8e14
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. +4
    -2
      bot/tongyi/tongyi_qwen_bot.py

+ 4
- 2
bot/tongyi/tongyi_qwen_bot.py 查看文件

@@ -103,8 +103,8 @@ class TongyiQwenBot(Bot):
try: try:
prompt, history = self.convert_messages_format(session.messages) prompt, history = self.convert_messages_format(session.messages)
self.update_api_key_if_expired() self.update_api_key_if_expired()
# NOTE 阿里百炼的call()函数参数比较奇怪, top_k参数表示top_p, top_p参数表示temperature, 可以参考文档 https://help.aliyun.com/document_detail/2587502.htm
response = broadscope_bailian.Completions().call(app_id=self.app_id(), prompt=prompt, history=history, top_k=self.top_p(), top_p=self.temperature())
# NOTE 阿里百炼的call()函数未提供temperature参数,考虑到temperature和top_p参数作用相同,取两者较小的值作为top_p参数传入,详情见文档 https://help.aliyun.com/document_detail/2587502.htm
response = broadscope_bailian.Completions().call(app_id=self.app_id(), prompt=prompt, history=history, top_p=min(self.temperature(), self.top_p()))
completion_content = self.get_completion_content(response, self.node_id()) completion_content = self.get_completion_content(response, self.node_id())
completion_tokens, total_tokens = self.calc_tokens(session.messages, completion_content) completion_tokens, total_tokens = self.calc_tokens(session.messages, completion_content)
return { return {
@@ -181,6 +181,8 @@ class TongyiQwenBot(Bot):
return user_content, history return user_content, history


def get_completion_content(self, response, node_id): def get_completion_content(self, response, node_id):
if not response['Success']:
return f"[ERROR]\n{response['Code']}:{response['Message']}"
text = response['Data']['Text'] text = response['Data']['Text']
if node_id == '': if node_id == '':
return text return text


Loading…
取消
儲存