From ef8856452095cbbaa44955f782fc6dc0d4df3673 Mon Sep 17 00:00:00 2001 From: Justin Hayes Date: Fri, 2 Aug 2024 15:45:38 -0400 Subject: [PATCH 1/2] Fix: get LiteLLM models on init --- examples/pipelines/providers/litellm_manifold_pipeline.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/pipelines/providers/litellm_manifold_pipeline.py b/examples/pipelines/providers/litellm_manifold_pipeline.py index 79609eb1..ef6c2492 100644 --- a/examples/pipelines/providers/litellm_manifold_pipeline.py +++ b/examples/pipelines/providers/litellm_manifold_pipeline.py @@ -2,7 +2,7 @@ title: LiteLLM Manifold Pipeline author: open-webui date: 2024-05-30 -version: 1.0 +version: 1.0.1 license: MIT description: A manifold pipeline that uses LiteLLM. """ @@ -46,7 +46,8 @@ def __init__(self): "LITELLM_PIPELINE_DEBUG": os.getenv("LITELLM_PIPELINE_DEBUG", False), } ) - self.pipelines = [] + # Get models on initialization + self.pipelines = self.get_litellm_models() pass async def on_startup(self): @@ -85,7 +86,7 @@ def get_litellm_models(self): for model in models["data"] ] except Exception as e: - print(f"Error: {e}") + print(f"Error fetching models from LiteLLM: {e}") return [ { "id": "error", @@ -93,6 +94,7 @@ def get_litellm_models(self): }, ] else: + print("LITELLM_BASE_URL not set. Please configure it in the valves.") return [] def pipe( From 316c547163cef5592a8574d8adb2f38809e5e9a9 Mon Sep 17 00:00:00 2001 From: Justin Hayes Date: Fri, 2 Aug 2024 15:51:28 -0400 Subject: [PATCH 2/2] Fix: get LiteLLM models on startup --- examples/pipelines/providers/litellm_manifold_pipeline.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/examples/pipelines/providers/litellm_manifold_pipeline.py b/examples/pipelines/providers/litellm_manifold_pipeline.py index ef6c2492..904a9f0e 100644 --- a/examples/pipelines/providers/litellm_manifold_pipeline.py +++ b/examples/pipelines/providers/litellm_manifold_pipeline.py @@ -53,6 +53,8 @@ def __init__(self): async def on_startup(self): # This function is called when the server is started. print(f"on_startup:{__name__}") + # Get models on startup + self.pipelines = self.get_litellm_models() pass async def on_shutdown(self):