Skip to content

fix(embedding): respect server_url for openai embedding provider - #119

Open
Sci-fiBrain wants to merge 1 commit into
fruitbars:mainfrom
Sci-fiBrain:fix/embedding-server-url
Open

fix(embedding): respect server_url for openai embedding provider#119
Sci-fiBrain wants to merge 1 commit into
fruitbars:mainfrom
Sci-fiBrain:fix/embedding-server-url

Conversation

@Sci-fiBrain

Copy link
Copy Markdown

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 为空时回退官方地址,向后兼容,不影响存量配置。

Copilot AI lite review requested due to automatic review settings August 19, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 OpenAIEmbedding to accept serverURL and build the embeddings request URL from it.
  • Pass s.ServerURL from EmbeddingsHandler into 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"
}
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