From 2c51dabc569a43063cd36cb2d400571e22accfa4 Mon Sep 17 00:00:00 2001 From: Mini256 Date: Fri, 10 Jan 2025 15:06:42 +0800 Subject: [PATCH] refine model provider API --- .../app/api/admin_routes/embedding_model/routes.py | 9 ++++++++- backend/app/api/admin_routes/llm/routes.py | 7 ++++++- .../app/api/admin_routes/reranker_model/routes.py | 13 ++++++++++--- backend/app/rag/rerankers/__init__.py | 4 ++-- backend/app/rag/rerankers/provider.py | 2 +- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/backend/app/api/admin_routes/embedding_model/routes.py b/backend/app/api/admin_routes/embedding_model/routes.py index c5951bc7..9f8c383f 100644 --- a/backend/app/api/admin_routes/embedding_model/routes.py +++ b/backend/app/api/admin_routes/embedding_model/routes.py @@ -24,7 +24,14 @@ logger = logging.getLogger(__name__) -@router.get("/admin/embedding-models/options") +@router.get("/admin/embedding-models/provider/options") +def list_embedding_model_provider_options( + user: CurrentSuperuserDep, +) -> List[EmbeddingProviderOption]: + return embedding_provider_options + + +@router.get("/admin/embedding-models/options", deprecated=True) def get_embedding_model_options( user: CurrentSuperuserDep, ) -> List[EmbeddingProviderOption]: diff --git a/backend/app/api/admin_routes/llm/routes.py b/backend/app/api/admin_routes/llm/routes.py index f9800376..d0bad1da 100644 --- a/backend/app/api/admin_routes/llm/routes.py +++ b/backend/app/api/admin_routes/llm/routes.py @@ -20,7 +20,12 @@ logger = logging.getLogger(__name__) -@router.get("/admin/llms/options") +@router.get("/admin/llms/provider/options") +def list_llm_provider_options(user: CurrentSuperuserDep) -> List[LLMProviderOption]: + return llm_provider_options + + +@router.get("/admin/llms/options", deprecated=True) def get_llm_options(user: CurrentSuperuserDep) -> List[LLMProviderOption]: return llm_provider_options diff --git a/backend/app/api/admin_routes/reranker_model/routes.py b/backend/app/api/admin_routes/reranker_model/routes.py index a0f99f96..0ca39bc4 100644 --- a/backend/app/api/admin_routes/reranker_model/routes.py +++ b/backend/app/api/admin_routes/reranker_model/routes.py @@ -14,7 +14,7 @@ from app.repositories.reranker_model import reranker_model_repo from app.rag.rerankers import ( get_reranker_model, - admin_reranker_model_options, + reranker_provider_options, RerankerProviderOption, ) @@ -22,11 +22,18 @@ logger = logging.getLogger(__name__) -@router.get("/admin/reranker-models/options") +@router.get("/admin/reranker-models/provider/options") +def list_reranker_model_provider_options( + user: CurrentSuperuserDep, +) -> List[RerankerProviderOption]: + return reranker_provider_options + + +@router.get("/admin/reranker-models/options", deprecated=True) def get_reranker_model_options( user: CurrentSuperuserDep, ) -> List[RerankerProviderOption]: - return admin_reranker_model_options + return reranker_provider_options @router.post("/admin/reranker-models/test") diff --git a/backend/app/rag/rerankers/__init__.py b/backend/app/rag/rerankers/__init__.py index 329e487b..956c4977 100644 --- a/backend/app/rag/rerankers/__init__.py +++ b/backend/app/rag/rerankers/__init__.py @@ -5,7 +5,7 @@ from .provider import ( RerankerProvider, RerankerProviderOption, - admin_reranker_model_options, + reranker_provider_options, ) from .resolver import ( get_reranker_model, @@ -22,5 +22,5 @@ "get_reranker_model", "get_default_reranker_model", "must_get_default_reranker_model", - "admin_reranker_model_options", + "reranker_provider_options", ] diff --git a/backend/app/rag/rerankers/provider.py b/backend/app/rag/rerankers/provider.py index e6ac079b..b4a6af28 100644 --- a/backend/app/rag/rerankers/provider.py +++ b/backend/app/rag/rerankers/provider.py @@ -29,7 +29,7 @@ class RerankerProviderOption(BaseModel): credentials_type: str = "str" -admin_reranker_model_options: List[RerankerProviderOption] = [ +reranker_provider_options: List[RerankerProviderOption] = [ RerankerProviderOption( provider=RerankerProvider.JINA, provider_display_name="Jina AI",