Closed figoyouwei closed 3 months ago
You can use asynchronous callbacks. These callbacks allow you to not block your UI when your application performs a heavy task.
Here is some documentation for it: https://docs.taipy.io/en/develop/tutorials/visuals/4_long_callbacks/
This allows you to perform a heavy task and regularly update your app. You can use a progress visual element to give feedback to your end users or notifications.
I don't know if this answers your question.
let's do it one by one, first the progress, could you add some code in the "on_filter" function, so that it works? https://github.com/figoyouwei/taipy_success/blob/main/apps/enterpriser/main.py
Add a progress visual element where you cant inside your page:
render_progress = False
progress_value = None
...
tgb.progress("{progress_value }", render="{render_progress}")
...
When you want this progress to appear, you can just put render_progress to True. So, in your on_filter:
def on_filter(state):
...
state.render_progress = True
You might need asynchronous callbacks, but we'll see later.
how come it returns this error... AttributeError: module 'taipy.gui.builder' has no attribute 'progress' Please check the latest commit.
This is inside the 4.0 release as well as the chat visual element.
Having a progress visual element is not compulsory. It may be better to stay on 3.1 for now
ok, forget the progress element for now, is there an easy to visualize listed items?
How would you want them to visualize them? You should just create a function that makes it a string or int or anything handled by Taipy
For the first step: just loop over a List and render the content with tgb.text would be ok, code would look like: facts = ['apple', 'banana', 'cherry'] for index, fact in enumerate(facts): tgb.text(f"{index}: {fact}", mode="md")
Obviously, this code doesn't work. So how to do it?
Ok, I see. To achieve that, you should create a partial that can be dynamically updated.
https://docs.taipy.io/en/develop/manuals/userman/gui/pages/partial/
Replace the building of the partial in the code you find above what you just sent me:
def build_your_partial(facts):
with tgb.Page() as new_partial:
for index, fact in enumerate(facts):
tgb.text(f"{index}: {fact}", mode="md")
return new_partial
I see, partial is the way to make the GUI code modularized, is that correct? My little example works now, thanks.
Yes, it is a way to make it modularized, but it is more used to create a dynamic part for your page.
I've committed apps/enterpriser https://github.com/figoyouwei/taipy_success/tree/main/apps/enterpriser
The GUI is simple, I need to display some List content, here facts variable, returned by the llm using pydantic model class Summary(BaseModel): summary: str = Field(description="Summary") facts: List[str] = Field(description="Facts")