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
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user