google / mesop

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

Better default markdown support #665

Open adriens opened 1 month ago

adriens commented 1 month ago

:grey_question: About

I use mesop to interact with an AI Agent API that is able to reply complex markdown... with lists and sub-items... but when display its answers I got sub-item appearing at the wrong level :

image

In other words, sections are messed-up and all go to the same level

:pray: Feature request

Make mesop better handle list and sublists.

For now, the only workaround I foud is to asj my agent to reply in markdown in raw format... causing the final display to be right but properly displayed (I have to copy/paste it into any markdown previewer to enjoy it).

richard-to commented 1 month ago

Thanks for pointing that out. As an experiment I've been thinking of creating a web component that renders markdown on the client side, which I think could improve https://github.com/google/mesop/issues/591.

So first I want to try it as a web component to see if it works. And if it does work, I think we could update the core markdown component to also render markdown on the front end.

So it's possible using the markdown web component could render the markdown better.


On the other hand, it is strange that the markdown is not being rendered correctly for you, especially a simple thing like nested lists. I'll see if I can reproduce it.

Do you have an example output for testing?

richard-to commented 1 month ago

Yeah I can confirm that the sub list is not working. This can be seen also in the demo gallary for the markdown example. The sublist is not indented.

It looks like a rendering issue since it gets rendered a one level list and not nested.

richard-to commented 1 month ago

So looks like the reason is the markdown module we're using requires four space indention. See https://github.com/Python-Markdown/markdown/issues/1378

This is expected behavior for this module.


I'd agree that this isn't ideal. As a workaround is it possible to tell the agent to render the sublist with four spaces?

adriens commented 1 month ago

I'd agree that this isn't ideal. As a workaround is it possible to tell the agent to render the sublist with four spaces?

In my case, I asked my agent to generate a markdown so I can put it in Github issue... and let him do the job.

richard-to commented 3 weeks ago

We're planning to update the markdown object to render using javascript instead of python. This has the side effect of allowing two spaces for nested lists.

adriens commented 3 weeks ago

great news ! We did a demo yesterday and enjoyed a lot the Dark theme toggle btw. I made an internal issue to force markdown output... so we'll wait for the next release.

Thanks for the very cool feedback and the resulting devex 🙏

adriens commented 3 weeks ago

here is the yesterday pari-programming session :

richard-to commented 3 weeks ago

Just for clarification, we haven't finished the implementation yet for the markdown rendering change. I'll probably start on that this week. And in reference to #816, we should have a copy and paste button.

adriens commented 3 weeks ago

I'll probably start on that this week

No rush, no pressure 🙏