diff --git a/main.py b/main.py index ba751a2..d85e125 100644 --- a/main.py +++ b/main.py @@ -47,10 +47,15 @@ def on_startup(): if hasattr(pipeline, "manifold") and pipeline.manifold: for p in pipeline.pipelines: 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] = { "module": pipeline, "id": manifold_pipeline_id, - "name": p["name"], + "name": manifold_pipeline_name, "manifold": True, } else: diff --git a/pipelines/examples/manifold_pipeline.py b/pipelines/examples/manifold_pipeline.py index b5d141c..c1d6934 100644 --- a/pipelines/examples/manifold_pipeline.py +++ b/pipelines/examples/manifold_pipeline.py @@ -5,7 +5,8 @@ from schemas import OpenAIChatMessage class Pipeline: def __init__(self): 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. # Set manifold to True if you want to use this pipeline as a manifold. # Manifold pipelines can have multiple pipelines. @@ -13,11 +14,11 @@ class Pipeline: self.pipelines = [ { "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", - "name": "Manifold: Pipeline 2", + "name": "Pipeline 2", }, ] pass diff --git a/pipelines/examples/ollama_manifold_pipeline.py b/pipelines/examples/ollama_manifold_pipeline.py new file mode 100644 index 0000000..b5d141c --- /dev/null +++ b/pipelines/examples/ollama_manifold_pipeline.py @@ -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}" diff --git a/pipelines/manifold_pipeline.py b/pipelines/manifold_pipeline.py index b5d141c..c1d6934 100644 --- a/pipelines/manifold_pipeline.py +++ b/pipelines/manifold_pipeline.py @@ -5,7 +5,8 @@ from schemas import OpenAIChatMessage class Pipeline: def __init__(self): 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. # Set manifold to True if you want to use this pipeline as a manifold. # Manifold pipelines can have multiple pipelines. @@ -13,11 +14,11 @@ class Pipeline: self.pipelines = [ { "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", - "name": "Manifold: Pipeline 2", + "name": "Pipeline 2", }, ] pass