Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gr.Chatbot cannot use gr.Markdown / gr.DataFrame while showing the results #8657

Open
sglbl opened this issue Jun 28, 2024 · 5 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@sglbl
Copy link

sglbl commented Jun 28, 2024

  • [y] I have searched to see if a similar issue already exists.

Is your feature request related to a problem? Please describe.
I want to use gr.DataFrame in output of chatbot.

Describe the solution you'd like
Show the result of gr.DataFrame as a table inside chatbot result.

Additional context
gradio.__version__: '4.37.1'
Code:

import gradio as gr
import time

def html_works():
   history = []
   history.append(["",None])
   text_to_show_in_chatbot = '**testing** normal md <br> <table border="1" style="width:100%"><tr><th>Label</th><th>Value</th></tr><tr><th>x</th><th>y</th></tr>'
   response = [(text_to_show_in_chatbot, None)]

   for letter in response[0][0]:
      history[-1][0] += letter
      time.sleep(0.01)
      yield history
   
   return response

def dataframe_does_not_work():
   history = []
   history.append(["",None])
   df_to_show_in_chatbot = gr.DataFrame( # gr.Markdown neither work
                              headers=["name", "age", "gender"],
                              datatype=["str", "number", "str"],
                              col_count=(3, "fixed"),
                              type='array' 
                              ## returning as an array / list of lists also okay, I can convert it to normal markdown but I also don't get any output as a list
                           )
   print(f'{type(df_to_show_in_chatbot) = }')
   response = [(df_to_show_in_chatbot, None)]
   
   for letter in response[0][0]:
      history[-1][0] += letter
      time.sleep(0.01)
      yield history
   
   return response

with gr.Blocks() as demo:
   button = gr.Button()
   chatbot = gr.Chatbot(render_markdown=True)
   # button.click(html_works, outputs = chatbot)   
   button.click(dataframe_does_not_work, outputs = chatbot)   
   
demo.queue(default_concurrency_limit=None)
demo.launch()
@abidlabs
Copy link
Member

I believe gr.Markdown is supported but gr.DataFrame is not supported. @dawoodkhan82 can you confirm? Also we should have a helpful error if an unsupported component is used in the output.

@abidlabs abidlabs added the enhancement New feature or request label Jun 28, 2024
@sglbl
Copy link
Author

sglbl commented Jun 28, 2024

I believe gr.Markdown is supported but gr.DataFrame is not supported. @dawoodkhan82 can you confirm? Also we should have a helpful error if an unsupported component is used in the output.

I get TypeError: 'Markdown' object is not iterable

@dawoodkhan82
Copy link
Collaborator

@sglbl @abidlabs as of now "gallery" | "plot" | "audio" | "video" | "image" | html are supported components in the chatbot. there's already progress on adding other components which will be supported soon. markdown and dataframe are on that list.

@dawoodkhan82
Copy link
Collaborator

Also we should have a helpful error if an unsupported component is used in the output.

I think we already have this, must not be working as expected.

@pngwn
Copy link
Member

pngwn commented Jul 8, 2024

gr.Markdown does not work but all text is treated as markdown and should be parsed appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants