add new gemini model
Browse filesFiles changed (3)
98 unmodified lines9910010110210310410510610710891 unmodified lines200201202203204205206644 unmodified lines8518528538548558568577 unmodified lines8658668678688698701 unmodified line87287387487587687787898 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": "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 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: strlanguage: str = "html"model_id: str = "devstral-medium-2512"provider: str = "auto"history: List[List[str]] = []agent_mode: bool = False644 unmodified linesmessages=messages,max_tokens=10000)# All other models use OpenAI-compatible APIelse:7 unmodified lineschunk_count = 0is_mistral = is_mistral_model(selected_model_id)# Only process stream if it exists (not None for Conversations API)if stream:1 unmodified linefor chunk in stream:chunk_content = Noneif is_mistral:# Mistral format: chunk.data.choices[0].delta.contenttry:if chunk.data and chunk.data.choices and chunk.data.choices[0].delta.content:98 unmodified lines9910010110210310410510610710810991 unmodified lines201202203204205206207644 unmodified lines8528538548558568578588598608618628638648658668678688698708717 unmodified lines8798808818828838848851 unmodified line88788888989089189289389489589689789889998 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", "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: strlanguage: str = "html"model_id: str = "gemini-3-flash-preview"provider: str = "auto"history: List[List[str]] = []agent_mode: bool = False644 unmodified linesmessages=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 APIelse:7 unmodified lineschunk_count = 0is_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 linefor chunk in stream:chunk_content = Noneif is_native:# Native SDK format (Gemini)try:chunk_content = chunk.textexcept (AttributeError, ValueError):continueelif is_mistral:# Mistral format: chunk.data.choices[0].delta.contenttry:if chunk.data and chunk.data.choices and chunk.data.choices[0].delta.content:
246 unmodified lines24724824925025125273 unmodified lines3263273283293303313323 unmodified lines336337338339340341342246 unmodified linesbase_url=base_url,)else:# Unknown model - try HuggingFace Inference APIreturn OpenAI(73 unmodified lines# Configure tools and thinkingtools = [types.Tool(googleSearch=types.GoogleSearch())]config = types.GenerateContentConfig(thinkingConfig=types.ThinkingConfig(thinkingLevel="HIGH"),tools=tools,max_output_tokens=16384)3 unmodified linesdef 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 APIsdef is_mistral_model(model_id: str) -> bool:246 unmodified lines24724824925025125225325425525625725873 unmodified lines3323333343353363373383 unmodified lines342343344345346347348246 unmodified linesbase_url=base_url,)elif model_id == "gemini-3-flash-preview":# Use native Google GenAI client for Gemini 3.0 Flash Previewif 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 APIreturn OpenAI(73 unmodified lines# Configure tools and thinkingtools = [types.Tool(googleSearch=types.GoogleSearch())]config = types.GenerateContentConfig(thinking_config=types.ThinkingConfig(thinking_level="HIGH"),tools=tools,max_output_tokens=16384)3 unmodified linesdef is_native_sdk_model(model_id: str) -> bool:"""Check if model uses native SDK (not OpenAI-compatible)"""return model_id == "gemini-3-flash-preview"def is_mistral_model(model_id: str) -> bool:
30 unmodified lines3132333435363730 unmodified linesonImport,isAuthenticated,initialLanguage = 'html',initialModel = 'devstral-medium-2512',onAuthChange,setPendingPR,pendingPRRef30 unmodified lines3132333435363730 unmodified linesonImport,isAuthenticated,initialLanguage = 'html',initialModel = 'gemini-3-flash-preview',onAuthChange,setPendingPR,pendingPRRef
backend_api.py+25-4
backend_models.py+8-2
frontend/src/components/LandingPage.tsx+1-1