refactor: 修改模型检查逻辑以提高代码可读性

This commit is contained in:
yinpeng
2025-01-22 14:29:07 +08:00
parent 6ee3b485a4
commit 97e601a176
3 changed files with 154 additions and 120 deletions
+2 -1
View File
@@ -63,6 +63,7 @@ class OpenAIChatService:
while retries < max_retries:
try:
async for line in self.api_client.stream_generate_content(payload, model, api_key):
# print(line)
if line.startswith("data:"):
chunk = json.loads(line[6:])
openai_chunk = self.response_handler.handle_response(
@@ -127,7 +128,7 @@ class OpenAIChatService:
def _get_safety_settings(self, model: str) -> List[Dict[str, str]]:
"""获取安全设置"""
if "2.0" in model and model != "gemini-2.0-flash-thinking-exp":
if "2.0" in model and "gemini-2.0-flash-thinking-exp" not in model:
return [
{"category": "HARM_CATEGORY_HARASSMENT", "threshold": "OFF"},
{"category": "HARM_CATEGORY_HATE_SPEECH", "threshold": "OFF"},