mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-05 07:02:13 +08:00
feat: add Google AI Studio API support with platform-based detection (#502)
* feat: add Google AI Studio API support with platform-based detection * chore: update configuration_guide.md * fix the uv.lock formate error --------- Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
@@ -8,7 +8,9 @@ from typing import Any, Dict, get_args
|
||||
import httpx
|
||||
from langchain_core.language_models import BaseChatModel
|
||||
from langchain_deepseek import ChatDeepSeek
|
||||
from langchain_google_genai import ChatGoogleGenerativeAI
|
||||
from langchain_openai import AzureChatOpenAI, ChatOpenAI
|
||||
from typing import get_args
|
||||
|
||||
from src.config import load_yaml_config
|
||||
from src.config.agents import LLMType
|
||||
@@ -83,6 +85,28 @@ def _create_llm_use_conf(llm_type: LLMType, conf: Dict[str, Any]) -> BaseChatMod
|
||||
merged_conf["http_client"] = http_client
|
||||
merged_conf["http_async_client"] = http_async_client
|
||||
|
||||
# Check if it's Google AI Studio platform based on configuration
|
||||
platform = merged_conf.get("platform", "").lower()
|
||||
is_google_aistudio = platform == "google_aistudio" or platform == "google-aistudio"
|
||||
|
||||
if is_google_aistudio:
|
||||
# Handle Google AI Studio specific configuration
|
||||
gemini_conf = merged_conf.copy()
|
||||
|
||||
# Map common keys to Google AI Studio specific keys
|
||||
if "api_key" in gemini_conf:
|
||||
gemini_conf["google_api_key"] = gemini_conf.pop("api_key")
|
||||
|
||||
# Remove base_url and platform since Google AI Studio doesn't use them
|
||||
gemini_conf.pop("base_url", None)
|
||||
gemini_conf.pop("platform", None)
|
||||
|
||||
# Remove unsupported parameters for Google AI Studio
|
||||
gemini_conf.pop("http_client", None)
|
||||
gemini_conf.pop("http_async_client", None)
|
||||
|
||||
return ChatGoogleGenerativeAI(**gemini_conf)
|
||||
|
||||
if "azure_endpoint" in merged_conf or os.getenv("AZURE_OPENAI_ENDPOINT"):
|
||||
return AzureChatOpenAI(**merged_conf)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user