Skip to content

POST /pipeline.{id}/filter/inlet not found #543

@ennioferreirab

Description

@ennioferreirab

I don’t know what’s going on. Even with a simple example, the pipeline API is adding the prefix “pipeline.” before the endpoint and returning a 404 Not Found error. What am I missing? Testing Swagger endpoint /inlet_events_pipeline/filter/inlet It works when put the right name "inlet_events_pipeline" .


from typing import List, Union, Generator, Iterator, Optional
from pprint import pprint
import time

# Uncomment to disable SSL verification warnings if needed.
# warnings.filterwarnings('ignore', message='Unverified HTTPS request')


class Pipeline:
    def __init__(self):
        self.pipeline_id = "inlet_events_pipeline"
        self.id = "inlet_events_pipeline"
        self.name = "Pipeline with Status Event"
        self.description = (
            "This is a pipeline that demonstrates how to use the status event."
        )
        self.debug = False
        self.version = "0.1.0"
        self.author = "Anthony Durussel"

        self.inlet_count = 0
        self.pipe_count = 0

    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 shutdown.
        print(f"on_shutdown: {__name__}")
        pass

    async def inlet(self, body: dict, user: Optional[dict] = None) -> 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.
        """
        self.inlet_count += 1
        print()
        print(f"inlet {self.inlet_count}: {__name__}")
        print()
        if self.debug:
            print(f"inlet: {__name__} - body:")
            pprint(body)
            print(f"inlet: {__name__} - user:")
            pprint(user)
        return body

    async def outlet(self, body: dict, user: Optional[dict] = None) -> 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()
        print(f"outlet: {__name__}")
        print()
        if self.debug:
            print(f"outlet: {__name__} - body:")
            pprint(body)
            print(f"outlet: {__name__} - user:")
            pprint(user)
        return body

    def pipe(
        self,
        user_message: str,
        model_id: str,
        messages: List[dict],
        body: dict,
    ) -> Union[str, Generator, Iterator]:
        self.pipe_count += 1
        print()
        print(f"pipe {self.pipe_count}: {__name__}")
        print()

        if self.debug:
            print(f"pipe: {__name__} - received message from user: {user_message}")
            print(f"pipe: {__name__} - messages:")
            pprint(messages)
            print(f"pipe: {__name__} - body:")
            pprint(body)

        yield {
            "event": {
                "type": "status",
                "data": {
                    "description": "Fake Status",
                    "done": False,
                },
            }
        }

        time.sleep(0.5)  # Sleep for 5 seconds

        yield f"user_message -- {user_message}"

        yield {
            "event": {
                "type": "status",
                "data": {
                    "description": "",
                    "done": True,
                },
            }
        }

INFO: 172.18.0.3:49672 - "POST /pipeline.inlet_events_pipeline/filter/inlet HTTP/1.1" 404 Not Found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions