Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Use TEI_BASE_URL then TEI_HOST (#21021)

Wang Qie347fc6b900e
diff --git a/docker/.env b/docker/.env
index bd4a8abae4..e44862eb3d 100644
--- a/docker/.env
+++ b/docker/.env
@@ -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.
diff --git a/internal/common/environments.go b/internal/common/environments.go
index baefb2f367..11f87739d9 100644
--- a/internal/common/environments.go
+++ b/internal/common/environments.go
@@ -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"
diff --git a/internal/entity/models/builtin.go b/internal/entity/models/builtin.go
index 9872662fe2..e424a1fdd9 100644
--- a/internal/entity/models/builtin.go
+++ b/internal/entity/models/builtin.go
@@ -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