gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
31k stars 2.31k forks source link

Automatically create a LLM plugin from a gradio app #4925

Open freddyaboulton opened 1 year ago

freddyaboulton commented 1 year ago

Is your feature request related to a problem? Please describe.
The gradio-tools library showed that there is interest in using gradio apps as tools for LLMs. I'd like to take one of the experiments I was working on in that library and bring it to the gradio_client library to maximize usage and impact: automatically creating LLM plugins from gradio apps.

My proposal is the following:

Add a deploy_plugin method from a gradio_client.Client instance with the following signature:

    def deploy_plugin(self,
        api_names: List[str],
        org_name: str | None = None,
        version: str = "v1",
        hf_token: str | None = None,
        private: bool = True,
        email: str | None = None,
        llm: Literal["chatgpt"] = "chatgpt"):

Note: email is needed by ChatGPT plugins.

Under the hood - this will create a new space that serves the necessary metadata needed for ChatGPT to recognize the space as a ChatGPT plugin. Right now I'm mentioning ChatGPT because that's the LLM with the most mature plugin ecosystem that I know of but it should be possible to support other LLMs (e.g. huggingchat when they allow plugins). The llm argument will make that configuration possible.

Then users can do the following once there is a space they want to deploy as a plugin:

client = grc.Client("freddyaboulton/video-creator")
client.deploy_plugin(api_names=['/generate'], private=False)

We can even make this a configuration parameter to gradio deploy, e.g.

gradio deploy-plugin freddyaboulton/video-creator --api-names generate  --private false

The benefits of doing this approach:

abidlabs commented 1 year ago

This is awesome, I'm a big fan of the duplication + deployment approach -- we can use the same approach to deploying Gradio apps to other platforms as well.

    def deploy_discord(self,
        api_names: List[str],
        discord_token: str
        org_name: str | None = None,
        version: str = "v1",
        hf_token: str | None = None,
        private: bool = True):

and

gradio deploy-discord freddyaboulton/chat