agenta 0.5.3__tar.gz → 0.5.4__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.
Potentially problematic release.
This version of agenta might be problematic. Click here for more details.
- {agenta-0.5.3 → agenta-0.5.4}/PKG-INFO +1 -1
- {agenta-0.5.3 → agenta-0.5.4}/agenta/cli/helper.py +85 -39
- {agenta-0.5.3 → agenta-0.5.4}/agenta/cli/telemetry.py +2 -6
- {agenta-0.5.3 → agenta-0.5.4}/pyproject.toml +1 -1
- {agenta-0.5.3 → agenta-0.5.4}/README.md +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/__init__.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/cli/main.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/cli/variant_commands.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/client/Readme.md +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/client/__init__.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/client/api_models.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/client/client.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/config.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/config.toml +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/docker/docker-assets/Dockerfile.template +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/docker/docker-assets/README.md +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/docker/docker-assets/entrypoint.sh +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/docker/docker-assets/main.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/docker/docker_utils.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/sdk/__init__.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/sdk/agenta_decorator.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/sdk/agenta_init.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/sdk/context.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/sdk/router.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/sdk/types.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/sdk/utils/globals.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/sdk/utils/preinit.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/compose_email/README.md +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/compose_email/app.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/compose_email/env.example +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/compose_email/requirements.txt +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/compose_email/template.toml +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/extract_data_to_json/README.md +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/extract_data_to_json/app.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/extract_data_to_json/env.example +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/extract_data_to_json/template.toml +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/simple_prompt/README.md +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/simple_prompt/app.py +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/simple_prompt/env.example +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/simple_prompt/requirements.txt +0 -0
- {agenta-0.5.3 → agenta-0.5.4}/agenta/templates/simple_prompt/template.toml +0 -0
|
@@ -8,56 +8,102 @@ from typing import Any, List, MutableMapping
|
|
|
8
8
|
from agenta.client.api_models import AppVariant
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
credentials_file = agenta_dir / "config.toml"
|
|
11
|
+
from typing import Any, Optional
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
import toml
|
|
15
14
|
|
|
16
|
-
if credentials_file.exists():
|
|
17
|
-
config = toml.load(credentials_file)
|
|
18
|
-
api_key = config.get("api_key", None)
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
f"API Key found: {api_key}\nDo you want to use this API Key?"
|
|
24
|
-
).ask()
|
|
16
|
+
def get_global_config(var_name: str) -> Optional[Any]:
|
|
17
|
+
"""
|
|
18
|
+
Get the value of a global configuration variable.
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
elif confirm_api_key is None: # User pressed Ctrl+C
|
|
29
|
-
sys.exit(0)
|
|
20
|
+
Args:
|
|
21
|
+
var_name: the name of the variable to get
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
Returns:
|
|
24
|
+
the value of the variable, or None if it doesn't exist
|
|
25
|
+
"""
|
|
26
|
+
agenta_dir = Path.home() / ".agenta"
|
|
27
|
+
if not agenta_dir.exists():
|
|
28
|
+
return None
|
|
29
|
+
agenta_config_file = agenta_dir / "config.toml"
|
|
30
|
+
if not agenta_config_file.exists():
|
|
31
|
+
return None
|
|
32
|
+
global_config = toml.load(agenta_config_file)
|
|
33
|
+
if var_name not in global_config:
|
|
34
|
+
return None
|
|
35
|
+
return global_config[var_name]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def set_global_config(var_name: str, var_value: Any) -> None:
|
|
39
|
+
"""
|
|
40
|
+
Set the value of a global configuration variable.
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
Args:
|
|
43
|
+
var_name: the name of the variable to set
|
|
44
|
+
var_value: the value to set the variable to
|
|
45
|
+
"""
|
|
46
|
+
agenta_dir = Path.home() / ".agenta"
|
|
47
|
+
if not agenta_dir.exists():
|
|
48
|
+
agenta_dir.mkdir(exist_ok=True)
|
|
49
|
+
agenta_config_file = agenta_dir / "config.toml"
|
|
50
|
+
if not agenta_config_file.exists():
|
|
51
|
+
config = {}
|
|
52
|
+
with agenta_config_file.open("w") as config_file:
|
|
38
53
|
toml.dump(config, config_file)
|
|
54
|
+
global_config = toml.load(agenta_config_file)
|
|
55
|
+
global_config[var_name] = var_value
|
|
56
|
+
with open(agenta_config_file, "w") as config_file:
|
|
57
|
+
toml.dump(global_config, config_file)
|
|
39
58
|
|
|
40
|
-
return api_key
|
|
41
|
-
elif api_key is None: # User pressed Ctrl+C
|
|
42
|
-
sys.exit(0)
|
|
43
59
|
|
|
44
|
-
|
|
45
|
-
def load_telemetry_config() -> None:
|
|
60
|
+
def get_api_key() -> str:
|
|
46
61
|
"""
|
|
47
|
-
|
|
62
|
+
Retrieve or request the API key for accessing the Agenta platform.
|
|
63
|
+
|
|
64
|
+
This function first looks for an existing API key in the global config file.
|
|
65
|
+
If found, it prompts the user to confirm whether they'd like to use that key.
|
|
66
|
+
If not found, it asks the user to input a new key.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
str: The API key to be used for accessing the Agenta platform.
|
|
70
|
+
|
|
71
|
+
Raises:
|
|
72
|
+
SystemExit: If the user cancels the input by pressing Ctrl+C.
|
|
48
73
|
"""
|
|
49
74
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
75
|
+
api_key = get_global_config("api_key")
|
|
76
|
+
if api_key:
|
|
77
|
+
# API key exists in the config file, ask for confirmation
|
|
78
|
+
confirm_api_key = questionary.confirm(
|
|
79
|
+
f"API Key found: {api_key}\nDo you want to use this API Key?"
|
|
80
|
+
).ask()
|
|
81
|
+
|
|
82
|
+
if confirm_api_key:
|
|
83
|
+
return api_key
|
|
84
|
+
elif confirm_api_key is None: # User pressed Ctrl+C
|
|
85
|
+
sys.exit(0)
|
|
86
|
+
else:
|
|
87
|
+
api_key = questionary.text(
|
|
88
|
+
"(You can get your API Key here: https://demo.agenta.ai/settings?tab=apiKeys) "
|
|
89
|
+
"Please provide your API key:"
|
|
90
|
+
).ask()
|
|
91
|
+
|
|
92
|
+
if api_key:
|
|
93
|
+
set_global_config("api_key", api_key)
|
|
94
|
+
elif api_key is None: # User pressed Ctrl+C
|
|
95
|
+
sys.exit(0)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def init_telemetry_config() -> None:
|
|
99
|
+
if (
|
|
100
|
+
get_global_config("telemetry_tracking_enabled") is None
|
|
101
|
+
or get_global_config("telemetry_api_key") is None
|
|
102
|
+
):
|
|
103
|
+
set_global_config("telemetry_tracking_enabled", True)
|
|
104
|
+
set_global_config(
|
|
105
|
+
"telemetry_api_key", "phc_hmVSxIjTW1REBHXgj2aw4HW9X6CXb6FzerBgP9XenC7"
|
|
106
|
+
)
|
|
61
107
|
|
|
62
108
|
|
|
63
109
|
def update_variants_from_backend(
|
|
@@ -10,11 +10,7 @@ from posthog import Posthog
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
# Load telemetry configuration
|
|
13
|
-
helper.
|
|
14
|
-
|
|
15
|
-
# Load global toml file
|
|
16
|
-
agenta_dir = Path.home() / ".agenta"
|
|
17
|
-
global_toml_file = toml.load(agenta_dir / "config.toml")
|
|
13
|
+
helper.init_telemetry_config()
|
|
18
14
|
|
|
19
15
|
|
|
20
16
|
class EventTracking(Posthog):
|
|
@@ -48,5 +44,5 @@ class EventTracking(Posthog):
|
|
|
48
44
|
|
|
49
45
|
# Initialize event tracking
|
|
50
46
|
event_track = EventTracking(
|
|
51
|
-
|
|
47
|
+
helper.get_global_config("telemetry_api_key"), "https://app.posthog.com"
|
|
52
48
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|