jvcli 2.0.31__py3-none-any.whl → 2.1.1__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.
Files changed (59) hide show
  1. jvcli/__init__.py +4 -2
  2. jvcli/cli.py +2 -6
  3. jvcli/commands/client.py +14 -38
  4. jvcli/commands/create.py +91 -86
  5. jvcli/commands/server.py +0 -6
  6. jvcli/commands/startproject.py +1 -1
  7. jvcli/templates/{2.0.0 → 2.1.1}/project/README.md +4 -40
  8. jvcli/templates/{2.0.0 → 2.1.1}/project/actions/README.md +1 -1
  9. jvcli/templates/{2.0.0 → 2.1.1}/project/daf/README.md +1 -1
  10. jvcli/templates/{2.0.0 → 2.1.1}/project/env.example +7 -4
  11. jvcli/templates/2.1.1/project/main.jac +2 -0
  12. jvcli/templates/2.1.1/sourcefiles/action_app.py +23 -0
  13. jvcli/templates/2.1.1/sourcefiles/action_archetype.jac +49 -0
  14. jvcli/templates/{2.0.0 → 2.1.1/sourcefiles}/action_info.yaml +1 -1
  15. jvcli/templates/2.1.1/sourcefiles/action_lib.jac +3 -0
  16. jvcli/templates/{2.0.0 → 2.1.1/sourcefiles}/agent_descriptor.yaml +4 -4
  17. jvcli/templates/2.1.1/sourcefiles/interact_action_archetype.jac +58 -0
  18. jvcli/utils.py +1 -1
  19. {jvcli-2.0.31.dist-info → jvcli-2.1.1.dist-info}/METADATA +8 -47
  20. jvcli-2.1.1.dist-info/RECORD +40 -0
  21. jvcli/client/__init__.py +0 -1
  22. jvcli/client/app.py +0 -188
  23. jvcli/client/lib/__init__.py +0 -1
  24. jvcli/client/lib/page.py +0 -68
  25. jvcli/client/lib/utils.py +0 -312
  26. jvcli/client/lib/widgets.py +0 -295
  27. jvcli/client/pages/__init__.py +0 -1
  28. jvcli/client/pages/action_dashboard_page.py +0 -120
  29. jvcli/client/pages/analytics_page.py +0 -245
  30. jvcli/client/pages/chat_page.py +0 -150
  31. jvcli/client/pages/graph_page.py +0 -20
  32. jvcli/commands/clean.py +0 -29
  33. jvcli/commands/studio.py +0 -258
  34. jvcli/studio/assets/index-DDV79SDu.js +0 -213
  35. jvcli/studio/assets/index-DdMMONxd.css +0 -1
  36. jvcli/studio/index.html +0 -15
  37. jvcli/studio/jac_logo.png +0 -0
  38. jvcli/studio/tauri.svg +0 -6
  39. jvcli/studio/vite.svg +0 -1
  40. jvcli/studio-auth/assets/index-Bh6lyeXA.js +0 -218
  41. jvcli/studio-auth/assets/index-DdMMONxd.css +0 -1
  42. jvcli/studio-auth/index.html +0 -15
  43. jvcli/studio-auth/jac_logo.png +0 -0
  44. jvcli/studio-auth/tauri.svg +0 -6
  45. jvcli/studio-auth/vite.svg +0 -1
  46. jvcli/templates/2.0.0/project/main.jac +0 -2
  47. jvcli-2.0.31.dist-info/RECORD +0 -61
  48. /jvcli/templates/{2.0.0 → 2.1.1}/project/gitignore.example +0 -0
  49. /jvcli/templates/{2.0.0 → 2.1.1}/project/globals.jac +0 -0
  50. /jvcli/templates/{2.0.0 → 2.1.1}/project/tests/README.md +0 -0
  51. /jvcli/templates/{CHANGELOG.md → 2.1.1/sourcefiles/CHANGELOG.md} +0 -0
  52. /jvcli/templates/{README.md → 2.1.1/sourcefiles/README.md} +0 -0
  53. /jvcli/templates/{2.0.0 → 2.1.1/sourcefiles}/agent_info.yaml +0 -0
  54. /jvcli/templates/{2.0.0 → 2.1.1/sourcefiles}/agent_knowledge.yaml +0 -0
  55. /jvcli/templates/{2.0.0 → 2.1.1/sourcefiles}/agent_memory.yaml +0 -0
  56. {jvcli-2.0.31.dist-info → jvcli-2.1.1.dist-info}/WHEEL +0 -0
  57. {jvcli-2.0.31.dist-info → jvcli-2.1.1.dist-info}/entry_points.txt +0 -0
  58. {jvcli-2.0.31.dist-info → jvcli-2.1.1.dist-info}/licenses/LICENSE +0 -0
  59. {jvcli-2.0.31.dist-info → jvcli-2.1.1.dist-info}/top_level.txt +0 -0
@@ -5,12 +5,12 @@ description: |-
5
5
  actions:
6
6
  - action: jivas/intro_interact_action
7
7
  context:
8
- version: "0.0.1"
8
+ version: "~0.1.0"
9
9
  enabled: true
10
10
  prompt: "In a natural and brief manner:\na. Introduce yourself by name and explain your role."
11
11
  - action: jivas/persona_interact_action
12
12
  context:
13
- version: "0.0.1"
13
+ version: "~0.1.0"
14
14
  enabled: true
15
15
  anchors: []
16
16
  timezone: "UTC"
@@ -21,10 +21,10 @@ actions:
21
21
  model_name: "gpt-4o"
22
22
  - action: jivas/agent_utils_action
23
23
  context:
24
- version: "0.0.1"
24
+ version: "~0.1.0"
25
25
  enabled: true
26
26
  - action: jivas/langchain_model_action
27
27
  context:
28
- version: "0.0.1"
28
+ version: "~0.0.1"
29
29
  enabled: true
30
30
  api_key: ""
@@ -0,0 +1,58 @@
1
+ import logging;
2
+ import traceback;
3
+ import from typing { Union }
4
+ import from logging { Logger }
5
+ import from jivas.agent.action.interact_action { InteractAction }
6
+ import from jivas.agent.action.agent_graph_walker { agent_graph_walker }
7
+
8
+ node {{archetype}}(InteractAction) {
9
+
10
+ # Declare your has variables to be persisted here
11
+ # e.g has var_a : str = "string";
12
+
13
+ # set up logger
14
+ static has logger:Logger = logging.getLogger(__name__);
15
+
16
+ can touch(visitor: agent_graph_walker) -> bool {
17
+ # override to authorize, redirect or deny the interact walker from running execute
18
+ }
19
+
20
+ can execute(visitor: agent_graph_walker) -> None {
21
+ # override to implement action execution
22
+ }
23
+
24
+ def healthcheck() -> Union[bool, dict] {
25
+ # override to implement healthcheck operation
26
+ # optionally returns a dict of (status:bool, severity:str [error|warning], message:str) if more information is needed
27
+ return True;
28
+ }
29
+
30
+ #*
31
+ (Optional Abilities - Uncomment and implement as needed)
32
+
33
+ # override to execute operations upon registration of action
34
+ def on_register() { }
35
+
36
+ # override to execute operations upon the reload of action
37
+ def on_reload() { }
38
+
39
+ # override to execute any setup code when all actions are in place
40
+ def post_register() { }
41
+
42
+ # override to execute operations upon enabling of action
43
+ def on_enable() { }
44
+
45
+ # override to execute operations upon disabling of action
46
+ def on_disable() { }
47
+
48
+ # override to execute operations upon deregistration of action
49
+ def on_deregister() { }
50
+
51
+ # override to implement pulse operation
52
+ def pulse() { }
53
+
54
+ # override to furnish analytics data for the action
55
+ def analytics() { }
56
+
57
+ *#
58
+ }
jvcli/utils.py CHANGED
@@ -11,7 +11,7 @@ import requests
11
11
  import semver
12
12
  import yaml
13
13
 
14
- from jvcli import __supported__jivas__versions__
14
+ from jvcli import __supported__jivas__versions__ # type: ignore[attr-defined]
15
15
  from jvcli.api import RegistryAPI
16
16
  from jvcli.auth import load_token
17
17
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jvcli
3
- Version: 2.0.31
3
+ Version: 2.1.1
4
4
  Summary: CLI tool for Jivas Package Repository
5
5
  Home-page: https://github.com/TrueSelph/jvcli
6
6
  Author: TrueSelph Inc.
@@ -12,14 +12,13 @@ Requires-Dist: click>=8.1.8
12
12
  Requires-Dist: requests>=2.32.3
13
13
  Requires-Dist: packaging>=24.2
14
14
  Requires-Dist: pyaml>=25.1.0
15
- Requires-Dist: jac-cloud==0.1.20
16
- Requires-Dist: streamlit>=1.42.0
17
- Requires-Dist: streamlit-elements>=0.1.0
18
- Requires-Dist: streamlit-router>=0.1.8
19
- Requires-Dist: streamlit-javascript>=0.1.5
20
15
  Requires-Dist: python-dotenv>=1.0.0
21
16
  Requires-Dist: semver>=3.0.4
22
17
  Requires-Dist: node-semver>=0.9.0
18
+ Requires-Dist: jaclang
19
+ Requires-Dist: pymongo
20
+ Requires-Dist: uvicorn
21
+ Requires-Dist: fastapi
23
22
  Provides-Extra: dev
24
23
  Requires-Dist: pre-commit; extra == "dev"
25
24
  Requires-Dist: pytest; extra == "dev"
@@ -152,17 +151,6 @@ This command creates a directory structure with:
152
151
  - Main JAC file for your JIVAS application
153
152
  - Configuration files and shell scripts for easy management
154
153
 
155
- #### `jvcli clean`
156
-
157
- Clean the Jac files in the current directory and subdirectories by removing compiled artifacts and temporary files.
158
-
159
- ```sh
160
- # Clean the current directory
161
- jvcli clean
162
- ```
163
-
164
- This command executes `jac clean` under the hood and ensures your project is in a clean state before rebuilding or deploying.
165
-
166
154
  ### Create Commands
167
155
 
168
156
  Create commands help you generate new resources like actions, agents, and namespaces with the proper structure and configuration.
@@ -523,8 +511,7 @@ jvcli server initagents
523
511
  This command:
524
512
  1. Checks if the server is running
525
513
  2. Logs in to the server
526
- 3. Cleans JAC files before reinitializing
527
- 4. Sends a request to the server to reinitialize all agents
514
+ 3. Sends a request to the server to reinitialize all agents
528
515
 
529
516
  #### `jvcli server importagent`
530
517
 
@@ -548,31 +535,6 @@ This command:
548
535
  3. Sends a request to import the specified agent
549
536
  4. Displays the agent ID upon successful import
550
537
 
551
- ### Studio Commands
552
-
553
- Studio commands help you manage the Jivas Studio, a web-based development environment for Jivas.
554
-
555
- #### `jvcli studio launch`
556
-
557
- Launch the Jivas Studio on a specified port. Jivas Studio provides a visual interface for building and managing agents.
558
-
559
- ```sh
560
- # Launch with default settings
561
- jvcli studio launch
562
-
563
- # Launch on a custom port
564
- jvcli studio launch --port 9000
565
-
566
- # Launch with authentication required
567
- jvcli studio launch --require-auth
568
- ```
569
-
570
- Options:
571
- - `--port`: Port for the studio to launch on (default: 8989)
572
- - `--require-auth`: Require authentication for studio API access (default: false)
573
-
574
- When launched, the Studio will be accessible via a web browser at `http://localhost:<port>`.
575
-
576
538
  ### Client Commands
577
539
 
578
540
  Client commands help you manage the Jivas Client, which provides a user interface for interacting with agents.
@@ -590,15 +552,14 @@ jvcli client launch --port 9001
590
552
 
591
553
  # Launch with custom server URLs
592
554
  jvcli client launch \
593
- --jivas_url http://my-server:8000 \
594
- --studio_url http://my-studio:8989
595
- ```
555
+ --jivas_url http://my-server:8000
596
556
 
597
557
  Options:
598
558
  - `--port`: Port for the client to launch on (default: 8501)
599
559
  - `--jivas_url`: URL for the Jivas API (default: http://localhost:8000 or JIVAS_BASE_URL env var)
600
560
  - `--studio_url`: URL for the Jivas Studio (default: http://localhost:8989 or JIVAS_STUDIO_URL env var)
601
561
 
562
+
602
563
  When launched, the Client will be accessible via a web browser at `http://localhost:<port>`.
603
564
 
604
565
  ## 🔰 Contributing
@@ -0,0 +1,40 @@
1
+ jvcli/__init__.py,sha256=idcJoHnioHW4Jpmp4bnThqSKiAK21U_1SCU52Vgb27Y,223
2
+ jvcli/api.py,sha256=gd-EP1e75e7HijyrP-EF6i_jjCo6YUeSbm1l5daKLfQ,10352
3
+ jvcli/auth.py,sha256=mHP425hvXhNxzeX--cApkrP7SdDPmfG6V0Li5TLHmIg,1953
4
+ jvcli/cli.py,sha256=xDFaPyhteTU7yHZ_o-0lmL3B8jWmb7RFfC_LSOruhkw,1090
5
+ jvcli/utils.py,sha256=03wwb3S0NXaeS13rSlMuCiMWXak_iK3RD7S2XWv6Xn4,8369
6
+ jvcli/commands/__init__.py,sha256=bjZvM55MC2NugvRlxkEU9CDDP9NnsygcsGZewj1gQcg,57
7
+ jvcli/commands/auth.py,sha256=lO5G1_TCbxhOfy7xH9EULwvCLqf7iQTF9Q3MrpAtHPY,1611
8
+ jvcli/commands/client.py,sha256=JwspKUKPFgaG_VaB2yG4ODDFj4FLegRlR3IU0I-jxr4,705
9
+ jvcli/commands/create.py,sha256=PQf1KD-rcCj5I-YOSZXUjUOkMSgyFxyO9qQqtm0ssFk,13172
10
+ jvcli/commands/download.py,sha256=GiLX_43CQOW9d5vF04fAszOWh3AB-7Mgote4tJ9RVng,3416
11
+ jvcli/commands/info.py,sha256=NyIDpR_AGMMSFPE0tFZv4dIuv_gwqrfd589zQAA_Q3s,2685
12
+ jvcli/commands/publish.py,sha256=TntkWRK6P4m0aTWRmFQtT5jYeEJqgxWJKvpUiHlrTQA,6637
13
+ jvcli/commands/server.py,sha256=lZsXqbrh1ZbZ8zlUESoS84JO4-1J0GLKGcrUadwPrJc,7929
14
+ jvcli/commands/startproject.py,sha256=cU88G4wfTA9_3QeoLK3HbYKLqxQxfpyeV8m8P45uA10,3405
15
+ jvcli/commands/update.py,sha256=LwCLg-W1b8WSdFkiiJ8WwTit2HJXTLpM5OQ4WBTe9C4,1997
16
+ jvcli/templates/2.1.1/project/README.md,sha256=f3njSjmQZRIK0lJ-0udH4118G_GQsYGVNKNrknRUVQQ,16639
17
+ jvcli/templates/2.1.1/project/env.example,sha256=PFTk68ZJOvO0wT4pvy2QPxSIzCHAmBVCZDnOcTqmDbQ,1325
18
+ jvcli/templates/2.1.1/project/gitignore.example,sha256=KG1wl-o8ltNs4d8qCVgok5F2waUYqCJ5-HJq58Kh79I,530
19
+ jvcli/templates/2.1.1/project/globals.jac,sha256=CEt7L25wEZfE6TupqpM1ilHbtJMQQWExDQ5GJlkHPts,56
20
+ jvcli/templates/2.1.1/project/main.jac,sha256=6dw30dozEqSEVb1ELn3Ttk4lPqnn-LZLoV1gGzGmC14,40
21
+ jvcli/templates/2.1.1/project/actions/README.md,sha256=z92-Oc2Py6zVRb2BBzbSWBdHaXTOledSHsRqQYOf2Bw,1742
22
+ jvcli/templates/2.1.1/project/daf/README.md,sha256=HKzoqEM7991NStDdL4lgWzhbv9qCyGW8Lspy0WREPo0,1682
23
+ jvcli/templates/2.1.1/project/tests/README.md,sha256=-1ZXkxuUKa6tMw_jlF3rpCvUFq8ijW2L-nSuAkbCANo,917
24
+ jvcli/templates/2.1.1/sourcefiles/CHANGELOG.md,sha256=aci-j1gPbzyywQyPY9M2PJkZLVTKgdDuJYcFpdPpKHQ,66
25
+ jvcli/templates/2.1.1/sourcefiles/README.md,sha256=VcLV54kkjp_m-cVVuH_OTdIJ39T41sM2TwKH9ISyqbk,51
26
+ jvcli/templates/2.1.1/sourcefiles/action_app.py,sha256=v0aUmIpzpzkaa1zbMl1Ixf_3_fCqZqji-euefgh8r48,743
27
+ jvcli/templates/2.1.1/sourcefiles/action_archetype.jac,sha256=s-JrUMa0mC1aqs5px2iKJHFhTRZIlvD787AJsBn-eu0,1375
28
+ jvcli/templates/2.1.1/sourcefiles/action_info.yaml,sha256=rOwJCK2F7ew4olydbPr2d1R0W0MbAX9v1QVWuzA-sXo,303
29
+ jvcli/templates/2.1.1/sourcefiles/action_lib.jac,sha256=ZpptC4rcHL9hIxf2egHAeZLPOuPAIbpMHoDnCzfcxQI,62
30
+ jvcli/templates/2.1.1/sourcefiles/agent_descriptor.yaml,sha256=5spl44ytEdvTWuJFe1aJcw10usmxrrqwgNDkyfXW_xk,746
31
+ jvcli/templates/2.1.1/sourcefiles/agent_info.yaml,sha256=3olXRQDQG-543o7zSWWT23kJsK29QGhdx6-tOLXvCk8,207
32
+ jvcli/templates/2.1.1/sourcefiles/agent_knowledge.yaml,sha256=hI0ifr0ICiZGce-oUFovBOmDWxGU1Z2M10WyZH_wS2g,284
33
+ jvcli/templates/2.1.1/sourcefiles/agent_memory.yaml,sha256=_MBgObZcW1UzwWuYQVJiPZ_7TvYbGrDgd-xMuzJEkVo,9
34
+ jvcli/templates/2.1.1/sourcefiles/interact_action_archetype.jac,sha256=S37dEHyoCkxCu3gTOOTe0UQIUD11XOEQb0vffm9c-yk,1735
35
+ jvcli-2.1.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
36
+ jvcli-2.1.1.dist-info/METADATA,sha256=Qo1QRnASoFozmKEB1GNndzrJPGBA_6vyZYvQI3Yg3lE,20458
37
+ jvcli-2.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
38
+ jvcli-2.1.1.dist-info/entry_points.txt,sha256=XunGcL0LWmIMIytaUckUA27czEf8M2Y4aTOfYIpOgrQ,42
39
+ jvcli-2.1.1.dist-info/top_level.txt,sha256=akZnN9Zy1dFT93N0ms-C8ZXUn-xlhq37nO3jSRp0Y6o,6
40
+ jvcli-2.1.1.dist-info/RECORD,,
jvcli/client/__init__.py DELETED
@@ -1 +0,0 @@
1
- """This package contains the client-side code for the JVCLI client streamlit app."""
jvcli/client/app.py DELETED
@@ -1,188 +0,0 @@
1
- """This module contains the main application logic for the JVCLI client."""
2
-
3
- import os
4
-
5
- import requests
6
- import streamlit as st
7
- from streamlit_router import StreamlitRouter
8
-
9
- from jvcli.client.lib.page import Page
10
- from jvcli.client.lib.utils import call_list_actions, call_list_agents, load_function
11
- from jvcli.client.pages import (
12
- action_dashboard_page,
13
- analytics_page,
14
- chat_page,
15
- graph_page,
16
- )
17
-
18
- JIVAS_BASE_URL = os.environ.get("JIVAS_BASE_URL", "http://localhost:8000")
19
- JIVAS_STUDIO_URL = os.environ.get("JIVAS_STUDIO_URL", "http://localhost:8989")
20
-
21
-
22
- def handle_agent_selection() -> None:
23
- """Handle the selection of an agent."""
24
- if "selected_agent" in st.session_state:
25
- st.query_params["agent"] = st.session_state.selected_agent["id"]
26
- st.session_state.messages = {}
27
-
28
-
29
- def login_form() -> None:
30
- """Render the login form and handle login logic."""
31
- login_url = f"{JIVAS_BASE_URL}/user/login"
32
-
33
- if os.environ.get("JIVAS_ENVIRONMENT") == "development":
34
- email = os.environ.get("JIVAS_USER", "admin@jivas.com")
35
- password = os.environ.get("JIVAS_PASSWORD", "password")
36
-
37
- response = requests.post(login_url, json={"email": email, "password": password})
38
-
39
- if response.status_code == 200:
40
- st.session_state.ROOT_ID = response.json()["user"]["root_id"]
41
- st.session_state.TOKEN = response.json()["token"]
42
- st.session_state.EXPIRATION = response.json()["user"]["expiration"]
43
- st.rerun()
44
-
45
- else:
46
-
47
- with st.container(border=True):
48
- st.header("Login")
49
-
50
- email = st.text_input("Email")
51
- password = st.text_input("Password", type="password")
52
-
53
- if st.button("Login"):
54
- response = requests.post(
55
- login_url, json={"email": email, "password": password}
56
- )
57
-
58
- if response.status_code == 200:
59
- st.session_state.ROOT_ID = response.json()["user"]["root_id"]
60
- st.session_state.TOKEN = response.json()["token"]
61
- st.session_state.EXPIRATION = response.json()["user"]["expiration"]
62
- st.rerun()
63
-
64
-
65
- def main() -> None:
66
- """Main function to render the Streamlit app."""
67
- hide_sidebar = st.query_params.get("hide_sidebar")
68
- router = StreamlitRouter()
69
-
70
- # Initialize session state
71
- for key in [
72
- "messages",
73
- "session_id",
74
- "agents",
75
- "actions_data",
76
- "TOKEN",
77
- "ROOT_ID",
78
- "EXPIRATION",
79
- ]:
80
- if key not in st.session_state:
81
- if key == "messages":
82
- st.session_state[key] = {}
83
- else:
84
- st.session_state[key] = [] if key in ["actions_data"] else ""
85
-
86
- if hide_sidebar == "true":
87
- st.markdown(
88
- """
89
- <style>
90
- [data-testid="stSidebar"] {
91
- display: none;
92
- }
93
- [data-testid="stSidebarCollapsedControl"] {
94
- display: none;
95
- }
96
- </style>
97
- """,
98
- unsafe_allow_html=True,
99
- )
100
-
101
- # Setup the sidebar
102
- with st.sidebar:
103
- st.title("✧ JIVAS Manager")
104
- # retrieve agent list
105
- agents = call_list_agents()
106
-
107
- try:
108
- selected_agent_id = st.query_params["agent"]
109
- except KeyError:
110
- st.query_params["agent"] = agents[0]["id"] if agents else None
111
- selected_agent_id = st.query_params["agent"]
112
-
113
- selected_agent_index = next(
114
- (i for i, item in enumerate(agents) if item["id"] == selected_agent_id),
115
- len(agents) - 1 if agents else None,
116
- )
117
-
118
- # Render the ComboBox using streamlit-elements
119
- st.sidebar.selectbox(
120
- "Agent",
121
- agents,
122
- index=selected_agent_index,
123
- placeholder="Select agent...",
124
- format_func=lambda x: x["label"] if "label" in x else x,
125
- on_change=handle_agent_selection,
126
- key="selected_agent",
127
- )
128
-
129
- # Expander for the menu
130
- with st.expander("Menu", True):
131
- Page(router).item(analytics_page.render, "Dashboard", "/").st_button()
132
- Page(router).item(chat_page.render, "Chat", "/chat").st_button()
133
- Page(router).item(
134
- action_dashboard_page.render, "Actions", "/actions"
135
- ).st_button()
136
- Page(router).item(graph_page.render, "Graph", "/graph").st_button()
137
- st.button(
138
- "Logout",
139
- on_click=action_dashboard_page.logout,
140
- use_container_width=True,
141
- )
142
-
143
- with st.expander("Action Apps", False):
144
- if selected_agent_id and (
145
- actions_data := call_list_actions(agent_id=selected_agent_id)
146
- ):
147
- st.session_state.actions_data = actions_data
148
-
149
- # Sort actions_data alphabetically by the action's title
150
- actions_data.sort(
151
- key=lambda action: action.get("_package", {})
152
- .get("meta", {})
153
- .get("title", "")
154
- )
155
-
156
- for action in actions_data:
157
- package = action.get("_package", {})
158
-
159
- if package.get("config", {}).get("app", False):
160
- func = load_function(
161
- f"{package['config']['path']}/app/app.py",
162
- "render",
163
- router=router,
164
- agent_id=selected_agent_id,
165
- action_id=action["id"],
166
- info=package,
167
- )
168
- # register the route to the app
169
- Page(router).item(
170
- callback=func,
171
- label=package["meta"]["title"],
172
- path=f'/{Page.normalize_label(package["meta"]["title"])}',
173
- ).st_button()
174
- router.serve()
175
-
176
-
177
- # Initialize Streamlit app config
178
- if __name__ == "__main__":
179
- token_query = st.query_params.get("token")
180
- if token_query:
181
- st.session_state.TOKEN = token_query
182
-
183
- if "TOKEN" not in st.session_state:
184
- st.set_page_config(page_title="JIVAS Manager", page_icon="💠")
185
- login_form()
186
- else:
187
- st.set_page_config(page_title="JIVAS Manager", page_icon="💠", layout="wide")
188
- main()
@@ -1 +0,0 @@
1
- """jvcli client library functions."""
jvcli/client/lib/page.py DELETED
@@ -1,68 +0,0 @@
1
- """This module contains the Page class used for managing pages in the JVCLI client."""
2
-
3
- from typing import Callable, Dict, Optional
4
-
5
- import streamlit as st
6
- from streamlit_router import StreamlitRouter
7
-
8
-
9
- class Page:
10
- """Class to manage pages in the JVCLI client."""
11
-
12
- def __init__(self, router: StreamlitRouter) -> None:
13
- """Initialize the Page with a router."""
14
- self._router: StreamlitRouter = router
15
- self._callback: Optional[Callable] = None
16
- self._label: Optional[str] = None
17
- self._path: Optional[str] = None
18
- self._key: Optional[str] = None
19
- self._args: Optional[Dict] = None
20
-
21
- def item(
22
- self, callback: Callable, label: str, path: str, args: Optional[Dict] = None
23
- ) -> "Page":
24
- """
25
- Register the page callable on the given route.
26
-
27
- Args:
28
- callback (Callable): The function to call for the page.
29
- label (str): The label for the page.
30
- path (str): The path for the page.
31
- args (Optional[Dict], optional): Additional arguments for the page. Defaults to None.
32
-
33
- Returns:
34
- Page: The current Page instance.
35
- """
36
- if args is None:
37
- args = {}
38
- self._callback = callback
39
- self._label = label
40
- self._path = path
41
- self._args = args
42
- self._key = f"{Page.normalize_label(label)}"
43
- self._router.register(func=self._callback, path=self._path, endpoint=self._key)
44
- return self
45
-
46
- def st_button(self) -> None:
47
- """Add the Streamlit link for this page wherever it is called."""
48
- if st.button(self._label, key=self._key, use_container_width=True):
49
- self._router.redirect(*self._router.build(self._key, self._args))
50
-
51
- @staticmethod
52
- def normalize_label(label: str) -> str:
53
- """
54
- Normalize the label to be used as a key.
55
-
56
- Args:
57
- label (str): The label to normalize.
58
-
59
- Returns:
60
- str: The normalized label.
61
- """
62
- return (
63
- "".join(char.lower() for char in label if char.isascii())
64
- .strip()
65
- .replace(" ", "-")
66
- .replace("/", "-")
67
- .replace(":", "-")
68
- )