Skip to content

Conversation

@roomote
Copy link
Collaborator

@roomote roomote commented Jun 30, 2025

Summary

This PR fixes issue #5212 by adding support for the required api-version query parameter when using Azure OpenAI with the "OpenAI Compatible" provider in codebase indexing.

Problem

When using Azure OpenAI embedding models through the "OpenAI Compatible" provider, users consistently receive 404 errors because the extension doesn't include the mandatory api-version query parameter that Azure OpenAI API requires.

Solution

  • Added API Version Field: New optional apiVersion parameter in the OpenAI Compatible provider configuration
  • Smart URL Construction: Modified the OpenAICompatibleEmbedder to intelligently append the api-version query parameter to the base URL
  • UI Enhancement: Added a dedicated "API Version" input field in the settings with placeholder text "2023-05-15"
  • Type Safety: Updated all relevant TypeScript interfaces and Zod schemas
  • Comprehensive Testing: Added test coverage for API version functionality
  • Internationalization: Added English translation keys for the new field

Technical Details

URL Construction Logic

The embedder now handles both scenarios:

  • Base URL without query params: https://example.openai.azure.com/openai/deployments/modelhttps://example.openai.azure.com/openai/deployments/model?api-version=2023-05-15
  • Base URL with existing query params: https://example.com/api?key=valuehttps://example.com/api?key=value&api-version=2023-05-15

Files Modified

  • packages/types/src/codebase-index.ts - Added schema validation
  • src/services/code-index/interfaces/config.ts - Updated interfaces
  • src/services/code-index/config-manager.ts - Added config management
  • src/services/code-index/embedders/openai-compatible.ts - Core URL construction logic
  • src/services/code-index/service-factory.ts - Updated service instantiation
  • webview-ui/src/components/settings/CodeIndexSettings.tsx - Added UI field
  • webview-ui/src/i18n/locales/en/settings.json - Added translations
  • src/services/code-index/embedders/__tests__/openai-compatible.spec.ts - Added tests

Testing

✅ All existing tests pass
✅ New test cases cover API version functionality
✅ Type checking passes across all packages
✅ Linting passes with no warnings

Manual Testing Instructions

  1. Open VSCode with the Roo Code extension
  2. Go to Settings → Codebase Index
  3. Select "OpenAI Compatible" as the provider
  4. Enter your Azure OpenAI endpoint URL (e.g., https://your-resource.openai.azure.com/openai/deployments/your-model)
  5. Enter your API key
  6. NEW: Enter an API version (e.g., 2023-05-15) in the new "API Version" field
  7. Save settings and test codebase indexing

Backward Compatibility

✅ The apiVersion field is optional, so existing configurations continue to work
✅ No breaking changes to existing APIs or interfaces
✅ Graceful handling when API version is not provided

Fixes #5212


Important

Adds optional apiVersion support for Azure OpenAI in OpenAI Compatible provider, updating URL logic, UI, and tests.

  • Behavior:
    • Adds optional apiVersion parameter to OpenAI Compatible provider configuration.
    • Updates OpenAICompatibleEmbedder to append api-version query parameter to URLs.
    • UI updated in CodeIndexSettings.tsx to include "API Version" input field.
  • Type Safety:
    • Updates TypeScript interfaces and Zod schemas to include apiVersion.
  • Testing:
    • Adds tests in openai-compatible.spec.ts to cover apiVersion functionality.
  • Internationalization:
    • Adds English translation keys for the new "API Version" field.

This description was created by Ellipsis for 5ab3ae8. You can customize this summary. It will automatically update as commits are pushed.

- Add optional apiVersion field to OpenAI Compatible provider schema
- Update config manager to handle API version parameter
- Modify OpenAICompatibleEmbedder to append api-version query parameter
- Add API version input field to settings UI with validation
- Include comprehensive test coverage for API version functionality
- Add i18n support for new API version field

Fixes #5212: Azure OpenAI embedding requests now include required api-version parameter
@roomote roomote requested review from cte, jr and mrubens as code owners June 30, 2025 09:46
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request UI/UX UI/UX related or focused labels Jun 30, 2025
@delve-auditor
Copy link

delve-auditor bot commented Jun 30, 2025

No security or compliance issues detected. Reviewed everything up to 5ab3ae8.

Security Overview
  • 🔎 Scanned files: 8 changed file(s)
Detected Code Changes

The diff is too large to display a summary of code changes.

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jun 30, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jul 7, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Codebase Indexing with Azure OpenAI: API version missing

3 participants