File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121
2222from ..utils .model_name_utils import is_gemini_1_model
2323from ..utils .model_name_utils import is_gemini_2_or_above
24+ from ..utils .model_name_utils import is_gemini_eap_model
2425from ..utils .model_name_utils import is_gemini_model_id_check_disabled
2526from .base_tool import BaseTool
2627from .tool_context import ToolContext
@@ -52,7 +53,11 @@ async def process_llm_request(
5253 llm_request .config .tools = llm_request .config .tools or []
5354 if is_gemini_1_model (llm_request .model ):
5455 raise ValueError ('Url context tool cannot be used in Gemini 1.x.' )
55- elif is_gemini_2_or_above (llm_request .model ) or model_check_disabled :
56+ elif (
57+ is_gemini_2_or_above (llm_request .model )
58+ or is_gemini_eap_model (llm_request .model )
59+ or model_check_disabled
60+ ):
5661 llm_request .config .tools .append (
5762 types .Tool (url_context = types .UrlContext ())
5863 )
Original file line number Diff line number Diff line change @@ -127,6 +127,31 @@ def is_gemini_2_or_above(model_string: Optional[str]) -> bool:
127127 return parsed_version .major >= 2
128128
129129
130+ def is_gemini_eap_model (model_string : Optional [str ]) -> bool :
131+ """Check if the model is an Early Access Program (EAP) Gemini model.
132+
133+ Matches names of the form ``gemini-<variant>-early-exp`` optionally
134+ followed by a numeric suffix, e.g. ``gemini-flash-early-exp`` or
135+ ``gemini-flash-early-exp3``. ``<variant>`` is one or more
136+ alphanumeric/underscore segments separated by ``-`` (e.g. ``flash``,
137+ ``pro``, ``flash-lite``).
138+
139+ Args:
140+ model_string: Either a simple model name or path-based model name.
141+
142+ Returns:
143+ True if it matches the EAP naming convention, False otherwise.
144+ """
145+ if not model_string :
146+ return False
147+
148+ model_name = extract_model_name (model_string )
149+ return (
150+ re .match (r'^gemini-[a-z0-9_]+(?:-[a-z0-9_]+)*-early-exp\d*$' , model_name )
151+ is not None
152+ )
153+
154+
130155def is_gemini_3_1_flash_live (model_string : Optional [str ]) -> bool :
131156 """Check if the model is a Gemini 3.1 Flash Live model.
132157
You can’t perform that action at this time.
0 commit comments