mirror of
https://github.com/open-webui/pipelines
synced 2025-06-26 01:56:00 +00:00
feat: manifold naming
This commit is contained in:
parent
29e3ba4c4d
commit
918b709f30
7
main.py
7
main.py
@ -47,10 +47,15 @@ def on_startup():
|
|||||||
if hasattr(pipeline, "manifold") and pipeline.manifold:
|
if hasattr(pipeline, "manifold") and pipeline.manifold:
|
||||||
for p in pipeline.pipelines:
|
for p in pipeline.pipelines:
|
||||||
manifold_pipeline_id = f'{pipeline_id}.{p["id"]}'
|
manifold_pipeline_id = f'{pipeline_id}.{p["id"]}'
|
||||||
|
|
||||||
|
manifold_pipeline_name = p["name"]
|
||||||
|
if hasattr(pipeline, "name"):
|
||||||
|
manifold_pipeline_name = f"{pipeline.name}{manifold_pipeline_name}"
|
||||||
|
|
||||||
PIPELINES[manifold_pipeline_id] = {
|
PIPELINES[manifold_pipeline_id] = {
|
||||||
"module": pipeline,
|
"module": pipeline,
|
||||||
"id": manifold_pipeline_id,
|
"id": manifold_pipeline_id,
|
||||||
"name": p["name"],
|
"name": manifold_pipeline_name,
|
||||||
"manifold": True,
|
"manifold": True,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
@ -5,7 +5,8 @@ from schemas import OpenAIChatMessage
|
|||||||
class Pipeline:
|
class Pipeline:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.id = "manifold_pipeline"
|
self.id = "manifold_pipeline"
|
||||||
self.name = "Manifold Pipeline"
|
# Optionally, you can set the name of the manifold pipeline.
|
||||||
|
self.name = "Manifold: "
|
||||||
# You can also set the pipelines that are available in this pipeline.
|
# You can also set the pipelines that are available in this pipeline.
|
||||||
# Set manifold to True if you want to use this pipeline as a manifold.
|
# Set manifold to True if you want to use this pipeline as a manifold.
|
||||||
# Manifold pipelines can have multiple pipelines.
|
# Manifold pipelines can have multiple pipelines.
|
||||||
@ -13,11 +14,11 @@ class Pipeline:
|
|||||||
self.pipelines = [
|
self.pipelines = [
|
||||||
{
|
{
|
||||||
"id": "pipeline-1", # This will turn into `manifold_pipeline.pipeline-1`
|
"id": "pipeline-1", # This will turn into `manifold_pipeline.pipeline-1`
|
||||||
"name": "Manifold: Pipeline 1",
|
"name": "Pipeline 1", # This will turn into `Manifold: Pipeline 1`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "pipeline-2",
|
"id": "pipeline-2",
|
||||||
"name": "Manifold: Pipeline 2",
|
"name": "Pipeline 2",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
pass
|
pass
|
||||||
|
45
pipelines/examples/ollama_manifold_pipeline.py
Normal file
45
pipelines/examples/ollama_manifold_pipeline.py
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
from typing import List, Union, Generator, Iterator
|
||||||
|
from schemas import OpenAIChatMessage
|
||||||
|
|
||||||
|
|
||||||
|
class Pipeline:
|
||||||
|
def __init__(self):
|
||||||
|
self.id = "manifold_pipeline"
|
||||||
|
self.name = "Manifold Pipeline"
|
||||||
|
# You can also set the pipelines that are available in this pipeline.
|
||||||
|
# Set manifold to True if you want to use this pipeline as a manifold.
|
||||||
|
# Manifold pipelines can have multiple pipelines.
|
||||||
|
self.manifold = True
|
||||||
|
self.pipelines = [
|
||||||
|
{
|
||||||
|
"id": "pipeline-1", # This will turn into `manifold_pipeline.pipeline-1`
|
||||||
|
"name": "Manifold: Pipeline 1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "pipeline-2",
|
||||||
|
"name": "Manifold: Pipeline 2",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def on_startup(self):
|
||||||
|
# This function is called when the server is started.
|
||||||
|
print(f"on_startup:{__name__}")
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def on_shutdown(self):
|
||||||
|
# This function is called when the server is stopped.
|
||||||
|
print(f"on_shutdown:{__name__}")
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_response(
|
||||||
|
self, user_message: str, model_id: str, messages: List[dict], body: dict
|
||||||
|
) -> Union[str, Generator, Iterator]:
|
||||||
|
# This is where you can add your custom pipelines like RAG.'
|
||||||
|
print(f"get_response:{__name__}")
|
||||||
|
|
||||||
|
print(messages)
|
||||||
|
print(user_message)
|
||||||
|
print(body)
|
||||||
|
|
||||||
|
return f"{model_id} response to: {user_message}"
|
@ -5,7 +5,8 @@ from schemas import OpenAIChatMessage
|
|||||||
class Pipeline:
|
class Pipeline:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.id = "manifold_pipeline"
|
self.id = "manifold_pipeline"
|
||||||
self.name = "Manifold Pipeline"
|
# Optionally, you can set the name of the manifold pipeline.
|
||||||
|
self.name = "Manifold: "
|
||||||
# You can also set the pipelines that are available in this pipeline.
|
# You can also set the pipelines that are available in this pipeline.
|
||||||
# Set manifold to True if you want to use this pipeline as a manifold.
|
# Set manifold to True if you want to use this pipeline as a manifold.
|
||||||
# Manifold pipelines can have multiple pipelines.
|
# Manifold pipelines can have multiple pipelines.
|
||||||
@ -13,11 +14,11 @@ class Pipeline:
|
|||||||
self.pipelines = [
|
self.pipelines = [
|
||||||
{
|
{
|
||||||
"id": "pipeline-1", # This will turn into `manifold_pipeline.pipeline-1`
|
"id": "pipeline-1", # This will turn into `manifold_pipeline.pipeline-1`
|
||||||
"name": "Manifold: Pipeline 1",
|
"name": "Pipeline 1", # This will turn into `Manifold: Pipeline 1`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "pipeline-2",
|
"id": "pipeline-2",
|
||||||
"name": "Manifold: Pipeline 2",
|
"name": "Pipeline 2",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
pass
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user