feat: manifold naming

This commit is contained in:
Timothy J. Baek 2024-05-26 16:12:01 -07:00
parent 29e3ba4c4d
commit 918b709f30
4 changed files with 59 additions and 7 deletions

View File

@ -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:

View File

@ -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

View 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}"

View File

@ -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