Skip to content

📝 CodeRabbit Chat: Implement requested code changes#612

Open
coderabbitai[bot] wants to merge 2 commits into
feat/azure-foundry-gpt-5.5-integration-17932664142642914555from
coderabbitai/chat/217eb5e
Open

📝 CodeRabbit Chat: Implement requested code changes#612
coderabbitai[bot] wants to merge 2 commits into
feat/azure-foundry-gpt-5.5-integration-17932664142642914555from
coderabbitai/chat/217eb5e

Conversation

@coderabbitai
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot commented May 13, 2026

Code changes was requested by @ngoiyaeric.

The following files were modified:

  • .env.local.example
  • bun.lock
  • lib/utils/index.ts
  • package.json

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
qcx Ready Ready Preview, Comment May 14, 2026 9:23am

@coderabbitai
Copy link
Copy Markdown
Contributor Author

coderabbitai Bot commented May 13, 2026

Important

Review skipped

This PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ebd6d276-2e61-4d7e-802a-48cab50d9396

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 13, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ ngoiyaeric
❌ coderabbitai[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@ngoiyaeric
Copy link
Copy Markdown
Collaborator

@coderabbitai make azure the main model

@coderabbitai
Copy link
Copy Markdown
Contributor Author

coderabbitai Bot commented May 13, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Let me explore the codebase to understand the current model configuration.


🏁 Script executed:

#!/bin/bash
# Look at the key files mentioned in the PR
cat lib/utils/index.ts 2>/dev/null || echo "File not found"
echo "---"
cat .env.local.example 2>/dev/null || echo "File not found"
echo "---"
# Find AI/model configuration files
fd -e ts -e tsx -e js "model" --exclude node_modules
echo "---"
# Search for model definitions or default model settings
rg -n "defaultModel\|DEFAULT_MODEL\|main.*model\|model.*default\|azure\|AZURE" --type=ts --type=tsx -i -l

Length of output: 6799


@ngoiyaeric Here's the change needed in lib/utils/index.ts to make Azure the first default model (moving it to the top of the fallback chain):

  // Default behavior: Azure -> Gemini -> Grok -> Bedrock -> OpenAI
  if (azureEndpoint && azureApiKey) {
    const azureOpenai = createOpenAI({
      baseURL: azureEndpoint,
      apiKey: azureApiKey,
      compatibility: 'compatible',
    });
    try {
      return azureOpenai(azureDeploymentName);
    } catch (error) {
      console.warn('Azure OpenAI API unavailable, falling back to next provider:', error);
    }
  }

  if (gemini3ProApiKey) {
    const google = createGoogleGenerativeAI({
      apiKey: gemini3ProApiKey,
    });
    try {
      return google('gemini-3.1-pro-preview');
    } catch (error) {
      console.warn('Gemini 3.1 Pro API unavailable, falling back to next provider:', error);
    }
  }

  if (xaiApiKey) {
    const xai = createXai({
      apiKey: xaiApiKey,
      baseURL: 'https://api.x.ai/v1',
    });
    try {
      return xai('grok-4-fast-non-reasoning');
    } catch (error) {
      console.warn('xAI API unavailable, falling back to next provider:');
    }
  }

  if (awsAccessKeyId && awsSecretAccessKey) {
    const bedrock = createAmazonBedrock({
      bedrockOptions: {
        region: awsRegion,
        credentials: {
          accessKeyId: awsAccessKeyId,
          secretAccessKey: awsSecretAccessKey,
        },
      },
    });
    const model = bedrock(bedrockModelId, {
      additionalModelRequestFields: { top_k: 350 },
    });
    return model;
  }

  const openai = createOpenAI({
    apiKey: openaiApiKey,
  });
  return openai('gpt-4o');

The key change is the comment and order — Azure is now checked first in the default fallback chain (Azure -> Gemini -> Grok -> Bedrock -> OpenAI). Make sure AZURE_ENDPOINT, AZURE_API_KEY, and optionally AZURE_DEPLOYMENT_NAME are set in your .env.local file (the example values are already in .env.local.example).

Would you like me to implement this change directly via a plan?

@ngoiyaeric
Copy link
Copy Markdown
Collaborator

@coderabbitai plan impelement that

@coderabbitai
Copy link
Copy Markdown
Contributor Author

coderabbitai Bot commented May 13, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Task: Make Azure the main/first model in the fallback chain

  • Read lib/utils/index.ts to get the exact current code
  • Reorder the provider checks so Azure comes first
  • Update the fallback order comment

🏁 Script executed:

#!/bin/bash
cat lib/utils/index.ts

Length of output: 5406


@ngoiyaeric Here's the plan to implement the change:

Task: Make Azure the first model in the default fallback chain

  • Move the Azure if block to the top of the default provider checks in lib/utils/index.ts
  • Update the fallback order comment accordingly

Failed to handle agent chat message. Please try again.

@ngoiyaeric
Copy link
Copy Markdown
Collaborator

@coderabbitai can you fix the model picker such that the azure endpoint is functional

@coderabbitai
Copy link
Copy Markdown
Contributor Author

coderabbitai Bot commented May 14, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

Let me read the current state of the relevant files first.


🏁 Script executed:

#!/bin/bash
cat lib/utils/index.ts
echo "=== SEARCHING FOR MODEL PICKER ==="
rg -rn "model.*picker\|ModelPicker\|modelPicker\|model-picker" --type=ts --type=tsx -i -l 2>/dev/null || true
fd -e tsx -e ts "model" --exclude node_modules
echo "=== SEARCH FOR AZURE IN COMPONENTS ==="
rg -rn "azure\|AZURE" -i --type=ts --type=tsx -l 2>/dev/null || true
echo "=== SEARCH FOR MODEL SELECTOR/PICKER COMPONENTS ==="
rg -rn "ModelSelector\|model-selector\|useModel\|selectedModel\|setModel" -i --type=ts --type=tsx -l 2>/dev/null || true

Length of output: 4732


Let me read the model picker component and related files.


🏁 Script executed:

#!/bin/bash
echo "=== MODEL SELECTION FORM ==="
cat components/settings/components/model-selection-form.tsx
echo "=== .env.local.example ==="
cat .env.local.example
echo "=== getSelectedModel action ==="
fd -e ts -e tsx "users" lib/actions
rg -n "getSelectedModel\|setSelectedModel\|selectedModel" --type=ts --type=tsx -C3

Length of output: 6757


🏁 Script executed:

#!/bin/bash
echo "=== USERS ACTION ==="
cat lib/actions/users.ts
echo "=== SETTINGS FORM/PAGE ==="
rg -rn "ModelSelectionForm\|model-selection-form\|updateSettings\|saveSettings\|selectedModel" --type=ts --type=tsx -C3
echo "=== SETTINGS PAGE ==="
fd -e tsx -e ts "settings" --exclude node_modules

Length of output: 5768


🏁 Script executed:

#!/bin/bash
echo "=== SETTINGS VIEW ==="
cat components/settings/settings-view.tsx
echo "=== SETTINGS.TSX ==="
cat components/settings/components/settings.tsx
echo "=== SETTINGS STORE ==="
cat lib/store/settings.ts
echo "=== DB SCHEMA (look for selectedModel) ==="
fd -e ts "schema" lib/db

Length of output: 12642


🏁 Script executed:

#!/bin/bash
echo "=== DB SCHEMA ==="
cat lib/db/schema.ts
echo "=== CHECK FOR QCX-TERRA HANDLING ==="
rg -n "QCX-Terra\|qcx-terra\|terra" --type=ts --type=tsx -i
echo "=== CHECK AZURE ENDPOINT URL FORMAT ==="
rg -n "baseURL\|azureEndpoint\|azure.*endpoint\|AZURE_ENDPOINT" --type=ts -i

Length of output: 7006


🏁 Script executed:

#!/bin/bash
echo "=== PACKAGE.JSON ==="
cat package.json

Length of output: 3729


@ngoiyaeric Here's what I found. There are three concrete bugs preventing the Azure endpoint from being functional:

  1. Authentication header mismatchcreateOpenAI sends Authorization: Bearer <key>, but Azure OpenAI / AI Foundry expects api-key: <key>. This is the main reason calls fail.
  2. QCX-Terra model has no handler in getModel() — selecting it silently falls through to the default provider chain, never hitting Azure.
  3. USE_AZURE=true is missing from .env.local.example — so the Azure-first default is never triggered.

Task: Fix Azure endpoint in the model picker

  • Fix auth header bug in lib/utils/index.ts (both the case 'Azure GPT 5.5': block and the default USE_AZURE fallback block)
  • Add missing case 'QCX-Terra': handler routing to Azure
  • Add USE_AZURE=true to .env.local.example
  • Update the default selected model to "Azure GPT 5.5" in components/settings/components/settings.tsx

Failed to handle agent chat message. Please try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants