add new gemini model
Browse filesFiles changed (3)
98 unmodified lines9910010110210210310410510610710810991 unmodified lines201202203203204205206207644 unmodified lines8528538548548558568578588598608618628638648658668678688698708717 unmodified lines8798808818828838848851 unmodified line88788888987589089189289389489589689789889998 unmodified lines
# Define models and languages here to avoid importing Gradio UIAVAILABLE_MODELS = [ {"name": "Devstral Medium 2512", "id": "devstral-medium-2512", "description": "Mistral Devstral 2512 - Expert code generation model via OpenRouter (Default)", "supports_images": False}, {"name": "Devstral Medium 2512", "id": "devstral-medium-2512", "description": "Mistral Devstral 2512 - Expert code generation model via OpenRouter", "supports_images": False}, {"name": "GLM-4.6V 👁️", "id": "zai-org/GLM-4.6V:zai-org", "description": "GLM-4.6V vision model - supports image uploads for visual understanding", "supports_images": True}, {"name": "DeepSeek V3.2", "id": "deepseek-ai/DeepSeek-V3.2-Exp", "description": "DeepSeek V3.2 Experimental - Fast model for code generation via HuggingFace Router with Novita provider", "supports_images": False}, {"name": "DeepSeek R1", "id": "deepseek-ai/DeepSeek-R1-0528", "description": "DeepSeek R1 model for code generation", "supports_images": False}, {"name": "Gemini 3.0 Flash Preview", "id": "gemini-3-flash-preview", "description": "Google Gemini 3.0 Flash Preview with Thinking Mode (High) (Default)", "supports_images": False}, {"name": "Gemini 3.0 Pro", "id": "gemini-3.0-pro", "description": "Google Gemini 3.0 Pro via Poe with advanced reasoning", "supports_images": False}, {"name": "Grok 4.1 Fast", "id": "x-ai/grok-4.1-fast", "description": "Grok 4.1 Fast model via OpenRouter (20 req/min on free tier)", "supports_images": False}, {"name": "MiniMax M2", "id": "MiniMaxAI/MiniMax-M2", "description": "MiniMax M2 model via HuggingFace InferenceClient with Novita provider", "supports_images": False},91 unmodified linesclass CodeGenerationRequest(BaseModel): query: str language: str = "html" model_id: str = "devstral-medium-2512" model_id: str = "gemini-3-flash-preview" provider: str = "auto" history: List[List[str]] = [] agent_mode: bool = False644 unmodified lines messages=messages, max_tokens=10000 )
# Handle Native SDK models (Gemini 3) elif is_native_sdk_model(selected_model_id): print(f"[Generate] Using Native SDK (Gemini) for {selected_model_id}") if selected_model_id == "gemini-3-flash-preview": contents, config = create_gemini3_messages(messages) stream = client.models.generate_content_stream( model=selected_model_id, contents=contents, config=config ) else: raise ValueError(f"Unknown native SDK model: {selected_model_id}") # All other models use OpenAI-compatible API else:7 unmodified lines chunk_count = 0 is_mistral = is_mistral_model(selected_model_id) is_native = is_native_sdk_model(selected_model_id) # Only process stream if it exists (not None for Conversations API) if stream:1 unmodified line for chunk in stream: chunk_content = None if is_mistral: if is_native: # Native SDK format (Gemini) try: chunk_content = chunk.text except (AttributeError, ValueError): continue elif is_mistral: # Mistral format: chunk.data.choices[0].delta.content try: if chunk.data and chunk.data.choices and chunk.data.choices[0].delta.content:246 unmodified lines24724824925025125225325425525625725873 unmodified lines3323333343293353363373383 unmodified lines342343344339345346347348246 unmodified lines base_url=base_url, ) elif model_id == "gemini-3-flash-preview": # Use native Google GenAI client for Gemini 3.0 Flash Preview if not GEMINI_AVAILABLE: raise ImportError("google-genai package required for Gemini 3") return genai.Client(api_key=os.getenv("GEMINI_API_KEY"))
else: # Unknown model - try HuggingFace Inference API return OpenAI(73 unmodified lines # Configure tools and thinking tools = [types.Tool(googleSearch=types.GoogleSearch())] config = types.GenerateContentConfig( thinkingConfig=types.ThinkingConfig(thinkingLevel="HIGH"), thinking_config=types.ThinkingConfig(thinking_level="HIGH"), tools=tools, max_output_tokens=16384 )3 unmodified lines
def is_native_sdk_model(model_id: str) -> bool: """Check if model uses native SDK (not OpenAI-compatible)""" return False # All models now use OpenAI-compatible APIs return model_id == "gemini-3-flash-preview"
def is_mistral_model(model_id: str) -> bool:30 unmodified lines313233343435363730 unmodified lines onImport, isAuthenticated, initialLanguage = 'html', initialModel = 'devstral-medium-2512', initialModel = 'gemini-3-flash-preview', onAuthChange, setPendingPR, pendingPRRefbackend_api.py+25-4
backend_models.py+8-2
frontend/src/components/LandingPage.tsx+1-1