google / mesop

Rapidly build AI apps in Python
https://google.github.io/mesop/
Apache License 2.0
5.36k stars 258 forks source link

Copy markdown or copy rich text #923

Open simonff opened 3 weeks ago

simonff commented 3 weeks ago

When an LLM generated markdown code (with bold text, lists, tables, etc), it's correctly rendered in mesop. But if I copy it, I get plain text with formatting lost.

It would be great to have the option to copy either the source markdown or the correct rich text. Or maybe to at least disable markdown rendering.

richard-to commented 3 weeks ago

Yes, we're planning to add a copy button (https://github.com/google/mesop/issues/275). That's next up on my todo list.

richard-to commented 3 weeks ago

Actually, I forgot the copy button is for the code snippets specifically and not the whole output.

To copy the whole output, the best option right now is a web component. Example here: https://github.com/google/mesop/tree/main/mesop/examples/web_component/copy_to_clipboard

The nice thing about this approach is that it allows you to place the copy button where you want it. Will need some adjustments for downstream usage though.