agenta 0.24.1a0__py3-none-any.whl → 0.24.2a1__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 agenta might be problematic. Click here for more details.

Files changed (132) hide show
  1. agenta/cli/variant_commands.py +15 -10
  2. agenta/client/Readme.md +72 -64
  3. agenta/client/api.py +1 -1
  4. agenta/client/backend/__init__.py +14 -9
  5. agenta/client/backend/apps/client.py +1669 -0
  6. agenta/client/backend/bases/client.py +190 -0
  7. agenta/client/backend/client.py +2102 -868
  8. agenta/client/backend/configs/client.py +598 -0
  9. agenta/client/backend/containers/client.py +638 -0
  10. agenta/client/backend/{resources/containers → containers}/types/container_templates_response.py +1 -2
  11. agenta/client/backend/core/__init__.py +29 -0
  12. agenta/client/backend/core/client_wrapper.py +42 -9
  13. agenta/client/backend/core/datetime_utils.py +1 -1
  14. agenta/client/backend/core/file.py +43 -0
  15. agenta/client/backend/core/http_client.py +553 -0
  16. agenta/client/backend/core/jsonable_encoder.py +33 -39
  17. agenta/client/backend/core/pydantic_utilities.py +212 -0
  18. agenta/client/backend/core/query_encoder.py +60 -0
  19. agenta/client/backend/core/remove_none_from_dict.py +2 -2
  20. agenta/client/backend/core/request_options.py +32 -0
  21. agenta/client/backend/core/serialization.py +179 -0
  22. agenta/client/backend/environments/client.py +190 -0
  23. agenta/client/backend/evaluations/client.py +1462 -0
  24. agenta/client/backend/evaluators/client.py +911 -0
  25. agenta/client/backend/observability/client.py +1271 -0
  26. agenta/client/backend/testsets/client.py +1132 -0
  27. agenta/client/backend/types/__init__.py +8 -6
  28. agenta/client/backend/types/aggregated_result.py +14 -29
  29. agenta/client/backend/types/aggregated_result_evaluator_config.py +1 -2
  30. agenta/client/backend/types/app.py +13 -28
  31. agenta/client/backend/types/app_variant_response.py +21 -37
  32. agenta/client/backend/types/app_variant_revision.py +17 -32
  33. agenta/client/backend/types/base_output.py +13 -28
  34. agenta/client/backend/types/body_import_testset.py +16 -31
  35. agenta/client/backend/types/config_db.py +16 -31
  36. agenta/client/backend/types/correct_answer.py +22 -0
  37. agenta/client/backend/types/create_app_output.py +13 -28
  38. agenta/client/backend/types/create_span.py +33 -50
  39. agenta/client/backend/types/create_trace_response.py +16 -31
  40. agenta/client/backend/types/docker_env_vars.py +13 -28
  41. agenta/client/backend/types/environment_output.py +21 -36
  42. agenta/client/backend/types/environment_output_extended.py +21 -36
  43. agenta/client/backend/types/environment_revision.py +18 -33
  44. agenta/client/backend/types/error.py +16 -31
  45. agenta/client/backend/types/evaluation.py +20 -34
  46. agenta/client/backend/types/evaluation_scenario.py +18 -33
  47. agenta/client/backend/types/evaluation_scenario_input.py +16 -31
  48. agenta/client/backend/types/evaluation_scenario_output.py +18 -33
  49. agenta/client/backend/types/evaluation_scenario_result.py +14 -29
  50. agenta/client/backend/types/evaluation_scenario_score_update.py +13 -28
  51. agenta/client/backend/types/evaluation_status_enum.py +11 -33
  52. agenta/client/backend/types/evaluation_type.py +3 -21
  53. agenta/client/backend/types/evaluator.py +18 -32
  54. agenta/client/backend/types/evaluator_config.py +20 -33
  55. agenta/client/backend/types/get_config_response.py +16 -31
  56. agenta/client/backend/types/http_validation_error.py +14 -29
  57. agenta/client/backend/types/human_evaluation.py +17 -32
  58. agenta/client/backend/types/human_evaluation_scenario.py +21 -37
  59. agenta/client/backend/types/human_evaluation_scenario_input.py +13 -28
  60. agenta/client/backend/types/human_evaluation_scenario_output.py +13 -28
  61. agenta/client/backend/types/human_evaluation_scenario_update.py +26 -41
  62. agenta/client/backend/types/human_evaluation_update.py +14 -29
  63. agenta/client/backend/types/image.py +18 -33
  64. agenta/client/backend/types/invite_request.py +13 -28
  65. agenta/client/backend/types/list_api_keys_response.py +18 -33
  66. agenta/client/backend/types/llm_run_rate_limit.py +13 -28
  67. agenta/client/backend/types/llm_tokens.py +16 -31
  68. agenta/client/backend/types/lm_providers_enum.py +21 -0
  69. agenta/client/backend/types/new_human_evaluation.py +13 -28
  70. agenta/client/backend/types/new_testset.py +16 -31
  71. agenta/client/backend/types/organization.py +22 -36
  72. agenta/client/backend/types/organization_output.py +13 -28
  73. agenta/client/backend/types/outputs.py +5 -0
  74. agenta/client/backend/types/permission.py +36 -137
  75. agenta/client/backend/types/result.py +17 -32
  76. agenta/client/backend/types/simple_evaluation_output.py +13 -28
  77. agenta/client/backend/types/span.py +23 -38
  78. agenta/client/backend/types/span_detail.py +26 -40
  79. agenta/client/backend/types/span_status_code.py +1 -25
  80. agenta/client/backend/types/span_variant.py +16 -31
  81. agenta/client/backend/types/template.py +14 -29
  82. agenta/client/backend/types/template_image_info.py +21 -35
  83. agenta/client/backend/types/test_set_output_response.py +16 -32
  84. agenta/client/backend/types/test_set_simple_response.py +13 -28
  85. agenta/client/backend/types/trace_detail.py +26 -40
  86. agenta/client/backend/types/update_app_output.py +22 -0
  87. agenta/client/backend/types/uri.py +13 -28
  88. agenta/client/backend/types/validation_error.py +13 -28
  89. agenta/client/backend/types/variant_action.py +14 -29
  90. agenta/client/backend/types/variant_action_enum.py +1 -19
  91. agenta/client/backend/types/with_pagination.py +14 -30
  92. agenta/client/backend/types/workspace_member_response.py +14 -29
  93. agenta/client/backend/types/workspace_permission.py +18 -33
  94. agenta/client/backend/types/workspace_response.py +20 -35
  95. agenta/client/backend/types/workspace_role.py +11 -37
  96. agenta/client/backend/types/workspace_role_response.py +17 -32
  97. agenta/client/backend/variants/client.py +1447 -0
  98. agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py +8 -0
  99. agenta/sdk/decorators/llm_entrypoint.py +8 -13
  100. agenta/sdk/tracing/llm_tracing.py +1 -1
  101. {agenta-0.24.1a0.dist-info → agenta-0.24.2a1.dist-info}/METADATA +1 -1
  102. agenta-0.24.2a1.dist-info/RECORD +175 -0
  103. agenta/client/backend/resources/__init__.py +0 -31
  104. agenta/client/backend/resources/apps/client.py +0 -977
  105. agenta/client/backend/resources/bases/client.py +0 -127
  106. agenta/client/backend/resources/configs/client.py +0 -377
  107. agenta/client/backend/resources/containers/client.py +0 -383
  108. agenta/client/backend/resources/environments/client.py +0 -131
  109. agenta/client/backend/resources/evaluations/client.py +0 -1008
  110. agenta/client/backend/resources/evaluators/client.py +0 -594
  111. agenta/client/backend/resources/observability/client.py +0 -1187
  112. agenta/client/backend/resources/testsets/client.py +0 -689
  113. agenta/client/backend/resources/variants/client.py +0 -796
  114. agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -7
  115. agenta/client/backend/types/evaluation_webhook.py +0 -36
  116. agenta/client/backend/types/feedback.py +0 -40
  117. agenta/client/backend/types/span_kind.py +0 -49
  118. agenta-0.24.1a0.dist-info/RECORD +0 -169
  119. /agenta/client/backend/{resources/apps → apps}/__init__.py +0 -0
  120. /agenta/client/backend/{resources/bases → bases}/__init__.py +0 -0
  121. /agenta/client/backend/{resources/configs → configs}/__init__.py +0 -0
  122. /agenta/client/backend/{resources/containers → containers}/__init__.py +0 -0
  123. /agenta/client/backend/{resources/containers → containers}/types/__init__.py +0 -0
  124. /agenta/client/backend/{resources/environments → environments}/__init__.py +0 -0
  125. /agenta/client/backend/{resources/evaluations → evaluations}/__init__.py +0 -0
  126. /agenta/client/backend/{resources/evaluators → evaluators}/__init__.py +0 -0
  127. /agenta/client/backend/{resources/observability → observability}/__init__.py +0 -0
  128. /agenta/client/backend/{resources/testsets → testsets}/__init__.py +0 -0
  129. /agenta/client/backend/{resources/variants → variants}/__init__.py +0 -0
  130. /agenta/client/backend/{resources/variants → variants}/types/__init__.py +0 -0
  131. {agenta-0.24.1a0.dist-info → agenta-0.24.2a1.dist-info}/WHEEL +0 -0
  132. {agenta-0.24.1a0.dist-info → agenta-0.24.2a1.dist-info}/entry_points.txt +0 -0
@@ -16,7 +16,7 @@ from agenta.client.backend.client import AgentaApi
16
16
  from agenta.client.api import add_variant_to_server
17
17
  from agenta.client.api_models import AppVariant, Image
18
18
  from agenta.docker.docker_utils import build_tar_docker_container
19
- from agenta.client.backend.types.variant_action import VariantActionEnum, VariantAction
19
+ from agenta.client.backend.types.variant_action import VariantAction
20
20
 
21
21
 
22
22
  BACKEND_URL_SUFFIX = os.environ.get("BACKEND_URL_SUFFIX", "api")
@@ -151,12 +151,18 @@ def add_variant(
151
151
  variant_id = config["variant_ids"][config["variants"].index(variant_name)]
152
152
  client.variants.update_variant_image(
153
153
  variant_id=variant_id,
154
- request=image, # because Fern code uses "request: Image" instead of "image: Image"
154
+ docker_id=image.docker_id,
155
+ tags=image.tags,
156
+ type=image.type,
155
157
  ) # this automatically restarts
156
158
  else:
157
159
  click.echo(click.style(f"Adding {variant_name} to server...", fg="yellow"))
158
160
  response = add_variant_to_server(
159
- app_id, base_name, image, f"{host}/{BACKEND_URL_SUFFIX}", api_key
161
+ app_id,
162
+ base_name,
163
+ image,
164
+ f"{host}/{BACKEND_URL_SUFFIX}",
165
+ api_key,
160
166
  )
161
167
  variant_id = response["variant_id"]
162
168
  config["variants"].append(variant_name)
@@ -174,7 +180,7 @@ def add_variant(
174
180
  if overwrite:
175
181
  # Track a deployment event
176
182
  if tracking_enabled:
177
- get_user_id = client.user_profile()
183
+ get_user_id = client.fetch_user_profile()
178
184
  user_id = get_user_id["id"]
179
185
  event_track.capture_event(
180
186
  "app_deployment",
@@ -196,7 +202,7 @@ def add_variant(
196
202
  else:
197
203
  # Track a deployment event
198
204
  if tracking_enabled:
199
- get_user_id = client.user_profile()
205
+ get_user_id = client.fetch_user_profile()
200
206
  user_id = get_user_id["id"]
201
207
  event_track.capture_event(
202
208
  "app_deployment",
@@ -261,12 +267,11 @@ def start_variant(variant_id: str, app_folder: str, host: str):
261
267
  api_key=api_key,
262
268
  )
263
269
 
264
- endpoint = client.variants.start_variant(
270
+ variant = client.variants.start_variant(
265
271
  variant_id=variant_id,
266
- action=VariantAction(
267
- action=VariantActionEnum.START,
268
- ),
269
- ).uri
272
+ action=VariantAction(action="START"),
273
+ )
274
+ endpoint = variant.uri
270
275
  click.echo("\n" + click.style("Congratulations! 🎉", bold=True, fg="green"))
271
276
  click.echo(
272
277
  click.style("Your app has been deployed locally as an API. 🚀", fg="cyan")
agenta/client/Readme.md CHANGED
@@ -7,90 +7,98 @@ Currently the models are manually copied from the backend code. This needs to ch
7
7
  To generate the client code using Fern, follow the steps below.
8
8
 
9
9
  1. Open a Terminal and navigate to the folder where this Readme.md file is. For example;
10
- ```
11
- $ cd agenta/agenta-cli/agenta/client
12
- ```
10
+ ```bash
11
+ cd agenta/agenta-cli/agenta/client
12
+ ```
13
13
 
14
14
  2. Next ensure you have installed Fern by executing the command;
15
- ```
16
- $ npm install -g fern-api
17
- ```
15
+ ```bash
16
+ npm install -g fern-api
17
+ ```
18
+
18
19
  3. Execute this command to initialize Fern to import and use the OpenAPI spec;
19
20
 
20
21
  > To use an OpenAPI spec, you can pass in the filepath or URL.
21
- > We'll be using a url to the openapi.json for [Agenta Cloud](https://cloud.agenta.ai)
22
+ > We'll need to log in to use fern.
23
+ > We'll be using a url to the openapi.json for [Agenta Cloud](https://cloud.agenta.ai).
24
+ > Alternatively, for `cloud-dev` we could use [Cloud Local](http://localhost).
22
25
 
23
- ```
26
+ ```bash
24
27
  fern init --openapi https://cloud.agenta.ai/api/openapi.json
28
+ # fern init --openapi http://localhost/api/openapi.json
25
29
  ```
26
30
 
27
31
  4. Add the Fern Python SDK;
28
- ```bash
29
- fern add fern-python-sdk
30
- ```
32
+ ```bash
33
+ fern add fern-python-sdk
34
+ ```
31
35
 
32
36
  5. Go to the generators.yml, which would look like this;
33
-
34
- ```yaml
35
- default-group: local
36
- groups:
37
- local:
38
- generators:
39
- - name: fernapi/fern-typescript-node-sdk
40
- version: 0.7.2
41
- output:
42
- location: local-file-system
43
- path: ../generated/typescript
44
- - name: fernapi/fern-python-sdk
45
- version: 0.6.0
46
- ```
47
-
48
- Replace the following;
49
-
50
- ```yaml
37
+ ```yaml
38
+ default-group: local
39
+ groups:
40
+ local:
41
+ generators:
51
42
  - name: fernapi/fern-typescript-node-sdk
52
- version: 0.7.2
53
- ```
54
-
55
- with this and delete it from the bottom of the file after;
56
-
57
- ```yaml
43
+ version: 0.9.5
44
+ output:
45
+ location: local-file-system
46
+ path: ../sdks/typescript
58
47
  - name: fernapi/fern-python-sdk
59
48
  version: 0.6.0
60
- ```
49
+ ```
61
50
 
62
- 6. Change the path from this `path: ../generated/typescript` to this path: `../backend`
51
+ 6. Remove `fernapi/fern-typescript-node-sdk`;
52
+ ```yaml
53
+ default-group: local
54
+ groups:
55
+ local:
56
+ generators:
57
+ - name: fernapi/fern-python-sdk
58
+ version: 3.10.6
59
+ ```
63
60
 
64
- Now your generators.yml should look like this;
65
- ```yaml
66
- default-group: local
67
- groups:
68
- local:
69
- generators:
70
- - name: fernapi/fern-python-sdk
71
- version: 0.6.0
72
- output:
73
- location: local-file-system
74
- path: ../backend
75
- ```
76
- <img width="1001" alt="image" src="https://github.com/Agenta-AI/agenta/assets/56418363/f537691d-8dbb-4363-b7c0-ecef9f464053">
61
+ 7. Update `fernapi/fern-python-sdk`, which would look like this;
62
+ ```yaml
63
+ default-group: local
64
+ groups:
65
+ local:
66
+ generators:
67
+ - name: fernapi/fern-python-sdk
68
+ version: 3.10.6
69
+ output:
70
+ location: local-file-system
71
+ path: ../backend
72
+ ```
73
+ <img width="1001" alt="image" src="https://github.com/Agenta-AI/agenta/assets/56418363/f537691d-8dbb-4363-b7c0-ecef9f464053">
77
74
 
78
75
 
79
- 7. Go to the fern.config.json file and change the value of "organization" to `agenta`
80
- <img width="593" alt="image" src="https://github.com/Agenta-AI/agenta/assets/56418363/0f44255e-50b5-4d78-863b-d33a3ec2eea0">
76
+ 8. Go to the fern.config.json file and change the value of "organization" to `agenta`
77
+ <img width="593" alt="image" src="https://github.com/Agenta-AI/agenta/assets/56418363/0f44255e-50b5-4d78-863b-d33a3ec2eea0">
81
78
 
82
79
 
83
- 9. Generate the client code
84
-
85
- ```bash
86
- fern generate
87
- ```
88
-
89
- 10. Change the timeout for the build_image function endpoint
90
- Go to the client.py in the generated code folder search for the `build_image` function in the AgentaApi class and change the timeout to 600.
91
- When done, it should look like this;
92
- <img width="995" alt="image" src="https://github.com/Agenta-AI/agenta/assets/56418363/8fab19e3-5226-405b-8a6f-4dcb6df588c9">
93
-
80
+ 9. Generate the client code
81
+ ```bash
82
+ fern generate
83
+ ```
94
84
 
85
+ 10. Go to `./backend/containers/client.py`, search for the `build_image` function in the AgentaApi class and update `timeout_in_seconds` to `600` in `request_options'. It should now look like this;
86
+ ```python
87
+ _response = self._client_wrapper.httpx_client.request(
88
+ "containers/build_image",
89
+ method="POST",
90
+ params={
91
+ "app_id": app_id,
92
+ "base_name": base_name,
93
+ },
94
+ data={},
95
+ files={
96
+ "tar_file": tar_file,
97
+ },
98
+ request_options={**request_options, "timeout_in_seconds": 600},
99
+ omit=OMIT,
100
+ )
101
+ ```
102
+ <img width="995" alt="image" src="https://github.com/Agenta-AI/agenta/assets/56418363/8fab19e3-5226-405b-8a6f-4dcb6df588c9">
95
103
 
96
- 11. Delete the fern folder.
104
+ 11. Delete the `./fern` folder.
agenta/client/api.py CHANGED
@@ -55,7 +55,7 @@ def add_variant_to_server(
55
55
  docker_id=image.docker_id,
56
56
  tags=image.tags,
57
57
  )
58
- click.echo(click.style("\nVariant added successfully.", fg="green"))
58
+ click.echo(click.style("\nVariant added successfully!", fg="green"))
59
59
  return response
60
60
  except RequestException as e:
61
61
  if attempt < retries - 1:
@@ -9,6 +9,7 @@ from .types import (
9
9
  BaseOutput,
10
10
  BodyImportTestset,
11
11
  ConfigDb,
12
+ CorrectAnswer,
12
13
  CreateAppOutput,
13
14
  CreateSpan,
14
15
  CreateTraceResponse,
@@ -25,10 +26,8 @@ from .types import (
25
26
  EvaluationScenarioScoreUpdate,
26
27
  EvaluationStatusEnum,
27
28
  EvaluationType,
28
- EvaluationWebhook,
29
29
  Evaluator,
30
30
  EvaluatorConfig,
31
- Feedback,
32
31
  GetConfigResponse,
33
32
  HttpValidationError,
34
33
  HumanEvaluation,
@@ -42,17 +41,18 @@ from .types import (
42
41
  ListApiKeysResponse,
43
42
  LlmRunRateLimit,
44
43
  LlmTokens,
44
+ LmProvidersEnum,
45
45
  NewHumanEvaluation,
46
46
  NewTestset,
47
47
  Organization,
48
48
  OrganizationOutput,
49
+ Outputs,
49
50
  Permission,
50
51
  Result,
51
52
  Score,
52
53
  SimpleEvaluationOutput,
53
54
  Span,
54
55
  SpanDetail,
55
- SpanKind,
56
56
  SpanStatusCode,
57
57
  SpanVariant,
58
58
  Template,
@@ -60,6 +60,7 @@ from .types import (
60
60
  TestSetOutputResponse,
61
61
  TestSetSimpleResponse,
62
62
  TraceDetail,
63
+ UpdateAppOutput,
63
64
  Uri,
64
65
  ValidationError,
65
66
  ValidationErrorLocItem,
@@ -73,9 +74,7 @@ from .types import (
73
74
  WorkspaceRoleResponse,
74
75
  )
75
76
  from .errors import UnprocessableEntityError
76
- from .resources import (
77
- AddVariantFromBaseAndConfigResponse,
78
- ContainerTemplatesResponse,
77
+ from . import (
79
78
  apps,
80
79
  bases,
81
80
  configs,
@@ -87,18 +86,24 @@ from .resources import (
87
86
  testsets,
88
87
  variants,
89
88
  )
89
+ from .client import AgentaApi, AsyncAgentaApi
90
+ from .containers import ContainerTemplatesResponse
91
+ from .variants import AddVariantFromBaseAndConfigResponse
90
92
 
91
93
  __all__ = [
92
94
  "AddVariantFromBaseAndConfigResponse",
95
+ "AgentaApi",
93
96
  "AggregatedResult",
94
97
  "AggregatedResultEvaluatorConfig",
95
98
  "App",
96
99
  "AppVariantResponse",
97
100
  "AppVariantRevision",
101
+ "AsyncAgentaApi",
98
102
  "BaseOutput",
99
103
  "BodyImportTestset",
100
104
  "ConfigDb",
101
105
  "ContainerTemplatesResponse",
106
+ "CorrectAnswer",
102
107
  "CreateAppOutput",
103
108
  "CreateSpan",
104
109
  "CreateTraceResponse",
@@ -115,10 +120,8 @@ __all__ = [
115
120
  "EvaluationScenarioScoreUpdate",
116
121
  "EvaluationStatusEnum",
117
122
  "EvaluationType",
118
- "EvaluationWebhook",
119
123
  "Evaluator",
120
124
  "EvaluatorConfig",
121
- "Feedback",
122
125
  "GetConfigResponse",
123
126
  "HttpValidationError",
124
127
  "HumanEvaluation",
@@ -132,17 +135,18 @@ __all__ = [
132
135
  "ListApiKeysResponse",
133
136
  "LlmRunRateLimit",
134
137
  "LlmTokens",
138
+ "LmProvidersEnum",
135
139
  "NewHumanEvaluation",
136
140
  "NewTestset",
137
141
  "Organization",
138
142
  "OrganizationOutput",
143
+ "Outputs",
139
144
  "Permission",
140
145
  "Result",
141
146
  "Score",
142
147
  "SimpleEvaluationOutput",
143
148
  "Span",
144
149
  "SpanDetail",
145
- "SpanKind",
146
150
  "SpanStatusCode",
147
151
  "SpanVariant",
148
152
  "Template",
@@ -151,6 +155,7 @@ __all__ = [
151
155
  "TestSetSimpleResponse",
152
156
  "TraceDetail",
153
157
  "UnprocessableEntityError",
158
+ "UpdateAppOutput",
154
159
  "Uri",
155
160
  "ValidationError",
156
161
  "ValidationErrorLocItem",