feat: add custom headers support for OpenAI compatible embeddings #8910
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR addresses Issue #8909 by adding support for custom headers when configuring OpenAI compatible gateways for the code base indexing feature. This allows users to add required headers (like API keys or version headers) that some gateways require beyond the standard Authorization header.
Changes
Core Implementation
codebaseIndexOpenAiCompatibleHeadersfield to type definitions inpackages/types/src/codebase-index.tsOpenAICompatibleEmbedderto accept custom headers as an optional parameterTesting
Usage
Users can now configure custom headers for OpenAI compatible gateways through the codebase index configuration:
{ "codebaseIndexOpenAiCompatibleHeaders": { "X-Custom-Header": "custom-value", "X-API-Version": "v2" } }These headers will be automatically included in all embedding API requests.
Security Considerations
codebaseIndexOpenAiCompatibleApiKeyfield which is stored securely as a secret.Testing
npx vitest run services/code-index/embedders/__tests__/openai-compatible.spec.tsFixes #8909
Important
Adds support for custom headers in OpenAI-compatible embeddings, allowing configuration of additional headers like API keys.
codebaseIndexOpenAiCompatibleHeadersto configuration schema incodebase-index.tsandconfig.ts.CodeIndexConfigManagerto read and handle custom headers.OpenAICompatibleEmbedderto accept custom headers and merge them with default headers.service-factory.tsto pass custom headers when creatingOpenAICompatibleEmbedder.openai-compatible.spec.tsto verify custom headers are passed correctly and override default headers.config-manager.tsto include custom headers inopenAiCompatibleOptions.This description was created by
for d089fb2. You can customize this summary. It will automatically update as commits are pushed.