1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-30 19:07:39 +03:00

feat(skill/todo_list): view_lists widget action kick off

This commit is contained in:
louistiti 2024-08-27 09:13:59 +08:00
parent 719664d1e5
commit ee732ceca8
4 changed files with 48 additions and 9 deletions

View File

@ -147,7 +147,7 @@ a {
color: inherit;
}
#feed ul li {
#feed ul li:not(.aurora-list-item) {
margin-left: 20px;
}

View File

@ -130,7 +130,6 @@ export default class Chatbot {
const data = await axios.get(
`${this.serverURL}/api/v1/fetch-widget?skill_action=${widgetContainer.onFetchAction}&widget_id=${widgetContainer.widgetId}`
)
console.log('data', data.data)
const fetchedWidget = data.data.widget
const reactNode = fetchedWidget
? renderAuroraComponent(

View File

@ -1,7 +1,10 @@
from bridges.python.src.sdk.leon import leon
from bridges.python.src.sdk.types import ActionParams
from bridges.python.src.sdk.widget import WidgetOptions
from ..lib import memory
from ..widgets.list_of_lists_widget import ListOfListsWidget, ListOfListsWidgetParams
def run(params: ActionParams) -> None:
"""View to-do lists"""
@ -18,10 +21,10 @@ def run(params: ActionParams) -> None:
'todos_nb': memory.count_todo_items(list_element['name'])
}))
leon.answer({
'key': 'lists_listed',
'data': {
'lists_nb': todo_lists_count,
'result': result
}
})
list_of_lists_options: WidgetOptions[ListOfListsWidgetParams] = WidgetOptions(
wrapper_props={'noPadding': True},
params={'random_number': 4}
)
list_of_lists_widget = ListOfListsWidget(list_of_lists_options)
leon.answer({'widget': list_of_lists_widget})

View File

@ -0,0 +1,37 @@
from typing import TypedDict
from bridges.python.src.sdk.aurora.list import List
from bridges.python.src.sdk.aurora.list_item import ListItem
from bridges.python.src.sdk.aurora.text import Text
from bridges.python.src.sdk.widget import Widget, WidgetOptions
from bridges.python.src.sdk.widget_component import WidgetComponent
class ListOfListsWidgetParams(TypedDict):
random_number: int
class ListOfListsWidget(Widget[ListOfListsWidgetParams]):
def __init__(self, options: WidgetOptions[ListOfListsWidgetParams]):
super().__init__(options)
def render(self) -> WidgetComponent:
return List({
'children': [
ListItem({
'children': Text({
'children': 'List 1'
})
}),
ListItem({
'children': Text({
'children': 'List 2'
})
}),
ListItem({
'children': Text({
'children': 'List 3'
})
})
]
})