fix(gemini): 调整 safetySettings 参数至 API 请求的正确层级
根据 Gemini API 的官方文档,`safetySettings` 参数应位于请求体的顶层,而非 `generationConfig` 内部。 本次提交将该参数移动到了正确的位置,以确保安全策略能够正确生效。
This commit is contained in:
@@ -186,7 +186,6 @@ def _build_generation_config(
|
|||||||
"temperature": temperature,
|
"temperature": temperature,
|
||||||
"topK": 1,
|
"topK": 1,
|
||||||
"topP": 1,
|
"topP": 1,
|
||||||
"safetySettings": gemini_safe_settings,
|
|
||||||
"thinkingConfig": {"includeThoughts": True, "thinkingBudget": thinking_budget},
|
"thinkingConfig": {"includeThoughts": True, "thinkingBudget": thinking_budget},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -589,6 +588,7 @@ class AiohttpGeminiClient(BaseClient):
|
|||||||
request_data = {
|
request_data = {
|
||||||
"contents": contents,
|
"contents": contents,
|
||||||
"generationConfig": _build_generation_config(max_tokens, temperature, tb, response_format, extra_params),
|
"generationConfig": _build_generation_config(max_tokens, temperature, tb, response_format, extra_params),
|
||||||
|
"safetySettings": gemini_safe_settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
# 添加系统指令
|
# 添加系统指令
|
||||||
@@ -701,6 +701,7 @@ class AiohttpGeminiClient(BaseClient):
|
|||||||
request_data = {
|
request_data = {
|
||||||
"contents": contents,
|
"contents": contents,
|
||||||
"generationConfig": _build_generation_config(2048, 0.1, THINKING_BUDGET_AUTO, None, extra_params),
|
"generationConfig": _build_generation_config(2048, 0.1, THINKING_BUDGET_AUTO, None, extra_params),
|
||||||
|
"safetySettings": gemini_safe_settings,
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user