vedana-backoffice 0.6.1__tar.gz → 0.6.3__tar.gz

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.
Files changed (34) hide show
  1. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/PKG-INFO +1 -1
  2. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/states/common.py +45 -0
  3. vedana_backoffice-0.6.3/src/vedana_backoffice/ui.py +193 -0
  4. vedana_backoffice-0.6.1/src/vedana_backoffice/ui.py +0 -115
  5. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/.gitignore +0 -0
  6. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/CHANGELOG.md +0 -0
  7. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/README.md +0 -0
  8. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/assets/styles.css +0 -0
  9. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/pyproject.toml +0 -0
  10. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/rxconfig.py +0 -0
  11. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/Caddyfile +0 -0
  12. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/__init__.py +0 -0
  13. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/components/__init__.py +0 -0
  14. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/components/etl_graph.py +0 -0
  15. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/components/ui_chat.py +0 -0
  16. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/graph/__init__.py +0 -0
  17. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/graph/build.py +0 -0
  18. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/pages/__init__.py +0 -0
  19. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/pages/chat.py +0 -0
  20. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/pages/etl.py +0 -0
  21. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/pages/eval.py +0 -0
  22. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/pages/jims_thread_list_page.py +0 -0
  23. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/pages/main_dashboard.py +0 -0
  24. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/py.typed +0 -0
  25. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/start_services.py +0 -0
  26. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/state.py +0 -0
  27. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/states/__init__.py +0 -0
  28. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/states/chat.py +0 -0
  29. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/states/etl.py +0 -0
  30. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/states/eval.py +0 -0
  31. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/states/jims.py +0 -0
  32. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/states/main_dashboard.py +0 -0
  33. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/util.py +0 -0
  34. {vedana_backoffice-0.6.1 → vedana_backoffice-0.6.3}/src/vedana_backoffice/vedana_backoffice.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: vedana-backoffice
3
- Version: 0.6.1
3
+ Version: 0.6.3
4
4
  Summary: Reflex-based admin/backoffice UI for Vedana
5
5
  Author-email: Andrey Tatarinov <a@tatarinov.co>, Timur Sheydaev <tsheyd@epoch8.co>
6
6
  Requires-Python: >=3.12
@@ -9,6 +9,9 @@ from vedana_core.app import VedanaApp, make_vedana_app
9
9
  vedana_app: VedanaApp | None = None
10
10
 
11
11
  EVAL_ENABLED = bool(os.environ.get("GRIST_TEST_SET_DOC_ID"))
12
+ DEBUG_MODE = os.environ.get("DEBUG", "").lower() in ("true", "1")
13
+ HAS_OPENAI_KEY = bool(os.environ.get("OPENAI_API_KEY"))
14
+ HAS_OPENROUTER_KEY = bool(os.environ.get("OPENROUTER_API_KEY"))
12
15
 
13
16
 
14
17
  async def get_vedana_app():
@@ -40,6 +43,48 @@ class MemLogger(logging.Logger):
40
43
  class AppVersionState(rx.State):
41
44
  version: str = f"`{os.environ.get('VERSION', 'unspecified_version')}`" # md-formatted
42
45
  eval_enabled: bool = EVAL_ENABLED
46
+ debug_mode: bool = DEBUG_MODE
47
+
48
+
49
+ class DebugState(rx.State):
50
+ """State for debug mode API key setup."""
51
+
52
+ debug_mode: bool = DEBUG_MODE
53
+ needs_api_key: bool = DEBUG_MODE and not HAS_OPENAI_KEY and not HAS_OPENROUTER_KEY
54
+ show_api_key_dialog: bool = False
55
+ api_key: str = ""
56
+ api_key_type: str = "openai" # "openai" or "openrouter"
57
+ api_key_saved: bool = False
58
+
59
+ def check_and_show_dialog(self) -> None:
60
+ """Called on app mount to show dialog if needed."""
61
+ if self.needs_api_key and not self.api_key_saved:
62
+ self.show_api_key_dialog = True
63
+
64
+ def set_api_key(self, value: str) -> None:
65
+ self.api_key = value
66
+
67
+ def set_api_key_type(self, value: str) -> None:
68
+ self.api_key_type = value
69
+
70
+ def save_api_key(self) -> None:
71
+ """Save the API key and close dialog."""
72
+ if self.api_key.strip() and self.debug_mode: # extra check for debug mode
73
+ self.api_key_saved = True
74
+ self.show_api_key_dialog = False
75
+ # Set environment variable so it's available throughout the app
76
+ if self.api_key_type == "openai":
77
+ os.environ["OPENAI_API_KEY"] = self.api_key.strip()
78
+ else:
79
+ os.environ["OPENROUTER_API_KEY"] = self.api_key.strip()
80
+
81
+ def close_dialog(self) -> None:
82
+ """Close dialog without saving."""
83
+ self.show_api_key_dialog = False
84
+
85
+ def open_dialog(self) -> None:
86
+ """Manually open the dialog to change API key."""
87
+ self.show_api_key_dialog = True
43
88
 
44
89
 
45
90
  class TelegramBotState(rx.State):
@@ -0,0 +1,193 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+ import reflex as rx
6
+
7
+ from vedana_backoffice.states.chat import ChatState
8
+ from vedana_backoffice.states.common import AppVersionState, DebugState, TelegramBotState
9
+
10
+
11
+ def telegram_link_box() -> rx.Component:
12
+ return rx.box(
13
+ rx.cond(
14
+ TelegramBotState.has_bot,
15
+ rx.link(
16
+ rx.hstack(
17
+ rx.text("Telegram", font_size="1.1em"),
18
+ # rx.icon("external-link", stroke_width=1, size=10),
19
+ # spacing="1",
20
+ ),
21
+ href=TelegramBotState.bot_url,
22
+ is_external=True,
23
+ ),
24
+ ),
25
+ on_mount=TelegramBotState.load_bot_info,
26
+ )
27
+
28
+
29
+ def data_model_reload_btn() -> rx.Component:
30
+ return rx.button(
31
+ "Reload Data Model",
32
+ variant="soft",
33
+ color_scheme="blue",
34
+ on_click=ChatState.reload_data_model,
35
+ loading=ChatState.is_refreshing_dm,
36
+ )
37
+
38
+
39
+ def debug_badge() -> rx.Component:
40
+ """Red badge indicating debug mode is active. Clickable to open API key dialog."""
41
+ return rx.cond(
42
+ AppVersionState.debug_mode,
43
+ rx.tooltip(
44
+ rx.badge(
45
+ "DEBUG MODE",
46
+ color_scheme="red",
47
+ variant="solid",
48
+ size="2",
49
+ style={
50
+ "font_weight": "bold",
51
+ "text_transform": "uppercase",
52
+ "cursor": "pointer",
53
+ },
54
+ on_click=DebugState.open_dialog,
55
+ ),
56
+ content="Debug mode enabled! Some features are not for production use. Click to reset LLM API_KEY"
57
+ ),
58
+ rx.fragment(),
59
+ )
60
+
61
+
62
+ def api_key_setup_dialog() -> rx.Component:
63
+ """Dialog to prompt user for API key in debug mode when no keys are configured."""
64
+ return rx.dialog.root(
65
+ rx.dialog.content(
66
+ rx.dialog.title("API Key Setup"),
67
+ rx.dialog.description(
68
+ "Please provide an OpenAI or OpenRouter API key to use the chat functionality.",
69
+ margin_bottom="1em",
70
+ ),
71
+ rx.vstack(
72
+ rx.select(
73
+ ["openai", "openrouter"],
74
+ value=DebugState.api_key_type,
75
+ on_change=DebugState.set_api_key_type,
76
+ placeholder="Select API provider",
77
+ ),
78
+ rx.input(
79
+ placeholder="Enter your API key",
80
+ value=DebugState.api_key,
81
+ on_change=DebugState.set_api_key,
82
+ type="password",
83
+ width="100%",
84
+ ),
85
+ rx.hstack(
86
+ rx.dialog.close(
87
+ rx.button(
88
+ "Skip",
89
+ variant="soft",
90
+ color_scheme="gray",
91
+ on_click=DebugState.close_dialog,
92
+ ),
93
+ ),
94
+ rx.button(
95
+ "Save",
96
+ color_scheme="blue",
97
+ on_click=DebugState.save_api_key,
98
+ ),
99
+ justify="end",
100
+ spacing="3",
101
+ width="100%",
102
+ ),
103
+ spacing="4",
104
+ width="100%",
105
+ ),
106
+ style={"max_width": "450px"},
107
+ ),
108
+ open=DebugState.show_api_key_dialog,
109
+ )
110
+
111
+
112
+ def app_header() -> rx.Component:
113
+ return rx.fragment(
114
+ rx.box(
115
+ rx.hstack(
116
+ rx.hstack(
117
+ rx.link("Vedana Backoffice", href="/", font_weight="bold", font_size="1.25em"),
118
+ rx.markdown(AppVersionState.version), # type: ignore[operator]
119
+ debug_badge(),
120
+ align="center",
121
+ spacing="3",
122
+ ),
123
+ rx.hstack(
124
+ data_model_reload_btn(),
125
+ rx.link("ETL", href="/etl", font_size="1.1em"),
126
+ rx.cond(
127
+ AppVersionState.eval_enabled,
128
+ rx.link("Eval", href="/eval", font_size="1.1em"),
129
+ rx.fragment(),
130
+ ),
131
+ rx.link("Chat", href="/chat", font_size="1.1em"),
132
+ rx.link("JIMS", href="/jims", font_size="1.1em"),
133
+ telegram_link_box(),
134
+ rx.color_mode.button(), # type: ignore[attr-defined]
135
+ spacing="6",
136
+ align="center",
137
+ ),
138
+ justify="between",
139
+ align="center",
140
+ width="100%",
141
+ ),
142
+ width="100%",
143
+ padding="0.5em 1.25em",
144
+ border_bottom="1px solid #e5e7eb",
145
+ position="sticky",
146
+ top="0",
147
+ background_color=rx.color_mode_cond(light="white", dark="black"),
148
+ style={
149
+ "backdrop-filter": "blur(10px)", # enables non-transparent background
150
+ },
151
+ z_index="10",
152
+ on_mount=DebugState.check_and_show_dialog,
153
+ ),
154
+ api_key_setup_dialog(),
155
+ )
156
+
157
+
158
+ def themed_data_table(
159
+ *,
160
+ data: rx.Var | list[Any],
161
+ columns: rx.Var | list[str],
162
+ width: str | rx.Var = "fit-content",
163
+ max_width: str | rx.Var = "100%",
164
+ **kwargs: Any,
165
+ ) -> rx.Component:
166
+ """Wrap rx.data_table with shared styling so it matches the app theme."""
167
+
168
+ default_kwargs = {"pagination": True, "search": True, "sort": True}
169
+ table_kwargs = {**default_kwargs, **kwargs}
170
+
171
+ table_style = table_kwargs.pop("style", {})
172
+ table_style = {"width": "fit-content", "minWidth": "100%", **table_style}
173
+
174
+ container_style: dict[str, Any] = {
175
+ "width": width,
176
+ "maxWidth": max_width,
177
+ "minWidth": "fit-content",
178
+ }
179
+
180
+ return rx.box(
181
+ rx.data_table(data=data, columns=columns, style=table_style, **table_kwargs),
182
+ class_name="datatable-surface",
183
+ style=container_style,
184
+ )
185
+
186
+
187
+ def breadcrumbs(items: list[tuple[str, str]]) -> rx.Component:
188
+ parts: list[rx.Component] = []
189
+ for idx, (label, href) in enumerate(items):
190
+ parts.append(rx.link(label, href=href))
191
+ if idx < len(items) - 1:
192
+ parts.append(rx.text("→", color="#9ca3af"))
193
+ return rx.hstack(*parts, spacing="2", padding_y="0.5em")
@@ -1,115 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from typing import Any
4
-
5
- import reflex as rx
6
-
7
- from vedana_backoffice.states.chat import ChatState
8
- from vedana_backoffice.states.common import AppVersionState, TelegramBotState
9
-
10
-
11
- def telegram_link_box() -> rx.Component:
12
- return rx.box(
13
- rx.cond(
14
- TelegramBotState.has_bot,
15
- rx.link(
16
- rx.hstack(
17
- rx.text("Telegram", font_size="1.1em"),
18
- # rx.icon("external-link", stroke_width=1, size=10),
19
- # spacing="1",
20
- ),
21
- href=TelegramBotState.bot_url,
22
- is_external=True,
23
- ),
24
- ),
25
- on_mount=TelegramBotState.load_bot_info,
26
- )
27
-
28
-
29
- def data_model_reload_btn() -> rx.Component:
30
- return rx.button(
31
- "Reload Data Model",
32
- variant="soft",
33
- color_scheme="blue",
34
- on_click=ChatState.reload_data_model,
35
- loading=ChatState.is_refreshing_dm,
36
- )
37
-
38
-
39
- def app_header() -> rx.Component:
40
- return rx.box(
41
- rx.hstack(
42
- rx.hstack(
43
- rx.link("Vedana Backoffice", href="/", font_weight="bold", font_size="1.25em"),
44
- rx.markdown(AppVersionState.version), # type: ignore[operator]
45
- align="center",
46
- spacing="3",
47
- ),
48
- rx.hstack(
49
- data_model_reload_btn(),
50
- rx.link("ETL", href="/etl", font_size="1.1em"),
51
- rx.cond(
52
- AppVersionState.eval_enabled,
53
- rx.link("Eval", href="/eval", font_size="1.1em"),
54
- rx.fragment(),
55
- ),
56
- rx.link("Chat", href="/chat", font_size="1.1em"),
57
- rx.link("JIMS", href="/jims", font_size="1.1em"),
58
- telegram_link_box(),
59
- rx.color_mode.button(), # type: ignore[attr-defined]
60
- spacing="6",
61
- align="center",
62
- ),
63
- justify="between",
64
- align="center",
65
- width="100%",
66
- ),
67
- width="100%",
68
- padding="0.5em 1.25em",
69
- border_bottom="1px solid #e5e7eb",
70
- position="sticky",
71
- top="0",
72
- background_color=rx.color_mode_cond(light="white", dark="black"),
73
- style={
74
- "backdrop-filter": "blur(10px)", # enables non-transparent background
75
- },
76
- z_index="10",
77
- )
78
-
79
-
80
- def themed_data_table(
81
- *,
82
- data: rx.Var | list[Any],
83
- columns: rx.Var | list[str],
84
- width: str | rx.Var = "fit-content",
85
- max_width: str | rx.Var = "100%",
86
- **kwargs: Any,
87
- ) -> rx.Component:
88
- """Wrap rx.data_table with shared styling so it matches the app theme."""
89
-
90
- default_kwargs = {"pagination": True, "search": True, "sort": True}
91
- table_kwargs = {**default_kwargs, **kwargs}
92
-
93
- table_style = table_kwargs.pop("style", {})
94
- table_style = {"width": "fit-content", "minWidth": "100%", **table_style}
95
-
96
- container_style: dict[str, Any] = {
97
- "width": width,
98
- "maxWidth": max_width,
99
- "minWidth": "fit-content",
100
- }
101
-
102
- return rx.box(
103
- rx.data_table(data=data, columns=columns, style=table_style, **table_kwargs),
104
- class_name="datatable-surface",
105
- style=container_style,
106
- )
107
-
108
-
109
- def breadcrumbs(items: list[tuple[str, str]]) -> rx.Component:
110
- parts: list[rx.Component] = []
111
- for idx, (label, href) in enumerate(items):
112
- parts.append(rx.link(label, href=href))
113
- if idx < len(items) - 1:
114
- parts.append(rx.text("→", color="#9ca3af"))
115
- return rx.hstack(*parts, spacing="2", padding_y="0.5em")