diff --git a/.env.local.example b/.env.local.example index 1934b0c0..e52eec0c 100644 --- a/.env.local.example +++ b/.env.local.example @@ -17,7 +17,7 @@ NEXT_PUBLIC_COMPOSIO_USER_ID=user@example.com # NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=your_mapbox_public_token_here # AI Provider API Keys -# Gemini 3 Pro (Google Generative AI) +# Gemini 3.1 Pro (Google Generative AI) GEMINI_3_PRO_API_KEY=your_gemini_3_pro_api_key_here # Supabase Credentials diff --git a/GEMINI_3_PRO_INTEGRATION.md b/GEMINI_3.1_PRO_INTEGRATION.md similarity index 65% rename from GEMINI_3_PRO_INTEGRATION.md rename to GEMINI_3.1_PRO_INTEGRATION.md index 994fc8f3..08f51ab4 100644 --- a/GEMINI_3_PRO_INTEGRATION.md +++ b/GEMINI_3.1_PRO_INTEGRATION.md @@ -1,25 +1,26 @@ -# Gemini 3 Pro Integration +# Gemini 3.1 Pro Integration ## Overview -This document describes the integration of Google's Gemini 3 Pro model into the QCX application. Gemini 3 Pro is Google's most advanced reasoning model with state-of-the-art capabilities for multimodal understanding, coding, and agentic tasks. +This document describes the integration of Google's Gemini 3.1 Pro model into the QCX application. Gemini 3.1 Pro is Google's most advanced reasoning model with state-of-the-art capabilities for multimodal understanding, coding, and agentic tasks. ## Changes Made ### 1. Updated `lib/utils/index.ts` -Added Gemini 3 Pro as a provider option in the `getModel()` function with the following priority order: +Added Gemini 3.1 Pro as a provider option in the `getModel()` function with the following priority order: -1. **xAI (Grok)** - Primary choice if `XAI_API_KEY` is configured -2. **Gemini 3 Pro** - Secondary choice if `GEMINI_3_PRO_API_KEY` is configured *(NEW)* +1. **Gemini 3.1 Pro** - Primary choice if `GEMINI_3_PRO_API_KEY` is configured *(UPDATED PRIORITY)* +2. **xAI (Grok)** - Secondary choice if `XAI_API_KEY` is configured 3. **AWS Bedrock** - Tertiary choice if AWS credentials are configured 4. **OpenAI** - Default fallback if `OPENAI_API_KEY` is configured The implementation includes: - Environment variable check for `GEMINI_3_PRO_API_KEY` - Creation of Google Generative AI client using `createGoogleGenerativeAI()` -- Model identifier: `gemini-3-pro-preview` +- Model identifier: `gemini-3.1-pro-preview` - Error handling with fallback to the next available provider +- Support for both "Gemini 3" and "Gemini 3.1 Pro" selection identifiers for backward compatibility. ### 2. Updated `.env.local.example` @@ -27,13 +28,13 @@ Added documentation for the new environment variable: ```bash # AI Provider API Keys -# Gemini 3 Pro (Google Generative AI) +# Gemini 3.1 Pro (Google Generative AI) GEMINI_3_PRO_API_KEY="your_gemini_3_pro_api_key_here" ``` ## Configuration -To use Gemini 3 Pro in your QCX deployment: +To use Gemini 3.1 Pro in your QCX deployment: 1. Obtain a Google AI API key from [Google AI Studio](https://aistudio.google.com/) 2. Add the API key to your `.env.local` file: @@ -44,7 +45,7 @@ To use Gemini 3 Pro in your QCX deployment: ## Model Capabilities -Gemini 3 Pro (`gemini-3-pro-preview`) supports: +Gemini 3.1 Pro (`gemini-3.1-pro-preview`) supports: - **Advanced Reasoning**: State-of-the-art reasoning capabilities with optional thinking modes - **Multimodal Understanding**: Text, image, and file inputs @@ -58,9 +59,9 @@ Gemini 3 Pro (`gemini-3-pro-preview`) supports: The provider selection follows this priority order: ``` -XAI_API_KEY exists? → Use Grok +GEMINI_3_PRO_API_KEY exists? → Use Gemini 3.1 Pro ↓ No -GEMINI_3_PRO_API_KEY exists? → Use Gemini 3 Pro +XAI_API_KEY exists? → Use Grok ↓ No AWS credentials exist? → Use AWS Bedrock ↓ No @@ -70,12 +71,12 @@ OPENAI_API_KEY exists? → Use OpenAI (default) ## Technical Details - **SDK Package**: `@ai-sdk/google` (already imported in the codebase) -- **Model ID**: `gemini-3-pro-preview` +- **Model ID**: `gemini-3.1-pro-preview` - **API Endpoint**: Google Generative AI API - **Vercel AI SDK Compatible**: Yes, fully compatible with the unified interface ## References -- [Google Gemini 3 Documentation](https://ai.google.dev/gemini-api/docs/gemini-3) +- [Google Gemini 3.1 Pro Documentation](https://ai.google.dev/gemini-api/docs/gemini-3) - [Vercel AI SDK - Google Provider](https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai) - [Google AI Studio](https://aistudio.google.com/) diff --git a/components/settings/components/model-selection-form.tsx b/components/settings/components/model-selection-form.tsx index 148ba85a..bc6164ba 100644 --- a/components/settings/components/model-selection-form.tsx +++ b/components/settings/components/model-selection-form.tsx @@ -43,11 +43,11 @@ const models = [ badgeVariant: "secondary" as const, }, { - id: "Gemini 3", - name: "Gemini 3", - description: "Google's next-generation multimodal model, excelling at understanding and processing diverse information.", + id: "Gemini 3.1 Pro", + name: "Gemini 3.1 Pro", + description: "Google's latest reasoning model, excelling at multimodal understanding and complex agentic tasks.", icon: Sparkles, - badge: "Multimodal", + badge: "Advanced", badgeVariant: "outline" as const, }, { @@ -55,7 +55,7 @@ const models = [ name: "GPT-5.1", description: "The cutting-edge of language models, offering unparalleled performance in creative and analytical tasks.", icon: Zap, - badge: "Advanced", + badge: "Expert", badgeVariant: "outline" as const, }, ]; diff --git a/components/settings/components/settings.tsx b/components/settings/components/settings.tsx index 7a526e18..8806664d 100644 --- a/components/settings/components/settings.tsx +++ b/components/settings/components/settings.tsx @@ -54,7 +54,7 @@ export type SettingsFormValues = z.infer const defaultValues: Partial = { systemPrompt: "You are a planetary copilot, an AI assistant designed to help users with information about planets, space exploration, and astronomy. Provide accurate, educational, and engaging responses about our solar system and beyond.", - selectedModel: "Grok 4.2", + selectedModel: "Gemini 3.1 Pro", users: [], } diff --git a/lib/agents/tools/geospatial.tsx b/lib/agents/tools/geospatial.tsx index ca5f9f49..33099975 100644 --- a/lib/agents/tools/geospatial.tsx +++ b/lib/agents/tools/geospatial.tsx @@ -249,14 +249,14 @@ Uses the Mapbox Search Box Text Search API endpoint to power searching for and g const selectedModel = await getSelectedModel(); - if (selectedModel?.includes('gemini') && mapProvider === 'google') { - let feedbackMessage = `Processing geospatial query with Gemini...`; + if (selectedModel?.toLowerCase().includes('gemini') && mapProvider === 'google') { + let feedbackMessage = `Processing geospatial query with Gemini 3.1 Pro...`; uiFeedbackStream.update(feedbackMessage); try { const genAI = new GoogleGenerativeAI(process.env.GEMINI_3_PRO_API_KEY!); const model = genAI.getGenerativeModel({ - model: 'gemini-1.5-pro-latest', + model: 'gemini-3.1-pro-preview', }); const searchText = (params as any).location || (params as any).query; diff --git a/lib/utils/index.ts b/lib/utils/index.ts index 5303da34..15565281 100644 --- a/lib/utils/index.ts +++ b/lib/utils/index.ts @@ -51,18 +51,19 @@ export async function getModel(requireVision: boolean = false) { throw new Error('Selected model is not configured.'); } case 'Gemini 3': + case 'Gemini 3.1 Pro': if (gemini3ProApiKey) { const google = createGoogleGenerativeAI({ apiKey: gemini3ProApiKey, }); try { - return google('gemini-3-pro-preview'); + return google('gemini-3.1-pro-preview'); } catch (error) { - console.error('Selected model "Gemini 3" is configured but failed to initialize.', error); + console.error('Selected model "Gemini 3.1 Pro" is configured but failed to initialize.', error); throw new Error('Failed to initialize selected model.'); } } else { - console.error('User selected "Gemini 3" but GEMINI_3_PRO_API_KEY is not set.'); + console.error('User selected "Gemini 3.1 Pro" but GEMINI_3_PRO_API_KEY is not set.'); throw new Error('Selected model is not configured.'); } case 'GPT-5.1': @@ -78,27 +79,27 @@ export async function getModel(requireVision: boolean = false) { } } - // Default behavior: Grok -> Gemini -> Bedrock -> OpenAI - if (xaiApiKey) { - const xai = createXai({ - apiKey: xaiApiKey, - baseURL: 'https://api.x.ai/v1', + // Default behavior: Gemini -> Grok -> Bedrock -> OpenAI + if (gemini3ProApiKey) { + const google = createGoogleGenerativeAI({ + apiKey: gemini3ProApiKey, }); try { - return xai('grok-4-fast-non-reasoning'); + return google('gemini-3.1-pro-preview'); } catch (error) { - console.warn('xAI API unavailable, falling back to next provider:'); + console.warn('Gemini 3.1 Pro API unavailable, falling back to next provider:', error); } } - if (gemini3ProApiKey) { - const google = createGoogleGenerativeAI({ - apiKey: gemini3ProApiKey, + if (xaiApiKey) { + const xai = createXai({ + apiKey: xaiApiKey, + baseURL: 'https://api.x.ai/v1', }); try { - return google('gemini-3-pro-preview'); + return xai('grok-4-fast-non-reasoning'); } catch (error) { - console.warn('Gemini 3 Pro API unavailable, falling back to next provider:', error); + console.warn('xAI API unavailable, falling back to next provider:'); } }