8000 feat: Add OpenAI Compatible embedder for codebase indexing by SannidhyaSah · Pull Request #4066 · RooCodeInc/Roo-Code · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat: Add OpenAI Compatible embedder for codebase indexing #4066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

SannidhyaSah
Copy link
@SannidhyaSah SannidhyaSah commented May 28, 2025

Related GitHub Issue

Closes: #4065

Description

This PR implements OpenAI Compatible embedder support for codebase indexing, enabling users to connect to any OpenAI-compatible API endpoint (LiteLLM, LMStudio, Ollama, etc.) for generating embeddings.

Key implementation details:

  • New embedder class: OpenAiCompatibleEmbedder with intelligent batching and retry logic
  • Configuration management: Added base URL and API key settings with validation
  • UI integration: Dynamic provider selection with conditional input fields
  • Comprehensive testing: 20+ unit tests covering all functionality
  • Internationalization: Complete translations for 17 languages

Design choices:

  • Used OpenAI SDK for compatibility with all OpenAI-spec endpoints
  • Implemented batching with configurable sizes for optimal performance
  • Added exponential backoff retry logic for robust error handling
  • Followed existing patterns from other embedder implementations

Test Procedure

Automated Testing:

  1. Run pnpm test - All 20+ new unit tests pass
  2. Run pnpm lint - No linting errors
  3. Run pnpm check-types - All TypeScript types valid

Manual Testing:

  1. Open VSCode extension settings
  2. Navigate to Codebase Index settings
  3. Select "OpenAI Compatible" from provider dropdown
  4. Verify Base URL and API Key fields appear
  5. Test validation by leaving fields empty
  6. Configure with a valid OpenAI-compatible endpoint
  7. Verify embeddings are generated successfully

Type of Change

  • New Feature: Non-breaking change that adds functionality.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. (This feature should be documented in user-facing docs explaining how to configure OpenAI-compatible endpoints for codebase indexing)

Additional Notes

This implementation supports all major OpenAI-compatible providers including:

  • LiteLLM proxy servers
  • LMStudio local servers
  • Ollama with OpenAI compatibility
  • Any other service implementing OpenAI's embeddings API spec

The feature is fully backward compatible and doesn't affect existing embedder configurations.


Important

Adds support for OpenAI-compatible embedders in codebase indexing with new embedder class, configuration, UI integration, and comprehensive testing.

  • Behavior:
    • Adds OpenAiCompatibleEmbedder class for OpenAI-compatible API endpoints with batching and retry logic.
    • Updates codebase-index.ts to include openai-compatible as an embedder provider.
    • UI changes in CodeIndexSettings.tsx to support dynamic provider selection.
  • Configuration:
    • Adds configuration options for base URL and API key in config-manager.ts.
    • Updates provider-settings.ts and global-settings.ts for new configuration keys.
  • Testing:
    • Adds 20+ unit tests in openai-compatible.test.ts and config-manager.test.ts.
    • Tests for configuration loading and validation in service-factory.test.ts.
  • Internationalization:
    • Updates translations in 17 language files for new UI elements.
  • Misc:
    • Adds OpenAiCompatibleEmbedder to service-factory.ts for embedder creation.
    • Updates embeddingModels.ts to include openai-compatible models.

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

- Implement OpenAiCompatibleEmbedder with batching and retry logic
- Add configuration support for base URL and API key
- Update UI with provider selection and input fields
- Add comprehensive test coverage
- Support for all OpenAI-compatible endpoints (LiteLLM, LMStudio, Ollama, etc.)
- Add internationalization for 17 languages
- Fix field count expectations (4 fields including Qdrant)
- Use specific test IDs for button selection
- Fix input handling with clear() before type()
- Use toHaveBeenLastCalledWith for better assertions
- Fix status text matching with regex pattern
- Remove unused waitFor import to fix ESLint error
- Fix test expectations to match actual component behavior for input fields
- Simplify provider selection test by removing complex mock interactions
- All CodeIndexSettings tests now pass (20/20)
@SannidhyaSah SannidhyaSah marked this pull request as ready for review May 28, 2025 06:45
@SannidhyaSah SannidhyaSah requested review from mrubens and cte as code owners May 28, 2025 06:45
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. documentation Improvements or additions to documentation enhancement New feature or request labels May 28, 2025
@@ -40,6 +40,9 @@
"selectProviderPlaceholder": "选择提供商",
"openaiProvider": "OpenAI",
"ollamaProvider": "Ollama",
"openaiCompatibleProvider": "OpenAI 兼容",
"openaiCompatibleBaseUrlLabel": "基础 URL:",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label value for openaiCompatibleBaseUrlLabel uses a half-width colon (:) instead of the full-width colon () used in similar labels (e.g. openaiKeyLabel). Consider changing it for consistency.

Suggested change
"openaiCompatibleBaseUrlLabel": "基础 URL:",
"openaiCompatibleBaseUrlLabel": "基础 URL",

@@ -40,6 +40,9 @@
"selectProviderPlaceholder": "选择提供商",
"openaiProvider": "OpenAI",
"ollamaProvider": "Ollama",
"openaiCompatibleProvider": "OpenAI 兼容",
"openaiCompatibleBaseUrlLabel": "基础 URL:",
"openaiCompatibleApiKeyLabel": "API 密钥:",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label value for openaiCompatibleApiKeyLabel uses a half-width colon (:) rather than the full-width colon () seen in other labels like openaiKeyLabel and ollamaUrlLabel. Please update for consistency.

Suggested change
"openaiCompatibleApiKeyLabel": "API 密钥:",
"openaiCompatibleApiKeyLabel": "API 密钥",

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label May 28, 2025
@hannesrudolph hannesrudolph moved this from Triage to PR [Needs Preliminary Review] in Roo Code Roadmap May 28, 2025
@hannesrudolph hannesrudolph added PR - Needs Preliminary Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request PR - Needs Preliminary Review size:XXL This PR changes 1000+ lines, ignoring generated files.
Projects
Status: PR [Needs Prelim Review]
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add OpenAI Compatible embedder support for codebase indexing
2 participants
0