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
32.41k stars 2.42k forks source link

chore: update versions #8458

Closed pngwn closed 3 months ago

pngwn commented 3 months ago

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

Releases

@gradio/client@1.0.0

Highlights

Clients 1.0 Launch! (#8468 7cc0a0c)

We're excited to unveil the first major release of the Gradio clients. We've made it even easier to turn any Gradio application into a production endpoint thanks to the clients' ergonomic, transparent, and portable design.

Ergonomic API πŸ’†

Stream From a Gradio app in 5 lines

Use the submit method to get a job you can iterate over:

from gradio_client import Client

client = Client("gradio/llm_stream")

for result in client.submit("What's the best UI framework in Python?"):
    print(result)
import { Client } from "@gradio/client";

const client = await Client.connect("gradio/llm_stream")
const job = client.submit("/predict", {"text": "What's the best UI framework in Python?"})

for await (const msg of job) console.log(msg.data)

Use the same keyword arguments as the app

from gradio_client import Client

client = Client("http://127.0.0.1:7860/")
result = client.predict(
        message="Hello!!",
        system_prompt="You are helpful AI.",
        tokens=10,
        api_name="/chat"
)
print(result)
import { Client } from "@gradio/client";

const client = await Client.connect("http://127.0.0.1:7860/");
const result = await client.predict("/chat", {      
        message: "Hello!!",         
        system_prompt: "Hello!!",       
        tokens: 10, 
});

console.log(result.data);

Better Error Messages

If something goes wrong in the upstream app, the client will raise the same exception as the app provided that show_error=True in the original app's launch() function, or it's a gr.Error exception.

Transparent Design πŸͺŸ

Anything you can do in the UI, you can do with the client:

Here's an example showing how to display the queue position of a pending job:

from gradio_client import Client

client = Client("gradio/diffusion_model")

job = client.submit("A cute cat")
while not job.done():
    status = job.status()
    print(f"Current in position {status.rank} out of {status.queue_size}")

Portable Design ⛺️

The client can run from pretty much any python and javascript environment (node, deno, the browser, Service Workers).

Here's an example using the client from a Flask server using gevent:

from gevent import monkey
monkey.patch_all()

from gradio_client import Client
from flask import Flask, send_file
import time

app = Flask(__name__)

imageclient = Client("gradio/diffusion_model")

@app.route("/gen")
def gen():
      result = imageclient.predict(
                "A cute cat",
                api_name="/predict"
              )
      return send_file(result)

if __name__ == "__main__":
      app.run(host="0.0.0.0", port=5000)

1.0 Migration Guide and Breaking Changes

Python

from gradio_client import Client, handle_file

client = Client("gradio/image_captioner")
client.predict(handle_file("cute_cat.jpg"))

Javascript The client has been redesigned entirely. It was refactored from a function into a class. An instance can now be constructed by awaiting the connect method.

const app = await Client.connect("gradio/whisper")

The app variable has the same methods as the python class (submit, predict, view_api, duplicate).

Additional Changes

Features

Fixes

gradio_client@1.0.0

Highlights

Clients 1.0 Launch! (#8468 7cc0a0c)

We're excited to unveil the first major release of the Gradio clients. We've made it even easier to turn any Gradio application into a production endpoint thanks to the clients' ergonomic, transparent, and portable design.

Ergonomic API πŸ’†

Stream From a Gradio app in 5 lines

Use the submit method to get a job you can iterate over:

from gradio_client import Client

client = Client("gradio/llm_stream")

for result in client.submit("What's the best UI framework in Python?"):
    print(result)
import { Client } from "@gradio/client";

const client = await Client.connect("gradio/llm_stream")
const job = client.submit("/predict", {"text": "What's the best UI framework in Python?"})

for await (const msg of job) console.log(msg.data)

Use the same keyword arguments as the app

from gradio_client import Client

client = Client("http://127.0.0.1:7860/")
result = client.predict(
        message="Hello!!",
        system_prompt="You are helpful AI.",
        tokens=10,
        api_name="/chat"
)
print(result)
import { Client } from "@gradio/client";

const client = await Client.connect("http://127.0.0.1:7860/");
const result = await client.predict("/chat", {      
        message: "Hello!!",         
        system_prompt: "Hello!!",       
        tokens: 10, 
});

console.log(result.data);

Better Error Messages

If something goes wrong in the upstream app, the client will raise the same exception as the app provided that show_error=True in the original app's launch() function, or it's a gr.Error exception.

Transparent Design πŸͺŸ

Anything you can do in the UI, you can do with the client:

Here's an example showing how to display the queue position of a pending job:

from gradio_client import Client

client = Client("gradio/diffusion_model")

job = client.submit("A cute cat")
while not job.done():
    status = job.status()
    print(f"Current in position {status.rank} out of {status.queue_size}")

Portable Design ⛺️

The client can run from pretty much any python and javascript environment (node, deno, the browser, Service Workers).

Here's an example using the client from a Flask server using gevent:

from gevent import monkey
monkey.patch_all()

from gradio_client import Client
from flask import Flask, send_file
import time

app = Flask(__name__)

imageclient = Client("gradio/diffusion_model")

@app.route("/gen")
def gen():
      result = imageclient.predict(
                "A cute cat",
                api_name="/predict"
              )
      return send_file(result)

if __name__ == "__main__":
      app.run(host="0.0.0.0", port=5000)

1.0 Migration Guide and Breaking Changes

Python

from gradio_client import Client, handle_file

client = Client("gradio/image_captioner")
client.predict(handle_file("cute_cat.jpg"))

Javascript The client has been redesigned entirely. It was refactored from a function into a class. An instance can now be constructed by awaiting the connect method.

const app = await Client.connect("gradio/whisper")

The app variable has the same methods as the python class (submit, predict, view_api, duplicate).

Additional Changes

Features

gradio@4.34.0

Features

Fixes

@gradio/audio@0.11.8

Dependency updates

@gradio/button@0.2.41

Dependency updates

@gradio/chatbot@0.10.9

Dependency updates

@gradio/code@0.6.9

Dependency updates

@gradio/dataframe@0.8.8

Dependency updates

@gradio/dataset@0.1.41

Dependency updates

@gradio/downloadbutton@0.1.18

Dependency updates

@gradio/file@0.8.0

Features

Fixes

Dependency updates

@gradio/gallery@0.10.8

Dependency updates

@gradio/image@0.11.8

Dependency updates

@gradio/imageeditor@0.7.8

Dependency updates

@gradio/lite@4.34.0

Dependency updates

@gradio/model3d@0.10.8

Dependency updates

@gradio/multimodaltextbox@0.4.9

Dependency updates

@gradio/preview@0.9.1

Fixes

@gradio/simpleimage@0.5.8

Dependency updates

@gradio/tootils@0.5.0

Features

Dependency updates

@gradio/upload@0.11.0

Features

Dependency updates

@gradio/uploadbutton@0.6.9

Dependency updates

@gradio/video@0.8.8

Dependency updates

website@0.31.3

Features

Dependency updates

@gradio/annotatedimage@0.6.8

Dependency updates

@gradio/app@1.36.0

Features

Fixes

Dependency updates

@gradio/fileexplorer@0.4.9

Dependency updates

gradio-pr-bot commented 3 months ago

πŸͺΌ branch checks and previews

β€’ Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook building...
:unicorn: Changes skipped! Workflow log

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/0fdfb9856e3fdd98e3e8a439b5b9f42b95e32d9d/gradio-4.33.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@0fdfb9856e3fdd98e3e8a439b5b9f42b95e32d9d#subdirectory=client/python"

Install Gradio JS Client from this PR

npm install https://gradio-builds.s3.amazonaws.com/0fdfb9856e3fdd98e3e8a439b5b9f42b95e32d9d/gradio-client-1.0.0.tgz