Server route
I need to somehow change the state depending on the behavior of the external service, I think I need some server route to accept the data, what is the best way to do it?
13 Replies
Do you mean a FastAPI endpoint that sets the state of for instance a reactive variable? Could you share the specific use case, that might be interesting for us to hear, and also to better understand what you need.
@MaartenBreddels Yes that's right, I do vscode extension, the application on solara runs as an iframe in webview. I need to pass data from vscode extension(js) to reactive variable
I do not want to use hard way - pass data to web view, from web view to iFrame with solara, from solara vue to Python using cv
Interesting, will this be a public vscode extension?
Can we assume 1 virtual kernel (so 1 connected tab)?
Yes for both questions, it is open source playground for HSL DSL https://hackmd.io/@hslang/hsl 1 user and 1 instance at one point in time
HackMD
Human Software Language (HSL) - HackMD
HSL introduces a new level of abstraction in programming, seamlessly merging human language with code via advanced Language Models (LLMs) and intuitive markdown syntax. This approach effortlessly transforms ideas into powerful software, eliminating complex syntax and steep learning curves. HSL streamlines development across various platforms, m...
I started here, I create the following (endpoint.py):
And app.py:
Run it as
SOLARA_APP=app uvicorn endpoint:app
and reset the counter using curl http://127.0.0.1:8000/_extra/reset
hope that helps, please share with us the end result!Your example works perfectly, but why don’t mine ? In the debugger all looks perfect, variable changed, but inside UI I see old values. Also, printing a variable after changing it works somehow strangely.
Source code: https://hackmd.io/@Oe9F3Sh9QpG8wuiS3v99Bg/Bys1sM_bR
403 Forbidden - I don't have permission to see that hackmd
Access fixed
Do you mean that
this piece makes it work? or it still doesn't work?
That one works when the ‘a’ value changes based on the chat response, but not from the endpoint. I see logs with correct values from the endpoint and can set up breakpoints to see correct values. However, at the UI, I see old values; it looks like reactivity isn’t working as expected
I would go from the working example I gave, and gradually work towards your example. I also don't see why your version doesn't work. Let me know when you solve it, really curious what it is, since I also don't see it.
I have been working on this using Fastapi for a project I'm building. I did get an identical result to what MindsightsAI saw if SOLARA_APP=app.py is used instead of SOLARA_APP=app.
Ah, yes, make sure you run as module/package, otherwise app.py is a different namespace . This is similar to ‘python app.py’ and ‘python -m app’