Skip to content

Commit

Permalink
修复Gemini对话错误问题(停用词数量为0的情况) (#2092)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxflzj authored Dec 28, 2024
1 parent 09a82a5 commit fd93622
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions request_llms/com_google.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,29 @@ def generate_message_payload(
) # 处理 history

messages.append(self.__conversation_user(inputs, llm_kwargs, enable_multimodal_capacity)) # 处理用户对话
payload = {
"contents": messages,
"generationConfig": {
# "maxOutputTokens": llm_kwargs.get("max_token", 1024),
"stopSequences": str(llm_kwargs.get("stop", "")).split(" "),
"temperature": llm_kwargs.get("temperature", 1),
"topP": llm_kwargs.get("top_p", 0.8),
"topK": 10,
},
}
stop_sequences = str(llm_kwargs.get("stop", "")).split(" ")
# 过滤空字符串并确保至少有一个停止序列
stop_sequences = [s for s in stop_sequences if s]
if not stop_sequences:
payload = {
"contents": messages,
"generationConfig": {
"temperature": llm_kwargs.get("temperature", 1),
"topP": llm_kwargs.get("top_p", 0.8),
"topK": 10,
},
}
else:
payload = {
"contents": messages,
"generationConfig": {
# "maxOutputTokens": llm_kwargs.get("max_token", 1024),
"stopSequences": stop_sequences,
"temperature": llm_kwargs.get("temperature", 1),
"topP": llm_kwargs.get("top_p", 0.8),
"topK": 10,
},
}

return header, payload

Expand Down

0 comments on commit fd93622

Please sign in to comment.