Commit 313df71

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-05-17 15:41:42
fix(gpt): fix sdk detection for Gemini models
1 parent 6a78701
Changed files (2)
src/llm/gpt.py
@@ -111,7 +111,7 @@ async def gpt_response(client: Client, message: Message, *, gpt_stream: bool = T
     if not config["completions"]["model"].strip():
         return await send2tg(client, message, texts=f"⚠️**{config['friendly_name']}** 未配置模型ID, 请尝试其他命令\n\n{HELP}", **kwargs)
 
-    config["completions"]["messages"] = await get_conversation_contexts(client, conversations, ctx_format=sdk)
+    config["completions"]["messages"] = await get_conversation_contexts(client, conversations, ctx_format="openai")
     msg = f"🤖**{config['friendly_name']}**: 思考中...\n👤**[{info['full_name'] or info['ctitle']}](tg://user?id={info['uid']})**: “{clean_cmd_prefix(info['text'])}”"
     status_msg = (await send2tg(client, message, texts=msg, **kwargs))[0]
     kwargs["progress"] = status_msg
src/llm/models.py
@@ -93,10 +93,12 @@ def get_model_id(text: str, reply_text: str, context_type: str) -> tuple[str, st
     if model_id and (model_id == GEMINI.IMG_MODEL or reply_text.startswith(f"🤖{GEMINI.IMG_MODEL_NAME}")):
         response_modality = "image"
         sdk = "gemini"
-    else:
+    elif "gemini" in model_id:
         response_modality = "text"
         sdk = GPT.GEMINI_SDK
-
+    else:
+        response_modality = "text"
+        sdk = "openai"
     if model_id and context_type == "text":  # no need to fallback if context type is text
         return model_id, response_modality, sdk
     if (