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
30.77k stars 2.29k forks source link

Allow `gr.Chatbot` to accept messages in the openai format #7118

Open abidlabs opened 5 months ago

abidlabs commented 5 months ago

The openai spec for chatbots has become the standard for llms, we should support messages in that format (which is essentially a list of dictionaries) for the gr.Chatbot.

abidlabs commented 5 months ago

I realized that this is actually not as advantageous as I thought. The main bottleneck when using gr.ChatInterface is that the history needs to be converted from the format it is stored by the gr.Chatbot to a format that is acceptable by openai/langchain. We could make the switch but then we'd be pretty vendor-specific and it would not be backwards-compatible.

See code examples here: https://www.gradio.app/guides/creating-a-chatbot-fast#a-langchain-example

Let's close this issue as I don't see a way to do a closer integration in a backwards-compatible way.

abidlabs commented 2 months ago

Reopening to see if there's any way we could support both: cc @dawoodkhan82 @pngwn