How to execute code that was generated by the solara chatbot?

I was already able to extract the code block that was returned from the chat interface. Now I want to execute that code and show the result in a solara component. Is there an easy way to directly execute this new code? Thanks for any advice on this!
No description
7 Replies
Jan-Hendrik Müller
for reference, here's my notebook
Jan-Hendrik Müller
oh no, there also seems to be an issue with the formating in the chatbot when it comes to code blocks.
No description
Jan-Hendrik Müller
intersting, now I tried it again, and cannot reproduce this bug. Maybe a ChatGPT mistake OK, solved it myself like this:
MaartenBreddels
MaartenBreddels3mo ago
Whow, nice 🙂 Will you let it re-write its own app? or you can write to gen.py, run import gen and call gen.Page() (and to remove it, use del sys.modules['gen']
Jan-Hendrik Müller
I'll soon share more about my idea! 🙂 thanks for this idea! ahhh, solara markdown supports images, that's amazing!
import solara

# Define the Markdown content with the base64 image
markdown_content = """
**Hello**

![example](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==)
"""

# Solara app component
@solara.component
def Page():
solara.Markdown(markdown_content)

# Run the app
Page()
import solara

# Define the Markdown content with the base64 image
markdown_content = """
**Hello**

![example](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==)
"""

# Solara app component
@solara.component
def Page():
solara.Markdown(markdown_content)

# Run the app
Page()
Want results from more Discord servers?
Add your server