fix: embedding URL path missing /v1 prefix
The embedding endpoint path was but OpenAI-compatible APIs serve embeddings at . When EMBEDDING_BASE_URL is set to a bare host (e.g. https://llm.aviron.ai), the resulting URL would be /eembeddings instead of /v1/embeddings, returning 404. Changed defaultBaseURL to not include /v1 and always use /v1/embeddings as the endpoint path.
This commit is contained in:
1 parent
306fea37fd
commit
5ac11631d4
3 files changed
+5
-5
No files matched your search
+1
-1
@@ -3,7 +3,7 @@ QDRANT_PORT=6334
|
||||
# QDRANT_API_KEY=
|
||||
# QDRANT_TLS=false
|
||||
OPENAI_API_KEY=sk-...
|
||||
# EMBEDDING_BASE_URL=https://api.openai.com/v1
|
||||
# EMBEDDING_BASE_URL=https://api.openai.com
|
||||
EMBEDDING_MODEL=text-embedding-3-small
|
||||
MCP_TOKEN=change-me
|
||||
PORT=8080
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
const defaultModel = "text-embedding-3-small"
|
||||
const defaultBaseURL = "https://api.openai.com/v1"
|
||||
const defaultBaseURL = "https://api.openai.com"
|
||||
|
||||
type embedder struct {
|
||||
apiKey string
|
||||
@@ -61,7 +61,7 @@ func (e *embedder) embedText(ctx context.Context, text string) ([]float32, error
|
||||
return nil, fmt.Errorf("marshal embedding request: %w", err)
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, e.baseURL+"/embeddings", bytes.NewReader(body))
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodPost, e.baseURL+"/v1/embeddings", bytes.NewReader(body))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("create embedding request: %w", err)
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@
|
||||
|
||||
embeddingBaseUrl = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "https://api.openai.com/v1";
|
||||
description = "Base URL for the embeddings API.";
|
||||
default = "https://api.openai.com";
|
||||
description = "Base URL for the embeddings API. Do not include /v1 suffix; it is appended automatically.";
|
||||
};
|
||||
|
||||
embeddingModel = lib.mkOption {
|
||||
|
||||
Reference in new issue
Block a user