Alonso Silva
Alonso Silva
SSolara
Created by Alonso Silva on 4/23/2024 in #questions-issues
Extract the value from an ipywidget
Hi all! I want to extract the value from an ipywidget but the values between the Solara app and the ipywidget do not coincide (I need to keep pressing the slider for a long time before they both agree). Here is the code I have:
import solara
import ipywidgets as widgets

aux = solara.reactive(0)
@solara.component
def Page():
slider = widgets.IntSlider()
output = widgets.Output()
display(slider, output)
def on_value_change(change):
with output:
aux.value = change["new"]
slider.observe(on_value_change, names='value')
solara.Markdown(f"{aux.value}")
import solara
import ipywidgets as widgets

aux = solara.reactive(0)
@solara.component
def Page():
slider = widgets.IntSlider()
output = widgets.Output()
display(slider, output)
def on_value_change(change):
with output:
aux.value = change["new"]
slider.observe(on_value_change, names='value')
solara.Markdown(f"{aux.value}")
Or you can check it here: https://app.py.cafe/snippet/solara/v1?c=H4sIAEmrJ2YAA11RTUvEMBD9KyGX7UIpngsLXjx4EAXBi5FltpnuBtNJTNKtZfG_O21TKc4lycub9-bjJhunUdbSdN6FJKKzEEBRfho_DkafMUUBUeSrIkXQf4tDZlcBoUnmisXdXtF9BhvHEoSUFGlsxQucsdjXigRHtEZjYIGsWD1Sep2xghUmhuuT79OG8TwD67c20VsYi0WozPT1k-0cHa9gezw2FyB2Xo7Vf4rBpEvO26BTcG_VnMz2S967koSDkh_b8it3ihi4639epSDoMB52M7jLReWpPEH41G6golXy9mf0oyTTZCkDfvUmYMdji7yUGUujnxa0CPAbvH8zOMi6BRuxlKhNeiA4WWalwGK_NO9QjNQBAAA I know I could do it with the solara.SliderInt() component or through an ipywidget application but I want to see if we can do it without those solutions...
6 replies
SSolara
Created by Alonso Silva on 4/18/2024 in #questions-issues
Quarto Solara compatibility
I'm writing a tutorial to build LLM chat apps with Solara: https://alonsosilvaallende.github.io/blog/posts/2024-04-11-Build_a_basic_LLM_chat_app_with_Solara.html In my blog, I use Quarto, however there is some compatibility which might be simple or difficult to solve (I don't know). I expect the cells output of jupyter notebooks to appear directly in Quarto (see for example the first two cells in this blog entry): https://alonsosilvaallende.github.io/blog/posts/2024-04-18-Quarto-Solara-Test.html However, the cells of Solara components don't appear directly in Quarto (see for example the third cell): https://alonsosilvaallende.github.io/blog/posts/2024-04-18-Quarto-Solara-Test.html I thought it might have to do with the widget state and perhaps there is something there because when I save the widget state there appears a lot of text in Quarto: "...{"model_module":"jupyter-vuetify","model_module_version":"^1.8.10","model_name":"ThemeColorsModel","state":{"_model_module_version":"^1.8.10","_theme_name":"dark","_view_module":null,"_view_module_version":"^1.8.10","accent":"#FF4081","error":"#FF5252","info":"#2196F3","primary":"#2196F3","secondary":"#424242","success":"#4CAF50","warning":"#FB8C00"}},"8f96225f9fab4c2d9f305a1b44078c4e" ...etc.... Do you know if there is a way to display a simple Solara component output as an image or something similar in Quarto?
1 replies
SSolara
Created by Alonso Silva on 4/11/2024 in #questions-issues
Streaming partial extraction
I want to replicate this streaming partial extraction: https://x.com/jxnlco/status/1755723172228350056 The basic idea is to use an LLM to extract some particular information (for example, name, e-mail and twitter login) from a text. I think I'm able to do it inside the solara chatbot example. That is, I send a message (which will not be displayed) just to activate the extraction and then I will stream the response within the solara.lab.ChatBox. I don't like this solution because ideally I would like to activate the extraction with a button, not with solara.lab.ChatInput. Any hint about how to accomplish this?
8 replies