reflex 0.5.10a3__py3-none-any.whl → 0.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of reflex might be problematic. Click here for more details.
- reflex/.templates/jinja/custom_components/pyproject.toml.jinja2 +2 -2
- reflex/.templates/jinja/web/pages/_app.js.jinja2 +1 -1
- reflex/.templates/jinja/web/pages/utils.js.jinja2 +4 -4
- reflex/.templates/jinja/web/utils/context.js.jinja2 +1 -1
- reflex/.templates/jinja/web/utils/theme.js.jinja2 +1 -1
- reflex/.templates/web/utils/state.js +3 -1
- reflex/__init__.py +10 -3
- reflex/__init__.pyi +3 -2
- reflex/app.py +47 -11
- reflex/app_module_for_backend.py +1 -1
- reflex/base.py +3 -2
- reflex/compiler/compiler.py +5 -5
- reflex/compiler/utils.py +5 -3
- reflex/components/base/app_wrap.py +2 -4
- reflex/components/base/app_wrap.pyi +16 -26
- reflex/components/base/bare.py +6 -4
- reflex/components/base/body.pyi +16 -26
- reflex/components/base/document.pyi +76 -126
- reflex/components/base/error_boundary.py +9 -8
- reflex/components/base/error_boundary.pyi +18 -30
- reflex/components/base/fragment.pyi +16 -26
- reflex/components/base/head.pyi +31 -51
- reflex/components/base/link.py +1 -1
- reflex/components/base/link.pyi +31 -51
- reflex/components/base/meta.pyi +61 -101
- reflex/components/base/script.py +2 -2
- reflex/components/base/script.pyi +20 -36
- reflex/components/component.py +107 -130
- reflex/components/core/banner.py +61 -66
- reflex/components/core/banner.pyi +129 -230
- reflex/components/core/client_side_routing.py +2 -2
- reflex/components/core/client_side_routing.pyi +31 -51
- reflex/components/core/clipboard.py +4 -3
- reflex/components/core/clipboard.pyi +19 -31
- reflex/components/core/cond.py +21 -44
- reflex/components/core/debounce.py +7 -9
- reflex/components/core/debounce.pyi +19 -31
- reflex/components/core/foreach.py +4 -14
- reflex/components/core/html.py +1 -1
- reflex/components/core/html.pyi +34 -44
- reflex/components/core/match.py +36 -43
- reflex/components/core/upload.py +27 -26
- reflex/components/core/upload.pyi +81 -116
- reflex/components/datadisplay/code.py +55 -29
- reflex/components/datadisplay/code.pyi +303 -410
- reflex/components/datadisplay/dataeditor.py +13 -9
- reflex/components/datadisplay/dataeditor.pyi +39 -51
- reflex/components/el/__init__.py +0 -1
- reflex/components/el/__init__.pyi +0 -11
- reflex/components/el/element.pyi +16 -26
- reflex/components/el/elements/__init__.py +1 -7
- reflex/components/el/elements/__init__.pyi +1 -15
- reflex/components/el/elements/base.py +1 -1
- reflex/components/el/elements/base.pyi +33 -43
- reflex/components/el/elements/forms.py +26 -33
- reflex/components/el/elements/forms.pyi +542 -694
- reflex/components/el/elements/inline.py +1 -1
- reflex/components/el/elements/inline.pyi +909 -1189
- reflex/components/el/elements/media.py +1 -22
- reflex/components/el/elements/media.pyi +765 -975
- reflex/components/el/elements/metadata.py +3 -5
- reflex/components/el/elements/metadata.pyi +175 -235
- reflex/components/el/elements/other.py +1 -1
- reflex/components/el/elements/other.pyi +228 -298
- reflex/components/el/elements/scripts.py +1 -1
- reflex/components/el/elements/scripts.pyi +106 -136
- reflex/components/el/elements/sectioning.py +0 -2
- reflex/components/el/elements/sectioning.pyi +481 -631
- reflex/components/el/elements/tables.py +1 -1
- reflex/components/el/elements/tables.pyi +341 -441
- reflex/components/el/elements/typography.py +1 -1
- reflex/components/el/elements/typography.pyi +491 -641
- reflex/components/gridjs/datatable.py +9 -13
- reflex/components/gridjs/datatable.pyi +33 -53
- reflex/components/lucide/icon.py +3 -127
- reflex/components/lucide/icon.pyi +31 -160
- reflex/components/markdown/markdown.py +32 -42
- reflex/components/markdown/markdown.pyi +28 -41
- reflex/components/moment/moment.py +13 -12
- reflex/components/moment/moment.pyi +22 -33
- reflex/components/next/base.pyi +16 -26
- reflex/components/next/image.py +1 -5
- reflex/components/next/image.pyi +21 -35
- reflex/components/next/link.py +1 -1
- reflex/components/next/link.pyi +16 -26
- reflex/components/next/video.py +1 -1
- reflex/components/next/video.pyi +16 -26
- reflex/components/plotly/plotly.py +17 -30
- reflex/components/plotly/plotly.pyi +38 -52
- reflex/components/props.py +21 -10
- reflex/components/radix/__init__.pyi +2 -1
- reflex/components/radix/primitives/accordion.py +6 -7
- reflex/components/radix/primitives/accordion.pyi +415 -485
- reflex/components/radix/primitives/base.py +1 -1
- reflex/components/radix/primitives/base.pyi +31 -51
- reflex/components/radix/primitives/drawer.py +1 -1
- reflex/components/radix/primitives/drawer.pyi +162 -262
- reflex/components/radix/primitives/form.py +1 -1
- reflex/components/radix/primitives/form.pyi +247 -353
- reflex/components/radix/primitives/progress.py +1 -1
- reflex/components/radix/primitives/progress.pyi +226 -276
- reflex/components/radix/primitives/slider.py +1 -1
- reflex/components/radix/primitives/slider.pyi +82 -132
- reflex/components/radix/themes/base.py +8 -25
- reflex/components/radix/themes/base.pyi +171 -242
- reflex/components/radix/themes/color_mode.py +11 -20
- reflex/components/radix/themes/color_mode.pyi +198 -231
- reflex/components/radix/themes/components/__init__.pyi +1 -0
- reflex/components/radix/themes/components/alert_dialog.py +1 -1
- reflex/components/radix/themes/components/alert_dialog.pyi +129 -199
- reflex/components/radix/themes/components/aspect_ratio.py +1 -1
- reflex/components/radix/themes/components/aspect_ratio.pyi +16 -26
- reflex/components/radix/themes/components/avatar.py +1 -1
- reflex/components/radix/themes/components/avatar.pyi +69 -79
- reflex/components/radix/themes/components/badge.py +1 -1
- reflex/components/radix/themes/components/badge.pyi +87 -97
- reflex/components/radix/themes/components/button.py +1 -1
- reflex/components/radix/themes/components/button.pyi +97 -107
- reflex/components/radix/themes/components/callout.py +1 -1
- reflex/components/radix/themes/components/callout.pyi +317 -367
- reflex/components/radix/themes/components/card.py +1 -1
- reflex/components/radix/themes/components/card.pyi +37 -47
- reflex/components/radix/themes/components/checkbox.py +2 -4
- reflex/components/radix/themes/components/checkbox.pyi +205 -241
- reflex/components/radix/themes/components/checkbox_cards.py +1 -1
- reflex/components/radix/themes/components/checkbox_cards.pyi +92 -112
- reflex/components/radix/themes/components/checkbox_group.py +1 -1
- reflex/components/radix/themes/components/checkbox_group.pyi +84 -104
- reflex/components/radix/themes/components/context_menu.py +1 -1
- reflex/components/radix/themes/components/context_menu.pyi +230 -310
- reflex/components/radix/themes/components/data_list.py +6 -1
- reflex/components/radix/themes/components/data_list.pyi +131 -166
- reflex/components/radix/themes/components/dialog.py +1 -1
- reflex/components/radix/themes/components/dialog.pyi +132 -202
- reflex/components/radix/themes/components/dropdown_menu.py +1 -1
- reflex/components/radix/themes/components/dropdown_menu.pyi +241 -323
- reflex/components/radix/themes/components/hover_card.py +1 -1
- reflex/components/radix/themes/components/hover_card.pyi +86 -126
- reflex/components/radix/themes/components/icon_button.py +1 -1
- reflex/components/radix/themes/components/icon_button.pyi +97 -107
- reflex/components/radix/themes/components/inset.py +1 -1
- reflex/components/radix/themes/components/inset.pyi +46 -56
- reflex/components/radix/themes/components/popover.py +1 -1
- reflex/components/radix/themes/components/popover.pyi +91 -131
- reflex/components/radix/themes/components/progress.py +1 -1
- reflex/components/radix/themes/components/progress.pyi +70 -80
- reflex/components/radix/themes/components/radio.py +1 -1
- reflex/components/radix/themes/components/radio.pyi +68 -78
- reflex/components/radix/themes/components/radio_cards.py +1 -1
- reflex/components/radix/themes/components/radio_cards.pyi +96 -116
- reflex/components/radix/themes/components/radio_group.py +32 -31
- reflex/components/radix/themes/components/radio_group.pyi +230 -266
- reflex/components/radix/themes/components/scroll_area.py +1 -1
- reflex/components/radix/themes/components/scroll_area.pyi +20 -30
- reflex/components/radix/themes/components/segmented_control.py +1 -1
- reflex/components/radix/themes/components/segmented_control.pyi +88 -110
- reflex/components/radix/themes/components/select.py +1 -1
- reflex/components/radix/themes/components/select.pyi +365 -461
- reflex/components/radix/themes/components/separator.py +2 -4
- reflex/components/radix/themes/components/separator.pyi +68 -78
- reflex/components/radix/themes/components/skeleton.py +1 -1
- reflex/components/radix/themes/components/skeleton.pyi +22 -32
- reflex/components/radix/themes/components/slider.py +1 -1
- reflex/components/radix/themes/components/slider.pyi +74 -86
- reflex/components/radix/themes/components/spinner.py +1 -1
- reflex/components/radix/themes/components/spinner.pyi +18 -28
- reflex/components/radix/themes/components/switch.py +1 -1
- reflex/components/radix/themes/components/switch.pyi +70 -82
- reflex/components/radix/themes/components/table.py +1 -1
- reflex/components/radix/themes/components/table.pyi +254 -324
- reflex/components/radix/themes/components/tabs.py +1 -1
- reflex/components/radix/themes/components/tabs.pyi +134 -188
- reflex/components/radix/themes/components/text_area.py +1 -1
- reflex/components/radix/themes/components/text_area.pyi +95 -109
- reflex/components/radix/themes/components/text_field.py +1 -80
- reflex/components/radix/themes/components/text_field.pyi +245 -290
- reflex/components/radix/themes/components/tooltip.py +1 -1
- reflex/components/radix/themes/components/tooltip.pyi +25 -35
- reflex/components/radix/themes/layout/__init__.pyi +1 -0
- reflex/components/radix/themes/layout/base.py +1 -1
- reflex/components/radix/themes/layout/base.pyi +55 -65
- reflex/components/radix/themes/layout/box.pyi +33 -43
- reflex/components/radix/themes/layout/center.pyi +55 -65
- reflex/components/radix/themes/layout/container.py +2 -4
- reflex/components/radix/themes/layout/container.pyi +35 -45
- reflex/components/radix/themes/layout/flex.py +1 -1
- reflex/components/radix/themes/layout/flex.pyi +55 -65
- reflex/components/radix/themes/layout/grid.py +1 -1
- reflex/components/radix/themes/layout/grid.pyi +63 -73
- reflex/components/radix/themes/layout/list.py +1 -1
- reflex/components/radix/themes/layout/list.pyi +188 -238
- reflex/components/radix/themes/layout/section.py +2 -4
- reflex/components/radix/themes/layout/section.pyi +35 -45
- reflex/components/radix/themes/layout/spacer.pyi +55 -65
- reflex/components/radix/themes/layout/stack.py +1 -1
- reflex/components/radix/themes/layout/stack.pyi +125 -155
- reflex/components/radix/themes/typography/blockquote.py +1 -1
- reflex/components/radix/themes/typography/blockquote.pyi +88 -98
- reflex/components/radix/themes/typography/code.py +1 -1
- reflex/components/radix/themes/typography/code.pyi +89 -99
- reflex/components/radix/themes/typography/heading.py +1 -1
- reflex/components/radix/themes/typography/heading.pyi +95 -105
- reflex/components/radix/themes/typography/link.py +1 -1
- reflex/components/radix/themes/typography/link.pyi +101 -111
- reflex/components/radix/themes/typography/text.py +1 -1
- reflex/components/radix/themes/typography/text.pyi +494 -564
- reflex/components/react_player/audio.pyi +32 -58
- reflex/components/react_player/react_player.py +1 -1
- reflex/components/react_player/react_player.pyi +32 -58
- reflex/components/react_player/video.pyi +32 -58
- reflex/components/recharts/cartesian.py +22 -19
- reflex/components/recharts/cartesian.pyi +658 -840
- reflex/components/recharts/charts.py +3 -3
- reflex/components/recharts/charts.pyi +238 -342
- reflex/components/recharts/general.py +8 -8
- reflex/components/recharts/general.pyi +175 -225
- reflex/components/recharts/polar.py +11 -11
- reflex/components/recharts/polar.pyi +135 -171
- reflex/components/recharts/recharts.pyi +31 -51
- reflex/components/sonner/toast.py +27 -31
- reflex/components/sonner/toast.pyi +36 -45
- reflex/components/suneditor/editor.py +1 -1
- reflex/components/suneditor/editor.pyi +54 -76
- reflex/components/tags/cond_tag.py +6 -4
- reflex/components/tags/iter_tag.py +37 -25
- reflex/components/tags/match_tag.py +6 -4
- reflex/components/tags/tag.py +43 -28
- reflex/constants/base.py +3 -1
- reflex/constants/event.py +1 -0
- reflex/custom_components/custom_components.py +3 -1
- reflex/event.py +166 -108
- reflex/experimental/__init__.py +25 -6
- reflex/experimental/client_state.py +34 -57
- reflex/experimental/hooks.py +12 -17
- reflex/experimental/layout.py +4 -4
- reflex/experimental/layout.pyi +130 -180
- reflex/middleware/hydrate_middleware.py +2 -0
- reflex/middleware/middleware.py +3 -3
- reflex/model.py +22 -0
- reflex/reflex.py +4 -0
- reflex/state.py +491 -110
- reflex/style.py +56 -39
- reflex/testing.py +8 -3
- reflex/utils/exceptions.py +32 -0
- reflex/utils/exec.py +0 -14
- reflex/utils/format.py +80 -209
- reflex/utils/imports.py +16 -73
- reflex/utils/net.py +43 -0
- reflex/utils/path_ops.py +13 -1
- reflex/utils/prerequisites.py +81 -41
- reflex/utils/pyi_generator.py +12 -6
- reflex/utils/serializers.py +13 -41
- reflex/utils/telemetry.py +3 -2
- reflex/utils/types.py +47 -7
- reflex/{experimental/vars → vars}/__init__.py +6 -3
- reflex/vars/base.py +2563 -0
- reflex/vars/function.py +196 -0
- reflex/vars/number.py +1158 -0
- reflex/vars/object.py +562 -0
- reflex/vars/sequence.py +1604 -0
- {reflex-0.5.10a3.dist-info → reflex-0.6.0.dist-info}/METADATA +6 -9
- reflex-0.6.0.dist-info/RECORD +382 -0
- reflex/.templates/apps/demo/.gitignore +0 -4
- reflex/.templates/apps/demo/assets/favicon.ico +0 -0
- reflex/.templates/apps/demo/assets/github.svg +0 -10
- reflex/.templates/apps/demo/assets/icon.svg +0 -37
- reflex/.templates/apps/demo/assets/logo.svg +0 -68
- reflex/.templates/apps/demo/assets/paneleft.svg +0 -13
- reflex/.templates/apps/demo/code/__init__.py +0 -1
- reflex/.templates/apps/demo/code/demo.py +0 -127
- reflex/.templates/apps/demo/code/pages/__init__.py +0 -7
- reflex/.templates/apps/demo/code/pages/chatapp.py +0 -31
- reflex/.templates/apps/demo/code/pages/datatable.py +0 -360
- reflex/.templates/apps/demo/code/pages/forms.py +0 -257
- reflex/.templates/apps/demo/code/pages/graphing.py +0 -253
- reflex/.templates/apps/demo/code/pages/home.py +0 -56
- reflex/.templates/apps/demo/code/sidebar.py +0 -178
- reflex/.templates/apps/demo/code/state.py +0 -22
- reflex/.templates/apps/demo/code/states/form_state.py +0 -40
- reflex/.templates/apps/demo/code/states/pie_state.py +0 -47
- reflex/.templates/apps/demo/code/styles.py +0 -68
- reflex/.templates/apps/demo/code/webui/__init__.py +0 -0
- reflex/.templates/apps/demo/code/webui/components/__init__.py +0 -4
- reflex/.templates/apps/demo/code/webui/components/chat.py +0 -118
- reflex/.templates/apps/demo/code/webui/components/loading_icon.py +0 -19
- reflex/.templates/apps/demo/code/webui/components/modal.py +0 -56
- reflex/.templates/apps/demo/code/webui/components/navbar.py +0 -70
- reflex/.templates/apps/demo/code/webui/components/sidebar.py +0 -66
- reflex/.templates/apps/demo/code/webui/state.py +0 -146
- reflex/.templates/apps/demo/code/webui/styles.py +0 -88
- reflex/.templates/web/components/reflex/chakra_color_mode_provider.js +0 -36
- reflex/experimental/vars/base.py +0 -583
- reflex/experimental/vars/function.py +0 -290
- reflex/experimental/vars/number.py +0 -1458
- reflex/experimental/vars/object.py +0 -804
- reflex/experimental/vars/sequence.py +0 -1764
- reflex/utils/watch.py +0 -96
- reflex/vars.py +0 -2604
- reflex/vars.pyi +0 -218
- reflex-0.5.10a3.dist-info/RECORD +0 -413
- {reflex-0.5.10a3.dist-info → reflex-0.6.0.dist-info}/LICENSE +0 -0
- {reflex-0.5.10a3.dist-info → reflex-0.6.0.dist-info}/WHEEL +0 -0
- {reflex-0.5.10a3.dist-info → reflex-0.6.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import asyncio
|
|
2
|
-
|
|
3
|
-
import reflex as rx
|
|
4
|
-
|
|
5
|
-
from ..state import State
|
|
6
|
-
|
|
7
|
-
# openai.api_key = os.environ["OPENAI_API_KEY"]
|
|
8
|
-
# openai.api_base = os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1")
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class QA(rx.Base):
|
|
12
|
-
"""A question and answer pair."""
|
|
13
|
-
|
|
14
|
-
question: str
|
|
15
|
-
answer: str
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
DEFAULT_CHATS = {
|
|
19
|
-
"Intros": [],
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class State(State):
|
|
24
|
-
"""The app state."""
|
|
25
|
-
|
|
26
|
-
# A dict from the chat name to the list of questions and answers.
|
|
27
|
-
chats: dict[str, list[QA]] = DEFAULT_CHATS
|
|
28
|
-
|
|
29
|
-
# The current chat name.
|
|
30
|
-
current_chat = "Intros"
|
|
31
|
-
|
|
32
|
-
# The current question.
|
|
33
|
-
question: str
|
|
34
|
-
|
|
35
|
-
# Whether we are processing the question.
|
|
36
|
-
processing: bool = False
|
|
37
|
-
|
|
38
|
-
# The name of the new chat.
|
|
39
|
-
new_chat_name: str = ""
|
|
40
|
-
|
|
41
|
-
# Whether the drawer is open.
|
|
42
|
-
drawer_open: bool = False
|
|
43
|
-
|
|
44
|
-
# Whether the modal is open.
|
|
45
|
-
modal_open: bool = False
|
|
46
|
-
|
|
47
|
-
def create_chat(self):
|
|
48
|
-
"""Create a new chat."""
|
|
49
|
-
# Add the new chat to the list of chats.
|
|
50
|
-
self.current_chat = self.new_chat_name
|
|
51
|
-
self.chats[self.new_chat_name] = []
|
|
52
|
-
|
|
53
|
-
# Toggle the modal.
|
|
54
|
-
self.modal_open = False
|
|
55
|
-
|
|
56
|
-
def toggle_modal(self):
|
|
57
|
-
"""Toggle the new chat modal."""
|
|
58
|
-
self.modal_open = not self.modal_open
|
|
59
|
-
|
|
60
|
-
def toggle_drawer(self):
|
|
61
|
-
"""Toggle the drawer."""
|
|
62
|
-
self.drawer_open = not self.drawer_open
|
|
63
|
-
|
|
64
|
-
def delete_chat(self):
|
|
65
|
-
"""Delete the current chat."""
|
|
66
|
-
del self.chats[self.current_chat]
|
|
67
|
-
if len(self.chats) == 0:
|
|
68
|
-
self.chats = DEFAULT_CHATS
|
|
69
|
-
# set self.current_chat to the first chat.
|
|
70
|
-
self.current_chat = next(iter(self.chats))
|
|
71
|
-
self.toggle_drawer()
|
|
72
|
-
|
|
73
|
-
def set_chat(self, chat_name: str):
|
|
74
|
-
"""Set the name of the current chat.
|
|
75
|
-
|
|
76
|
-
Args:
|
|
77
|
-
chat_name: The name of the chat.
|
|
78
|
-
"""
|
|
79
|
-
self.current_chat = chat_name
|
|
80
|
-
self.toggle_drawer()
|
|
81
|
-
|
|
82
|
-
@rx.var
|
|
83
|
-
def chat_titles(self) -> list[str]:
|
|
84
|
-
"""Get the list of chat titles.
|
|
85
|
-
|
|
86
|
-
Returns:
|
|
87
|
-
The list of chat names.
|
|
88
|
-
"""
|
|
89
|
-
return [*self.chats]
|
|
90
|
-
|
|
91
|
-
async def process_question(self, form_data: dict[str, str]):
|
|
92
|
-
"""Get the response from the API.
|
|
93
|
-
|
|
94
|
-
Args:
|
|
95
|
-
form_data: A dict with the current question.
|
|
96
|
-
|
|
97
|
-
Yields:
|
|
98
|
-
The current question and the response.
|
|
99
|
-
"""
|
|
100
|
-
# Check if the question is empty
|
|
101
|
-
if self.question == "":
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
# Add the question to the list of questions.
|
|
105
|
-
qa = QA(question=self.question, answer="")
|
|
106
|
-
self.chats[self.current_chat].append(qa)
|
|
107
|
-
|
|
108
|
-
# Clear the input and start the processing.
|
|
109
|
-
self.processing = True
|
|
110
|
-
self.question = ""
|
|
111
|
-
yield
|
|
112
|
-
|
|
113
|
-
# # Build the messages.
|
|
114
|
-
# messages = [
|
|
115
|
-
# {"role": "system", "content": "You are a friendly chatbot named Reflex."}
|
|
116
|
-
# ]
|
|
117
|
-
# for qa in self.chats[self.current_chat]:
|
|
118
|
-
# messages.append({"role": "user", "content": qa.question})
|
|
119
|
-
# messages.append({"role": "assistant", "content": qa.answer})
|
|
120
|
-
|
|
121
|
-
# # Remove the last mock answer.
|
|
122
|
-
# messages = messages[:-1]
|
|
123
|
-
|
|
124
|
-
# Start a new session to answer the question.
|
|
125
|
-
# session = openai.ChatCompletion.create(
|
|
126
|
-
# model=os.getenv("OPENAI_MODEL", "gpt-3.5-turbo"),
|
|
127
|
-
# messages=messages,
|
|
128
|
-
# stream=True,
|
|
129
|
-
# )
|
|
130
|
-
|
|
131
|
-
# Stream the results, yielding after every word.
|
|
132
|
-
# for item in session:
|
|
133
|
-
answer = "I don't know! This Chatbot still needs to add in AI API keys!"
|
|
134
|
-
for i in range(len(answer)):
|
|
135
|
-
# Pause to show the streaming effect.
|
|
136
|
-
await asyncio.sleep(0.1)
|
|
137
|
-
# Add one letter at a time to the output.
|
|
138
|
-
|
|
139
|
-
# if hasattr(item.choices[0].delta, "content"):
|
|
140
|
-
# answer_text = item.choices[0].delta.content
|
|
141
|
-
self.chats[self.current_chat][-1].answer += answer[i]
|
|
142
|
-
self.chats = self.chats
|
|
143
|
-
yield
|
|
144
|
-
|
|
145
|
-
# Toggle the processing flag.
|
|
146
|
-
self.processing = False
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import reflex as rx
|
|
2
|
-
|
|
3
|
-
bg_dark_color = "#111"
|
|
4
|
-
bg_medium_color = "#222"
|
|
5
|
-
|
|
6
|
-
border_color = "#fff3"
|
|
7
|
-
|
|
8
|
-
accennt_light = "#6649D8"
|
|
9
|
-
accent_color = "#5535d4"
|
|
10
|
-
accent_dark = "#4c2db3"
|
|
11
|
-
|
|
12
|
-
icon_color = "#fff8"
|
|
13
|
-
|
|
14
|
-
text_light_color = "#fff"
|
|
15
|
-
shadow_light = "rgba(17, 12, 46, 0.15) 0px 48px 100px 0px;"
|
|
16
|
-
shadow = "rgba(50, 50, 93, 0.25) 0px 50px 100px -20px, rgba(0, 0, 0, 0.3) 0px 30px 60px -30px, rgba(10, 37, 64, 0.35) 0px -2px 6px 0px inset;"
|
|
17
|
-
|
|
18
|
-
message_style = dict(display="inline-block", p="4", border_radius="xl", max_w="30em")
|
|
19
|
-
|
|
20
|
-
input_style = dict(
|
|
21
|
-
bg=bg_medium_color,
|
|
22
|
-
border_color=border_color,
|
|
23
|
-
border_width="1px",
|
|
24
|
-
p="4",
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
icon_style = dict(
|
|
28
|
-
font_size="md",
|
|
29
|
-
color=icon_color,
|
|
30
|
-
_hover=dict(color=text_light_color),
|
|
31
|
-
cursor="pointer",
|
|
32
|
-
w="8",
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
sidebar_style = dict(
|
|
36
|
-
border="double 1px transparent;",
|
|
37
|
-
border_radius="10px;",
|
|
38
|
-
background_image=f"linear-gradient({bg_dark_color}, {bg_dark_color}), radial-gradient(circle at top left, {accent_color},{accent_dark});",
|
|
39
|
-
background_origin="border-box;",
|
|
40
|
-
background_clip="padding-box, border-box;",
|
|
41
|
-
p="2",
|
|
42
|
-
_hover=dict(
|
|
43
|
-
background_image=f"linear-gradient({bg_dark_color}, {bg_dark_color}), radial-gradient(circle at top left, {accent_color},{accennt_light});",
|
|
44
|
-
),
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
base_style = {
|
|
48
|
-
rx.chakra.Avatar: {
|
|
49
|
-
"shadow": shadow,
|
|
50
|
-
"color": text_light_color,
|
|
51
|
-
# "bg": border_color,
|
|
52
|
-
},
|
|
53
|
-
rx.chakra.Button: {
|
|
54
|
-
"shadow": shadow,
|
|
55
|
-
"color": text_light_color,
|
|
56
|
-
"_hover": {
|
|
57
|
-
"bg": accent_dark,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
rx.chakra.Menu: {
|
|
61
|
-
"bg": bg_dark_color,
|
|
62
|
-
"border": f"red",
|
|
63
|
-
},
|
|
64
|
-
rx.chakra.MenuList: {
|
|
65
|
-
"bg": bg_dark_color,
|
|
66
|
-
"border": f"1.5px solid {bg_medium_color}",
|
|
67
|
-
},
|
|
68
|
-
rx.chakra.MenuDivider: {
|
|
69
|
-
"border": f"1px solid {bg_medium_color}",
|
|
70
|
-
},
|
|
71
|
-
rx.chakra.MenuItem: {
|
|
72
|
-
"bg": bg_dark_color,
|
|
73
|
-
"color": text_light_color,
|
|
74
|
-
},
|
|
75
|
-
rx.chakra.DrawerContent: {
|
|
76
|
-
"bg": bg_dark_color,
|
|
77
|
-
"color": text_light_color,
|
|
78
|
-
"opacity": "0.9",
|
|
79
|
-
},
|
|
80
|
-
rx.chakra.Hstack: {
|
|
81
|
-
"align_items": "center",
|
|
82
|
-
"justify_content": "space-between",
|
|
83
|
-
},
|
|
84
|
-
rx.chakra.Vstack: {
|
|
85
|
-
"align_items": "stretch",
|
|
86
|
-
"justify_content": "space-between",
|
|
87
|
-
},
|
|
88
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useColorMode as chakraUseColorMode } from "@chakra-ui/react";
|
|
2
|
-
import { useTheme } from "next-themes";
|
|
3
|
-
import { useEffect, useState } from "react";
|
|
4
|
-
import { ColorModeContext, defaultColorMode } from "/utils/context.js";
|
|
5
|
-
|
|
6
|
-
export default function ChakraColorModeProvider({ children }) {
|
|
7
|
-
const { theme, resolvedTheme, setTheme } = useTheme();
|
|
8
|
-
const { colorMode, toggleColorMode } = chakraUseColorMode();
|
|
9
|
-
const [resolvedColorMode, setResolvedColorMode] = useState(colorMode);
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (colorMode != resolvedTheme) {
|
|
13
|
-
toggleColorMode();
|
|
14
|
-
}
|
|
15
|
-
setResolvedColorMode(resolvedTheme);
|
|
16
|
-
}, [theme, resolvedTheme]);
|
|
17
|
-
|
|
18
|
-
const rawColorMode = colorMode;
|
|
19
|
-
const setColorMode = (mode) => {
|
|
20
|
-
const allowedModes = ["light", "dark", "system"];
|
|
21
|
-
if (!allowedModes.includes(mode)) {
|
|
22
|
-
console.error(
|
|
23
|
-
`Invalid color mode "${mode}". Defaulting to "${defaultColorMode}".`
|
|
24
|
-
);
|
|
25
|
-
mode = defaultColorMode;
|
|
26
|
-
}
|
|
27
|
-
setTheme(mode);
|
|
28
|
-
};
|
|
29
|
-
return (
|
|
30
|
-
<ColorModeContext.Provider
|
|
31
|
-
value={{ rawColorMode, resolvedColorMode, toggleColorMode, setColorMode }}
|
|
32
|
-
>
|
|
33
|
-
{children}
|
|
34
|
-
</ColorModeContext.Provider>
|
|
35
|
-
);
|
|
36
|
-
}
|