mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-11-10 21:32:43 +08:00
Fix: Use TEI_BASE_URL then TEI_HOST (#21021)
This commit is contained in:
1 parent
80b277c3ae
commit
e347fc6b90
3 files changed
+10
-14
No files matched your search
+1
-1
@@ -336,7 +336,7 @@ TEI_IMAGE_GPU=infiniflow/text-embeddings-inference:1.8
|
||||
# - `BAAI/bge-small-en-v1.5` (requires 1.2GB RAM/vRAM to load)
|
||||
TEI_MODEL=${TEI_MODEL:-Qwen/Qwen3-Embedding-0.6B}
|
||||
|
||||
# The embedding service port:
|
||||
# The embedding service hostname inside the Docker network:
|
||||
TEI_HOST=tei
|
||||
# The port used to expose the TEI service to the host machine,
|
||||
# allowing EXTERNAL access to the service running inside the Docker container.
|
||||
|
||||
@@ -240,6 +240,7 @@ const (
|
||||
EnvChunkFeedbackWeighting = "CHUNK_FEEDBACK_WEIGHTING"
|
||||
EnvComposeProfiles = "COMPOSE_PROFILES"
|
||||
EnvTEIModel = "TEI_MODEL"
|
||||
EnvTEIHost = "TEI_HOST"
|
||||
EnvTEIBaseURL = "TEI_BASE_URL"
|
||||
EnvRAGFlowConfDir = "RAGFLOW_CONF_DIR"
|
||||
EnvRAGProjectBase = "RAG_PROJECT_BASE"
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"ragflow/internal/common"
|
||||
"strings"
|
||||
@@ -20,6 +21,11 @@ type BuiltinModel struct {
|
||||
|
||||
// NewBuiltinModel creates a new Builtin model instance
|
||||
func NewBuiltinModel(baseURL, model string) *BuiltinModel {
|
||||
if baseURL == "" {
|
||||
host := getEnv(common.EnvTEIHost, "tei")
|
||||
baseURL = getEnv(common.EnvTEIBaseURL, "http://"+net.JoinHostPort(host, "80"))
|
||||
}
|
||||
|
||||
return &BuiltinModel{
|
||||
baseURL: baseURL,
|
||||
model: model,
|
||||
@@ -52,12 +58,7 @@ func (b *BuiltinModel) Embed(ctx context.Context, modelName *string, request Emb
|
||||
return []EmbeddingData{}, nil
|
||||
}
|
||||
|
||||
baseURL := b.baseURL
|
||||
if baseURL == "" {
|
||||
baseURL = "http://localhost:6380"
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/embed", baseURL)
|
||||
url := fmt.Sprintf("%s/embed", b.baseURL)
|
||||
|
||||
reqBody := map[string]interface{}{
|
||||
"inputs": request.Texts,
|
||||
@@ -169,13 +170,7 @@ func (b *BuiltinModel) ShowTask(ctx context.Context, taskID string, apiConfig *A
|
||||
|
||||
// GetBuiltinEmbeddingModel returns a Builtin model driver for the given model name
|
||||
func GetBuiltinEmbeddingModel(modelName string) ModelDriver {
|
||||
// Get TEI base URL from environment or config
|
||||
// Default to port 6380 where docker-tei-cpu-1 maps internal port 80
|
||||
teiBaseURL := getEnv(common.EnvTEIBaseURL, "http://localhost:6380")
|
||||
|
||||
// Create a builtin model instance with TEI endpoint
|
||||
driver := NewBuiltinModel(teiBaseURL, modelName)
|
||||
return driver
|
||||
return NewBuiltinModel("", modelName)
|
||||
}
|
||||
|
||||
// getEnv is a helper to get environment variable with default
|
||||
|
||||
Reference in new issue
Block a user