fix(embedding): respect server_url for openai embedding provider - #119
Open
Sci-fiBrain wants to merge 1 commit into
Open
fix(embedding): respect server_url for openai embedding provider#119Sci-fiBrain wants to merge 1 commit into
Sci-fiBrain wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes OpenAI-compatible embedding forwarding by using the configured server_url (when provided) instead of a hard-coded OpenAI embeddings endpoint, aligning embedding behavior with the existing chat path behavior.
Changes:
- Extend
OpenAIEmbeddingto acceptserverURLand build the embeddings request URL from it. - Pass
s.ServerURLfromEmbeddingsHandlerinto the OpenAI embedding provider implementation.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/embedding/oai/oai_embedding.go | Builds embeddings URL from server_url with fallback to the official OpenAI endpoint. |
| pkg/embedding/embeddings_handler.go | Passes configured ServerURL through to the OpenAI embedding provider. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+16
to
+21
| url := serverURL | ||
| if url == "" { | ||
| url = "https://api.openai.com/v1/embeddings" | ||
| } else { | ||
| url = strings.TrimRight(url, "/") + "/embeddings" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
openai 类型 embedding 的请求 URL 目前写死为 https://api.openai.com/v1/embeddings,没有使用 Provider 配置的 server_url,导致 embedding 无法转发到自建的 OpenAI 兼容服务(如本地 TEI、Ollama)。chat 路径已支持 server_url,embedding 这里不一致。
修改:将 s.ServerURL 传入 OpenAIEmbedding,按 serverURL + "/embeddings" 拼请求地址;server_url 为空时回退官方地址,向后兼容,不影响存量配置。