From 97528e27243cdd607a868a4384344eb5f4006ceb Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 21 May 2024 20:01:08 -0700 Subject: [PATCH] feat: custom id, name support --- main.py | 4 ++-- pipelines/examples/openai_pipeline.py | 3 +++ pipelines/examples/pipeline_example.py | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index d0d5b58..f022817 100644 --- a/main.py +++ b/main.py @@ -43,8 +43,8 @@ for loaded_module in load_modules_from_directory("./pipelines"): PIPELINES[loaded_module.__name__] = { "module": pipeline, - "id": loaded_module.__name__, - "name": loaded_module.__name__, + "id": pipeline.id if hasattr(pipeline, "id") else loaded_module.__name__, + "name": pipeline.name if hasattr(pipeline, "name") else loaded_module.__name__, } diff --git a/pipelines/examples/openai_pipeline.py b/pipelines/examples/openai_pipeline.py index 416fdcd..79c650b 100644 --- a/pipelines/examples/openai_pipeline.py +++ b/pipelines/examples/openai_pipeline.py @@ -5,6 +5,9 @@ import requests class Pipeline: def __init__(self): + # Optionally, you can set the id and name of the pipeline. + self.id = "openai_pipeline" + self.name = "OpenAI Pipeline" pass async def on_startup(self): diff --git a/pipelines/examples/pipeline_example.py b/pipelines/examples/pipeline_example.py index a6fd00f..a0d1f95 100644 --- a/pipelines/examples/pipeline_example.py +++ b/pipelines/examples/pipeline_example.py @@ -4,6 +4,9 @@ from schemas import OpenAIChatMessage class Pipeline: def __init__(self): + # Optionally, you can set the id and name of the pipeline. + self.id = "pipeline_example" + self.name = "Pipeline Example" pass async def on_startup(self):