diff --git a/main.py b/main.py index 952ffe4..3b95936 100644 --- a/main.py +++ b/main.py @@ -470,10 +470,7 @@ async def update_valves(pipeline_id: str, form_data: dict): @app.post("/v1/{pipeline_id}/filter/inlet") @app.post("/{pipeline_id}/filter/inlet") async def filter_inlet(pipeline_id: str, form_data: FilterForm): - if ( - pipeline_id not in app.state.PIPELINES - or app.state.PIPELINES[pipeline_id].get("type", "pipe") != "filter" - ): + if pipeline_id not in app.state.PIPELINES: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail=f"Filter {pipeline_id} not found", @@ -498,10 +495,7 @@ async def filter_inlet(pipeline_id: str, form_data: FilterForm): @app.post("/v1/{pipeline_id}/filter/outlet") @app.post("/{pipeline_id}/filter/outlet") async def filter_outlet(pipeline_id: str, form_data: FilterForm): - if ( - pipeline_id not in app.state.PIPELINES - or app.state.PIPELINES[pipeline_id].get("type", "pipe") != "filter" - ): + if pipeline_id not in app.state.PIPELINES: raise HTTPException( status_code=status.HTTP_404_NOT_FOUND, detail=f"Filter {pipeline_id} not found", diff --git a/pipelines/examples/example_pipeline.py b/pipelines/examples/example_pipeline.py index e1a4cfc..b7cec2f 100644 --- a/pipelines/examples/example_pipeline.py +++ b/pipelines/examples/example_pipeline.py @@ -9,8 +9,8 @@ class Pipeline: # The identifier must be unique across all pipelines. # The identifier must be an alphanumeric string that can include underscores or hyphens. It cannot contain spaces, special characters, slashes, or backslashes. self.id = "pipeline_example" - self.name = "Pipeline Example" + pass async def on_startup(self): @@ -23,6 +23,29 @@ class Pipeline: print(f"on_shutdown:{__name__}") pass + async def on_valves_updated(self): + # This function is called when the valves are updated. + pass + + async def inlet(self, body: dict, user: dict) -> dict: + # This function is called before the OpenAI API request is made. You can modify the form data before it is sent to the OpenAI API. + print(f"inlet:{__name__}") + + print(body) + print(user) + + return body + + async def outlet(self, body: dict, user: dict) -> dict: + # This function is called after the OpenAI API response is completed. You can modify the messages after they are received from the OpenAI API. + + print(f"outlet:{__name__}") + + print(body) + print(user) + + return body + def pipe( self, user_message: str, model_id: str, messages: List[dict], body: dict ) -> Union[str, Generator, Iterator]: