open-webui / pipelines

Pipelines: Versatile, UI-Agnostic OpenAI-Compatible Plugin Framework
MIT License
931 stars 297 forks source link

Feature Request: Add file upload functionality #232

Closed InquestGeronimo closed 2 months ago

InquestGeronimo commented 2 months ago

Hi it would be great if we could have the ability to pass a file object to a custom pipeline for document understanding/summarization.

tjbck commented 2 months ago

You should be able to hijack files item in the payload from inlet.

InquestGeronimo commented 2 months ago

@tjbck can you point me in the right direction, is the inlet in the pipe function? I currently only know of these 4 variables: user_message, model_id, messages, body. When I print these variables I don't see any data relating to file uploads.

InquestGeronimo commented 2 months ago

nevermind, i found it, I have to add an inlet function:

    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