0

I have created a chatbot using gpt3.5 and gradio, I have referred this for creating it. So my UI is similar to ChatGpt.

I am able to respond to user queries with text output, but unable to respond with images, while maintaining chat history.

Below is my code structure, for some reason, I won't be able to add my complete code, but adding enough to give an idea about it

def my_chatbot(question,chat_history):
    # Here it calls the OpenAI API, gets some data, and then sends that data to a function that generates a plot, saves it as an image(xyz.png), and returns the filename
    chat_history.append((question,img_filename))
    return "",chat_history
    



with gr.Blocks() as demo:
    chatbot = gr.Chatbot()
    msg = gr.Textbox()
    clear = gr.ClearButton([msg, chatbot])
    msg.submit(my_chatbot, [msg, chatbot],[gr.Image(type="filepath"),chatbot])

demo.launch()

Now when I run this code and write a query on gradio UI, the bot responds with the name of the image file (xyz.png), But I want it to respond with an image (Display the image on UI).

What do I have to do to achieve this? I am relatively new to gradio so have been stuck for the last three days.

Any help would be appreciated, thanks.

user18148705
  • 215
  • 1
  • 11

0 Answers0