Gradio Profile picture
Build and share machine learning apps in 3 lines of Python. Part of the @Huggingface family πŸ€—. DMs are open for sharing your gradio app with us!

Jul 17, 2023, 7 tweets

BIG NEWS πŸ₯³πŸŽˆ

Building Chatbots apps just got wayyy easier: announcing the new π™²πš‘πšŠπšπ™Έπš—πšπšŽπš›πšπšŠπšŒπšŽ class πŸ™Œ

The *fastest* way to build to build a Chatbot UI in Python -- including streaming, undo/retry, API, all out of the box!

Let's take a look at a few examples...

The π™²πš‘πšŠπšπ™Έπš—πšπšŽπš›πšπšŠπšŒπšŽ only has 1 required parameter: a function that takes in:

- an input message (string)
- a history (list of list of strings)

and returns:
- a response (string)

Here's a toy example: (for the example above!)

The π™²πš‘πšŠπšπ™Έπš—πšπšŽπš›πšπšŠπšŒπšŽ class works beautifully with @langchain classes

Here's a complete example querying GPT3.5 in 19 lines of code

To add streaming, just use a generator (πš’πš’πšŽπš•πš) instead of a regular function (πš›πšŽπšπšžπš›πš—)

Of course, you can customize it a lot more by adding examples, title/description, buttons (but you can get a fully-functioning chatbot without any of these!)

You also get a dedicated, easy-to-use API endpoint:

/πšŒπš‘πšŠπš

Out in the latest version of gradio:

πš™πš’πš™ πš’πš—πšœπšπšŠπš•πš• --πšžπš™πšπš›πšŠπšπšŽ πšπš›πšŠπšπš’πš˜

Read more here: gradio.app/guides/creatin…

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling