Skip to content

Commit

Permalink
Merge pull request #210 from justinh-rahb/litellm-fix
Browse files Browse the repository at this point in the history
Fix: Get LiteLLM Models
  • Loading branch information
tjbck authored Aug 2, 2024
2 parents edce3be + 316c547 commit 272cf8c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions examples/pipelines/providers/litellm_manifold_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""
Expand Down Expand Up @@ -46,12 +46,15 @@ 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):
# 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):
Expand Down Expand Up @@ -85,14 +88,15 @@ 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",
"name": "Could not fetch models from LiteLLM, please update the URL in the valves.",
},
]
else:
print("LITELLM_BASE_URL not set. Please configure it in the valves.")
return []

def pipe(
Expand Down

0 comments on commit 272cf8c

Please sign in to comment.