mirror of
https://github.com/open-webui/pipelines
synced 2025-05-12 16:40:45 +00:00
feat: pipelines function
This commit is contained in:
parent
2109df8230
commit
12e415615d
10
main.py
10
main.py
@ -49,7 +49,15 @@ def get_all_pipelines():
|
|||||||
|
|
||||||
if hasattr(pipeline, "type"):
|
if hasattr(pipeline, "type"):
|
||||||
if pipeline.type == "manifold":
|
if pipeline.type == "manifold":
|
||||||
for p in pipeline.pipelines:
|
manifold_pipelines = []
|
||||||
|
|
||||||
|
# Check if pipelines is a function or a list
|
||||||
|
if callable(pipeline.pipelines):
|
||||||
|
manifold_pipelines = pipeline.pipelines()
|
||||||
|
else:
|
||||||
|
manifold_pipelines = pipeline.pipelines
|
||||||
|
|
||||||
|
for p in manifold_pipelines:
|
||||||
manifold_pipeline_id = f'{pipeline_id}.{p["id"]}'
|
manifold_pipeline_id = f'{pipeline_id}.{p["id"]}'
|
||||||
|
|
||||||
manifold_pipeline_name = p["name"]
|
manifold_pipeline_name = p["name"]
|
||||||
|
@ -32,10 +32,8 @@ class Pipeline:
|
|||||||
LITELLM_PROXY_HOST: str = "127.0.0.1"
|
LITELLM_PROXY_HOST: str = "127.0.0.1"
|
||||||
litellm_config: dict = {}
|
litellm_config: dict = {}
|
||||||
|
|
||||||
# Initialize rate limits
|
# Initialize Valves
|
||||||
self.valves = Valves(**{"LITELLM_CONFIG_DIR": f"./litellm/config.yaml"})
|
self.valves = Valves(**{"LITELLM_CONFIG_DIR": f"./litellm/config.yaml"})
|
||||||
self.pipelines = []
|
|
||||||
|
|
||||||
self.background_process = None
|
self.background_process = None
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -102,8 +100,6 @@ class Pipeline:
|
|||||||
self.background_process = process
|
self.background_process = process
|
||||||
print("Subprocess started successfully.")
|
print("Subprocess started successfully.")
|
||||||
|
|
||||||
self.pipelines = self.get_litellm_models()
|
|
||||||
|
|
||||||
# Capture STDERR for debugging purposes
|
# Capture STDERR for debugging purposes
|
||||||
stderr_output = await process.stderr.read()
|
stderr_output = await process.stderr.read()
|
||||||
stderr_text = stderr_output.decode().strip()
|
stderr_text = stderr_output.decode().strip()
|
||||||
@ -172,6 +168,11 @@ class Pipeline:
|
|||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
# Pipelines are the models that are available in the manifold.
|
||||||
|
# It can be a list or a function that returns a list.
|
||||||
|
def pipelines(self) -> List[dict]:
|
||||||
|
return self.get_litellm_models()
|
||||||
|
|
||||||
def pipe(
|
def pipe(
|
||||||
self, user_message: str, model_id: str, messages: List[dict], body: dict
|
self, user_message: str, model_id: str, messages: List[dict], body: dict
|
||||||
) -> Union[str, Generator, Iterator]:
|
) -> Union[str, Generator, Iterator]:
|
||||||
|
Loading…
Reference in New Issue
Block a user