Skip to content

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

Fix: route API-Route to it's driver (#19793)

Lynna6c722778837
diff --git a/internal/entity/models/apiroute_test.go b/internal/entity/models/apiroute_test.go
index da7619ec04..65f4d7a075 100644
--- a/internal/entity/models/apiroute_test.go
+++ b/internal/entity/models/apiroute_test.go
@@ -41,7 +41,7 @@ func TestApiRouteName(t *testing.T) {
// TestApiRouteFactory tests creating the driver from factory.
func TestApiRouteFactory(t *testing.T) {
- driver, err := NewModelFactory().CreateModelDriver("apiroute", map[string]string{"default": "http://unused"}, URLSuffix{})
+ driver, err := NewModelFactory().CreateModelDriver("api-route", map[string]string{"default": "http://unused"}, URLSuffix{})
if err != nil {
t.Fatalf("CreateModelDriver: %v", err)
}
@@ -53,6 +53,27 @@ func TestApiRouteFactory(t *testing.T) {
}
}
+// The shipped config must resolve to the API-Route driver. CreateModelDriver
+// dispatches on strings.ToLower(name), so the "API-Route" provider name only
+// matches a "api-route" case; a "apiroute" case silently falls through to
+// DummyModel.
+func TestApiRouteProviderConfig(t *testing.T) {
+ dir, restore := setupProviderTestDir(t, "apiroute.json")
+ defer restore()
+
+ if err := InitProviderManager(dir); err != nil {
+ t.Fatalf("InitProviderManager: %v", err)
+ }
+
+ provider := GetProviderManager().FindProvider("API-Route")
+ if provider == nil {
+ t.Fatal("API-Route provider not found")
+ }
+ if _, ok := provider.ModelDriver.(*ApiRouteModel); !ok {
+ t.Fatalf("ModelDriver=%T, want *models.ApiRouteModel", provider.ModelDriver)
+ }
+}
+
// TestApiRouteChatSendsAPIKey tests chat completion authentication.
func TestApiRouteChatSendsAPIKey(t *testing.T) {
withSSRFBypass(t)
diff --git a/internal/entity/models/factory.go b/internal/entity/models/factory.go
index d7e0fc9f59..6e8a8d9474 100644
--- a/internal/entity/models/factory.go
+++ b/internal/entity/models/factory.go
@@ -175,7 +175,7 @@ func (f *ModelFactory) CreateModelDriver(providerName string, baseURL map[string
return NewSynthoraiModel(baseURL, urlSuffix), nil
case "anonrouter":
return NewAnonRouterModel(baseURL, urlSuffix), nil
- case "apiroute":
+ case "api-route":
return NewApiRouteModel(baseURL, urlSuffix), nil
default:
return NewDummyModel(baseURL, urlSuffix), nil