agenta 0.13.0a0__py3-none-any.whl → 0.13.0a2__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 (98) hide show
  1. agenta/__init__.py +1 -0
  2. agenta/client/backend/client.py +169 -50
  3. agenta/client/backend/core/api_error.py +3 -1
  4. agenta/client/backend/core/datetime_utils.py +3 -1
  5. agenta/client/backend/core/jsonable_encoder.py +9 -3
  6. agenta/client/backend/resources/__init__.py +12 -1
  7. agenta/client/backend/resources/apps/__init__.py +0 -1
  8. agenta/client/backend/resources/apps/client.py +88 -26
  9. agenta/client/backend/resources/bases/__init__.py +0 -1
  10. agenta/client/backend/resources/bases/client.py +8 -2
  11. agenta/client/backend/resources/configs/__init__.py +0 -1
  12. agenta/client/backend/resources/configs/client.py +58 -14
  13. agenta/client/backend/resources/containers/client.py +46 -14
  14. agenta/client/backend/resources/environments/__init__.py +0 -1
  15. agenta/client/backend/resources/environments/client.py +18 -6
  16. agenta/client/backend/resources/evaluations/__init__.py +0 -1
  17. agenta/client/backend/resources/evaluations/client.py +86 -26
  18. agenta/client/backend/resources/evaluators/__init__.py +0 -1
  19. agenta/client/backend/resources/evaluators/client.py +57 -17
  20. agenta/client/backend/resources/observability/__init__.py +0 -1
  21. agenta/client/backend/resources/observability/client.py +100 -30
  22. agenta/client/backend/resources/testsets/__init__.py +0 -1
  23. agenta/client/backend/resources/testsets/client.py +56 -16
  24. agenta/client/backend/resources/variants/client.py +92 -26
  25. agenta/client/backend/resources/variants/types/__init__.py +3 -1
  26. agenta/client/backend/types/aggregated_result.py +10 -2
  27. agenta/client/backend/types/aggregated_result_evaluator_config.py +3 -1
  28. agenta/client/backend/types/app.py +10 -2
  29. agenta/client/backend/types/app_variant_response.py +10 -2
  30. agenta/client/backend/types/app_variant_revision.py +10 -2
  31. agenta/client/backend/types/base_output.py +10 -2
  32. agenta/client/backend/types/body_import_testset.py +10 -2
  33. agenta/client/backend/types/config_db.py +10 -2
  34. agenta/client/backend/types/create_app_output.py +10 -2
  35. agenta/client/backend/types/create_span.py +11 -2
  36. agenta/client/backend/types/create_trace_response.py +10 -2
  37. agenta/client/backend/types/docker_env_vars.py +10 -2
  38. agenta/client/backend/types/environment_output.py +10 -2
  39. agenta/client/backend/types/environment_output_extended.py +10 -2
  40. agenta/client/backend/types/environment_revision.py +10 -2
  41. agenta/client/backend/types/error.py +10 -2
  42. agenta/client/backend/types/evaluation.py +10 -2
  43. agenta/client/backend/types/evaluation_scenario.py +10 -2
  44. agenta/client/backend/types/evaluation_scenario_input.py +10 -2
  45. agenta/client/backend/types/evaluation_scenario_output.py +10 -2
  46. agenta/client/backend/types/evaluation_scenario_result.py +10 -2
  47. agenta/client/backend/types/evaluation_scenario_score_update.py +10 -2
  48. agenta/client/backend/types/evaluation_type.py +3 -1
  49. agenta/client/backend/types/evaluation_webhook.py +10 -2
  50. agenta/client/backend/types/evaluator.py +10 -2
  51. agenta/client/backend/types/evaluator_config.py +10 -2
  52. agenta/client/backend/types/feedback.py +10 -2
  53. agenta/client/backend/types/get_config_response.py +10 -3
  54. agenta/client/backend/types/http_validation_error.py +10 -2
  55. agenta/client/backend/types/human_evaluation.py +10 -2
  56. agenta/client/backend/types/human_evaluation_scenario.py +10 -2
  57. agenta/client/backend/types/human_evaluation_scenario_input.py +10 -2
  58. agenta/client/backend/types/human_evaluation_scenario_output.py +10 -2
  59. agenta/client/backend/types/human_evaluation_scenario_update.py +10 -2
  60. agenta/client/backend/types/human_evaluation_update.py +10 -2
  61. agenta/client/backend/types/image.py +10 -2
  62. agenta/client/backend/types/invite_request.py +10 -2
  63. agenta/client/backend/types/list_api_keys_response.py +10 -2
  64. agenta/client/backend/types/llm_run_rate_limit.py +10 -2
  65. agenta/client/backend/types/llm_tokens.py +10 -2
  66. agenta/client/backend/types/new_human_evaluation.py +10 -2
  67. agenta/client/backend/types/new_testset.py +10 -2
  68. agenta/client/backend/types/organization.py +10 -2
  69. agenta/client/backend/types/organization_output.py +10 -2
  70. agenta/client/backend/types/result.py +10 -2
  71. agenta/client/backend/types/simple_evaluation_output.py +10 -2
  72. agenta/client/backend/types/span.py +10 -2
  73. agenta/client/backend/types/span_detail.py +10 -2
  74. agenta/client/backend/types/span_variant.py +10 -2
  75. agenta/client/backend/types/template.py +10 -2
  76. agenta/client/backend/types/template_image_info.py +10 -2
  77. agenta/client/backend/types/test_set_output_response.py +10 -2
  78. agenta/client/backend/types/test_set_simple_response.py +10 -2
  79. agenta/client/backend/types/trace_detail.py +10 -2
  80. agenta/client/backend/types/uri.py +10 -2
  81. agenta/client/backend/types/validation_error.py +10 -2
  82. agenta/client/backend/types/variant_action.py +10 -2
  83. agenta/client/backend/types/variant_action_enum.py +3 -1
  84. agenta/client/backend/types/with_pagination.py +10 -2
  85. agenta/client/backend/types/workspace_member_response.py +10 -2
  86. agenta/client/backend/types/workspace_permission.py +10 -2
  87. agenta/client/backend/types/workspace_response.py +10 -2
  88. agenta/client/backend/types/workspace_role_response.py +10 -2
  89. agenta/sdk/__init__.py +1 -0
  90. agenta/sdk/agenta_decorator.py +11 -3
  91. agenta/sdk/agenta_init.py +3 -1
  92. agenta/sdk/tracing/llm_tracing.py +35 -18
  93. agenta/sdk/types.py +38 -0
  94. {agenta-0.13.0a0.dist-info → agenta-0.13.0a2.dist-info}/METADATA +46 -96
  95. agenta-0.13.0a2.dist-info/RECORD +161 -0
  96. agenta-0.13.0a0.dist-info/RECORD +0 -161
  97. {agenta-0.13.0a0.dist-info → agenta-0.13.0a2.dist-info}/WHEEL +0 -0
  98. {agenta-0.13.0a0.dist-info → agenta-0.13.0a2.dist-info}/entry_points.txt +0 -0
@@ -18,11 +18,19 @@ class Result(pydantic.BaseModel):
18
18
  error: typing.Optional[Error]
19
19
 
20
20
  def json(self, **kwargs: typing.Any) -> str:
21
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
21
+ kwargs_with_defaults: typing.Any = {
22
+ "by_alias": True,
23
+ "exclude_unset": True,
24
+ **kwargs,
25
+ }
22
26
  return super().json(**kwargs_with_defaults)
23
27
 
24
28
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
25
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
29
+ kwargs_with_defaults: typing.Any = {
30
+ "by_alias": True,
31
+ "exclude_unset": True,
32
+ **kwargs,
33
+ }
26
34
  return super().dict(**kwargs_with_defaults)
27
35
 
28
36
  class Config:
@@ -20,11 +20,19 @@ class SimpleEvaluationOutput(pydantic.BaseModel):
20
20
  evaluation_type: EvaluationType
21
21
 
22
22
  def json(self, **kwargs: typing.Any) -> str:
23
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
23
+ kwargs_with_defaults: typing.Any = {
24
+ "by_alias": True,
25
+ "exclude_unset": True,
26
+ **kwargs,
27
+ }
24
28
  return super().json(**kwargs_with_defaults)
25
29
 
26
30
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
27
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
31
+ kwargs_with_defaults: typing.Any = {
32
+ "by_alias": True,
33
+ "exclude_unset": True,
34
+ **kwargs,
35
+ }
28
36
  return super().dict(**kwargs_with_defaults)
29
37
 
30
38
  class Config:
@@ -30,11 +30,19 @@ class Span(pydantic.BaseModel):
30
30
  children: typing.Optional[typing.List[Span]]
31
31
 
32
32
  def json(self, **kwargs: typing.Any) -> str:
33
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
33
+ kwargs_with_defaults: typing.Any = {
34
+ "by_alias": True,
35
+ "exclude_unset": True,
36
+ **kwargs,
37
+ }
34
38
  return super().json(**kwargs_with_defaults)
35
39
 
36
40
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
37
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
41
+ kwargs_with_defaults: typing.Any = {
42
+ "by_alias": True,
43
+ "exclude_unset": True,
44
+ **kwargs,
45
+ }
38
46
  return super().dict(**kwargs_with_defaults)
39
47
 
40
48
  class Config:
@@ -31,11 +31,19 @@ class SpanDetail(pydantic.BaseModel):
31
31
  config: typing.Optional[typing.Dict[str, typing.Any]]
32
32
 
33
33
  def json(self, **kwargs: typing.Any) -> str:
34
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
34
+ kwargs_with_defaults: typing.Any = {
35
+ "by_alias": True,
36
+ "exclude_unset": True,
37
+ **kwargs,
38
+ }
35
39
  return super().json(**kwargs_with_defaults)
36
40
 
37
41
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
38
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
42
+ kwargs_with_defaults: typing.Any = {
43
+ "by_alias": True,
44
+ "exclude_unset": True,
45
+ **kwargs,
46
+ }
39
47
  return super().dict(**kwargs_with_defaults)
40
48
 
41
49
  class Config:
@@ -17,11 +17,19 @@ class SpanVariant(pydantic.BaseModel):
17
17
  revision: int
18
18
 
19
19
  def json(self, **kwargs: typing.Any) -> str:
20
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
20
+ kwargs_with_defaults: typing.Any = {
21
+ "by_alias": True,
22
+ "exclude_unset": True,
23
+ **kwargs,
24
+ }
21
25
  return super().json(**kwargs_with_defaults)
22
26
 
23
27
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
24
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
28
+ kwargs_with_defaults: typing.Any = {
29
+ "by_alias": True,
30
+ "exclude_unset": True,
31
+ **kwargs,
32
+ }
25
33
  return super().dict(**kwargs_with_defaults)
26
34
 
27
35
  class Config:
@@ -17,11 +17,19 @@ class Template(pydantic.BaseModel):
17
17
  image: TemplateImageInfo
18
18
 
19
19
  def json(self, **kwargs: typing.Any) -> str:
20
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
20
+ kwargs_with_defaults: typing.Any = {
21
+ "by_alias": True,
22
+ "exclude_unset": True,
23
+ **kwargs,
24
+ }
21
25
  return super().json(**kwargs_with_defaults)
22
26
 
23
27
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
24
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
28
+ kwargs_with_defaults: typing.Any = {
29
+ "by_alias": True,
30
+ "exclude_unset": True,
31
+ **kwargs,
32
+ }
25
33
  return super().dict(**kwargs_with_defaults)
26
34
 
27
35
  class Config:
@@ -22,11 +22,19 @@ class TemplateImageInfo(pydantic.BaseModel):
22
22
  template_uri: typing.Optional[str]
23
23
 
24
24
  def json(self, **kwargs: typing.Any) -> str:
25
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
25
+ kwargs_with_defaults: typing.Any = {
26
+ "by_alias": True,
27
+ "exclude_unset": True,
28
+ **kwargs,
29
+ }
26
30
  return super().json(**kwargs_with_defaults)
27
31
 
28
32
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
29
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
33
+ kwargs_with_defaults: typing.Any = {
34
+ "by_alias": True,
35
+ "exclude_unset": True,
36
+ **kwargs,
37
+ }
30
38
  return super().dict(**kwargs_with_defaults)
31
39
 
32
40
  class Config:
@@ -17,11 +17,19 @@ class TestSetOutputResponse(pydantic.BaseModel):
17
17
  created_at: dt.datetime
18
18
 
19
19
  def json(self, **kwargs: typing.Any) -> str:
20
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
20
+ kwargs_with_defaults: typing.Any = {
21
+ "by_alias": True,
22
+ "exclude_unset": True,
23
+ **kwargs,
24
+ }
21
25
  return super().json(**kwargs_with_defaults)
22
26
 
23
27
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
24
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
28
+ kwargs_with_defaults: typing.Any = {
29
+ "by_alias": True,
30
+ "exclude_unset": True,
31
+ **kwargs,
32
+ }
25
33
  return super().dict(**kwargs_with_defaults)
26
34
 
27
35
  class Config:
@@ -17,11 +17,19 @@ class TestSetSimpleResponse(pydantic.BaseModel):
17
17
  created_at: str
18
18
 
19
19
  def json(self, **kwargs: typing.Any) -> str:
20
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
20
+ kwargs_with_defaults: typing.Any = {
21
+ "by_alias": True,
22
+ "exclude_unset": True,
23
+ **kwargs,
24
+ }
21
25
  return super().json(**kwargs_with_defaults)
22
26
 
23
27
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
24
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
28
+ kwargs_with_defaults: typing.Any = {
29
+ "by_alias": True,
30
+ "exclude_unset": True,
31
+ **kwargs,
32
+ }
25
33
  return super().dict(**kwargs_with_defaults)
26
34
 
27
35
  class Config:
@@ -31,11 +31,19 @@ class TraceDetail(pydantic.BaseModel):
31
31
  config: typing.Dict[str, typing.Any]
32
32
 
33
33
  def json(self, **kwargs: typing.Any) -> str:
34
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
34
+ kwargs_with_defaults: typing.Any = {
35
+ "by_alias": True,
36
+ "exclude_unset": True,
37
+ **kwargs,
38
+ }
35
39
  return super().json(**kwargs_with_defaults)
36
40
 
37
41
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
38
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
42
+ kwargs_with_defaults: typing.Any = {
43
+ "by_alias": True,
44
+ "exclude_unset": True,
45
+ **kwargs,
46
+ }
39
47
  return super().dict(**kwargs_with_defaults)
40
48
 
41
49
  class Config:
@@ -15,11 +15,19 @@ class Uri(pydantic.BaseModel):
15
15
  uri: str
16
16
 
17
17
  def json(self, **kwargs: typing.Any) -> str:
18
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
18
+ kwargs_with_defaults: typing.Any = {
19
+ "by_alias": True,
20
+ "exclude_unset": True,
21
+ **kwargs,
22
+ }
19
23
  return super().json(**kwargs_with_defaults)
20
24
 
21
25
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
22
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
26
+ kwargs_with_defaults: typing.Any = {
27
+ "by_alias": True,
28
+ "exclude_unset": True,
29
+ **kwargs,
30
+ }
23
31
  return super().dict(**kwargs_with_defaults)
24
32
 
25
33
  class Config:
@@ -18,11 +18,19 @@ class ValidationError(pydantic.BaseModel):
18
18
  type: str
19
19
 
20
20
  def json(self, **kwargs: typing.Any) -> str:
21
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
21
+ kwargs_with_defaults: typing.Any = {
22
+ "by_alias": True,
23
+ "exclude_unset": True,
24
+ **kwargs,
25
+ }
22
26
  return super().json(**kwargs_with_defaults)
23
27
 
24
28
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
25
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
29
+ kwargs_with_defaults: typing.Any = {
30
+ "by_alias": True,
31
+ "exclude_unset": True,
32
+ **kwargs,
33
+ }
26
34
  return super().dict(**kwargs_with_defaults)
27
35
 
28
36
  class Config:
@@ -16,11 +16,19 @@ class VariantAction(pydantic.BaseModel):
16
16
  action: VariantActionEnum
17
17
 
18
18
  def json(self, **kwargs: typing.Any) -> str:
19
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
19
+ kwargs_with_defaults: typing.Any = {
20
+ "by_alias": True,
21
+ "exclude_unset": True,
22
+ **kwargs,
23
+ }
20
24
  return super().json(**kwargs_with_defaults)
21
25
 
22
26
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
23
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
27
+ kwargs_with_defaults: typing.Any = {
28
+ "by_alias": True,
29
+ "exclude_unset": True,
30
+ **kwargs,
31
+ }
24
32
  return super().dict(**kwargs_with_defaults)
25
33
 
26
34
  class Config:
@@ -14,7 +14,9 @@ class VariantActionEnum(str, enum.Enum):
14
14
  START = "START"
15
15
  STOP = "STOP"
16
16
 
17
- def visit(self, start: typing.Callable[[], T_Result], stop: typing.Callable[[], T_Result]) -> T_Result:
17
+ def visit(
18
+ self, start: typing.Callable[[], T_Result], stop: typing.Callable[[], T_Result]
19
+ ) -> T_Result:
18
20
  if self is VariantActionEnum.START:
19
21
  return start()
20
22
  if self is VariantActionEnum.STOP:
@@ -18,11 +18,19 @@ class WithPagination(pydantic.BaseModel):
18
18
  page_size: int = pydantic.Field(alias="pageSize")
19
19
 
20
20
  def json(self, **kwargs: typing.Any) -> str:
21
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
21
+ kwargs_with_defaults: typing.Any = {
22
+ "by_alias": True,
23
+ "exclude_unset": True,
24
+ **kwargs,
25
+ }
22
26
  return super().json(**kwargs_with_defaults)
23
27
 
24
28
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
25
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
29
+ kwargs_with_defaults: typing.Any = {
30
+ "by_alias": True,
31
+ "exclude_unset": True,
32
+ **kwargs,
33
+ }
26
34
  return super().dict(**kwargs_with_defaults)
27
35
 
28
36
  class Config:
@@ -17,11 +17,19 @@ class WorkspaceMemberResponse(pydantic.BaseModel):
17
17
  roles: typing.List[WorkspacePermission]
18
18
 
19
19
  def json(self, **kwargs: typing.Any) -> str:
20
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
20
+ kwargs_with_defaults: typing.Any = {
21
+ "by_alias": True,
22
+ "exclude_unset": True,
23
+ **kwargs,
24
+ }
21
25
  return super().json(**kwargs_with_defaults)
22
26
 
23
27
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
24
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
28
+ kwargs_with_defaults: typing.Any = {
29
+ "by_alias": True,
30
+ "exclude_unset": True,
31
+ **kwargs,
32
+ }
25
33
  return super().dict(**kwargs_with_defaults)
26
34
 
27
35
  class Config:
@@ -19,11 +19,19 @@ class WorkspacePermission(pydantic.BaseModel):
19
19
  permissions: typing.Optional[typing.List[Permission]]
20
20
 
21
21
  def json(self, **kwargs: typing.Any) -> str:
22
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
22
+ kwargs_with_defaults: typing.Any = {
23
+ "by_alias": True,
24
+ "exclude_unset": True,
25
+ **kwargs,
26
+ }
23
27
  return super().json(**kwargs_with_defaults)
24
28
 
25
29
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
26
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
30
+ kwargs_with_defaults: typing.Any = {
31
+ "by_alias": True,
32
+ "exclude_unset": True,
33
+ **kwargs,
34
+ }
27
35
  return super().dict(**kwargs_with_defaults)
28
36
 
29
37
  class Config:
@@ -23,11 +23,19 @@ class WorkspaceResponse(pydantic.BaseModel):
23
23
  members: typing.Optional[typing.List[WorkspaceMemberResponse]]
24
24
 
25
25
  def json(self, **kwargs: typing.Any) -> str:
26
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
26
+ kwargs_with_defaults: typing.Any = {
27
+ "by_alias": True,
28
+ "exclude_unset": True,
29
+ **kwargs,
30
+ }
27
31
  return super().json(**kwargs_with_defaults)
28
32
 
29
33
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
30
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
34
+ kwargs_with_defaults: typing.Any = {
35
+ "by_alias": True,
36
+ "exclude_unset": True,
37
+ **kwargs,
38
+ }
31
39
  return super().dict(**kwargs_with_defaults)
32
40
 
33
41
  class Config:
@@ -17,11 +17,19 @@ class WorkspaceRoleResponse(pydantic.BaseModel):
17
17
  role_description: typing.Optional[str]
18
18
 
19
19
  def json(self, **kwargs: typing.Any) -> str:
20
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
20
+ kwargs_with_defaults: typing.Any = {
21
+ "by_alias": True,
22
+ "exclude_unset": True,
23
+ **kwargs,
24
+ }
21
25
  return super().json(**kwargs_with_defaults)
22
26
 
23
27
  def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
24
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
28
+ kwargs_with_defaults: typing.Any = {
29
+ "by_alias": True,
30
+ "exclude_unset": True,
31
+ **kwargs,
32
+ }
25
33
  return super().dict(**kwargs_with_defaults)
26
34
 
27
35
  class Config:
agenta/sdk/__init__.py CHANGED
@@ -9,6 +9,7 @@ from .types import (
9
9
  InFile,
10
10
  IntParam,
11
11
  MultipleChoiceParam,
12
+ GroupedMultipleChoiceParam,
12
13
  TextParam,
13
14
  MessagesInput,
14
15
  FileInputURL,
@@ -25,6 +25,7 @@ from .types import (
25
25
  InFile,
26
26
  IntParam,
27
27
  MultipleChoiceParam,
28
+ GroupedMultipleChoiceParam,
28
29
  TextParam,
29
30
  MessagesInput,
30
31
  FileInputURL,
@@ -83,7 +84,8 @@ def entrypoint(func: Callable[..., Any]) -> Callable[..., Any]:
83
84
  tracing.start_parent_span(
84
85
  name=func.__name__,
85
86
  inputs=func_params,
86
- config=api_config_params,
87
+ config=config_params,
88
+ environment="playground", # type: ignore #NOTE: wrapper is only called in playground
87
89
  )
88
90
 
89
91
  # Ingest files, prepare configurations and run llm app
@@ -97,7 +99,6 @@ def entrypoint(func: Callable[..., Any]) -> Callable[..., Any]:
97
99
  tracing.end_recording(
98
100
  outputs=llm_result.dict(),
99
101
  span=tracing.active_trace,
100
- environment="playground", # type: ignore #NOTE: wrapper is only called in playground
101
102
  )
102
103
  return llm_result
103
104
 
@@ -120,6 +121,7 @@ def entrypoint(func: Callable[..., Any]) -> Callable[..., Any]:
120
121
  name=func.__name__,
121
122
  inputs=func_params,
122
123
  config=config,
124
+ environment="playground", # type: ignore #NOTE: wrapper is only called in playground
123
125
  )
124
126
 
125
127
  llm_result = await execute_function(
@@ -130,7 +132,6 @@ def entrypoint(func: Callable[..., Any]) -> Callable[..., Any]:
130
132
  tracing.end_recording(
131
133
  outputs=llm_result.dict(),
132
134
  span=tracing.active_trace,
133
- environment="playground", # type: ignore #NOTE: wrapper is only called in playground
134
135
  )
135
136
  return llm_result
136
137
 
@@ -446,6 +447,13 @@ def override_schema(openapi_schema: dict, func_name: str, endpoint: str, params:
446
447
  f"Body_{func_name}_{endpoint}_post"
447
448
  ]["properties"]
448
449
  for param_name, param_val in params.items():
450
+ if isinstance(param_val, GroupedMultipleChoiceParam):
451
+ subschema = find_in_schema(schema_to_override, param_name, "grouped_choice")
452
+ assert (
453
+ subschema
454
+ ), f"GroupedMultipleChoiceParam '{param_name}' is in the parameters but could not be found in the openapi.json"
455
+ subschema["choices"] = param_val.choices
456
+ subschema["default"] = param_val.default
449
457
  if isinstance(param_val, MultipleChoiceParam):
450
458
  subschema = find_in_schema(schema_to_override, param_name, "choice")
451
459
  default = str(param_val)
agenta/sdk/agenta_init.py CHANGED
@@ -90,6 +90,7 @@ class AgentaSingleton:
90
90
  self.host = host
91
91
  self.app_id = os.environ.get("AGENTA_APP_ID") if app_id is None else app_id
92
92
  self.variant_id = os.environ.get("AGENTA_VARIANT_ID")
93
+ self.variant_name = os.environ.get("AGENTA_VARIANT_NAME")
93
94
  self.api_key = api_key
94
95
  self.config = Config(base_id=base_id, host=host)
95
96
 
@@ -193,7 +194,7 @@ class Config:
193
194
  + str(ex)
194
195
  )
195
196
  try:
196
- self.set(**config.parameters)
197
+ self.set(**{"current_version": config.current_version, **config.parameters})
197
198
  except Exception as ex:
198
199
  logger.warning("Failed to set the configuration with error: " + str(ex))
199
200
 
@@ -237,6 +238,7 @@ def llm_tracing(max_workers: Optional[int] = None) -> Tracing:
237
238
  base_url=singleton.host,
238
239
  app_id=singleton.app_id, # type: ignore
239
240
  variant_id=singleton.variant_id, # type: ignore
241
+ variant_name=singleton.variant_name,
240
242
  api_key=singleton.api_key,
241
243
  max_workers=max_workers,
242
244
  )
@@ -36,6 +36,7 @@ class Tracing(object):
36
36
  base_url: str,
37
37
  app_id: str,
38
38
  variant_id: str,
39
+ variant_name: Optional[str] = None,
39
40
  api_key: Optional[str] = None,
40
41
  max_workers: Optional[int] = None,
41
42
  ):
@@ -44,6 +45,7 @@ class Tracing(object):
44
45
  self.llm_logger = llm_logger
45
46
  self.app_id = app_id
46
47
  self.variant_id = variant_id
48
+ self.variant_name = variant_name
47
49
  self.tasks_manager = TaskQueue(
48
50
  max_workers if max_workers else 4, logger=llm_logger
49
51
  )
@@ -92,7 +94,7 @@ class Tracing(object):
92
94
  self.tags.extend(tags)
93
95
 
94
96
  def start_parent_span(
95
- self, name: str, inputs: Dict[str, Any], config: Dict[str, Any]
97
+ self, name: str, inputs: Dict[str, Any], config: Dict[str, Any], **kwargs
96
98
  ):
97
99
  trace_id = self._create_trace_id()
98
100
  span_id = self._create_span_id()
@@ -101,9 +103,11 @@ class Tracing(object):
101
103
  id=span_id,
102
104
  app_id=self.app_id,
103
105
  variant_id=self.variant_id,
106
+ variant_name=self.variant_name,
104
107
  inputs=inputs,
105
108
  name=name,
106
109
  config=config,
110
+ environment=kwargs.get("environment"),
107
111
  spankind=SpanKind.WORKFLOW.value,
108
112
  status=SpanStatusCode.UNSET.value,
109
113
  start_time=datetime.now(timezone.utc),
@@ -111,7 +115,9 @@ class Tracing(object):
111
115
  self.active_trace = span
112
116
  self.recording_trace_id = trace_id
113
117
  self.parent_span_id = span.id
114
- self.llm_logger.info(f"Recorded active_trace and parent_span_id: {span.id}")
118
+ self.llm_logger.info(
119
+ f"Recorded active_trace and setting parent_span_id: {span.id}"
120
+ )
115
121
 
116
122
  def start_span(
117
123
  self,
@@ -126,7 +132,11 @@ class Tracing(object):
126
132
  id=span_id,
127
133
  inputs=input,
128
134
  name=name,
135
+ app_id=self.app_id,
136
+ variant_id=self.variant_id,
137
+ variant_name=self.variant_name,
129
138
  config=config,
139
+ environment=self.active_trace.environment,
130
140
  parent_span_id=self.parent_span_id,
131
141
  spankind=spankind.upper(),
132
142
  attributes={},
@@ -137,7 +147,9 @@ class Tracing(object):
137
147
  self.active_span = span
138
148
  self.span_dict[span.id] = span
139
149
  self.parent_span_id = span.id
140
- self.llm_logger.info(f"Recorded active_span and parent_span_id: {span.id}")
150
+ self.llm_logger.info(
151
+ f"Recorded active_span and setting parent_span_id: {span.id}"
152
+ )
141
153
  return span
142
154
 
143
155
  def update_span_status(self, span: CreateSpan, value: str):
@@ -150,39 +162,34 @@ class Tracing(object):
150
162
  end_time=datetime.now(timezone.utc),
151
163
  outputs=[outputs["message"]],
152
164
  cost=outputs.get("cost", None),
153
- environment=kwargs.get("environment"),
154
165
  tokens=outputs.get("usage"),
155
166
  )
156
167
 
157
168
  # Push span to list of recorded spans
158
169
  self.recorded_spans.append(updated_span)
159
- self.llm_logger.info(f"Pushed {updated_span.spankind} span {updated_span.id} to recorded spans.")
160
-
161
- def end_recording(self, outputs: Dict[str, Any], span: CreateSpan, **kwargs):
162
- updated_span = CreateSpan(
163
- **span.dict(),
164
- end_time=datetime.now(timezone.utc),
165
- outputs=[outputs["message"]],
166
- cost=outputs.get("cost", None),
167
- environment=kwargs.get("environment"),
168
- tokens=outputs.get("usage"),
169
- )
170
- self.recorded_spans.append(updated_span)
171
170
  self.llm_logger.info(
172
- f"Pushed workflow span {updated_span.id} to recorded spans."
171
+ f"Pushed {updated_span.spankind} span {updated_span.id} to recorded spans."
173
172
  )
173
+
174
+ def end_recording(self, outputs: Dict[str, Any], span: CreateSpan, **kwargs):
175
+ self.end_span(outputs=outputs, span=span, **kwargs)
176
+ if self.api_key == "":
177
+ return
178
+
174
179
  self.llm_logger.info(f"Preparing to send recorded spans for processing.")
180
+ self.llm_logger.info(f"Recorded spans => {len(self.recorded_spans)}")
175
181
  self.tasks_manager.add_task(
176
182
  self.active_trace.id,
177
183
  "trace",
178
184
  self.client.create_traces(
179
- trace=self.recording_trace_id, spans=self.recorded_spans
185
+ trace=self.recording_trace_id, spans=self.recorded_spans # type: ignore
180
186
  ),
181
187
  self.client,
182
188
  )
183
189
  self.llm_logger.info(
184
190
  f"Tracing for {span.id} recorded successfully and sent for processing."
185
191
  )
192
+ self._clear_recorded_spans()
186
193
 
187
194
  def _create_trace_id(self) -> str:
188
195
  """Creates a unique mongo id for the trace object.
@@ -201,3 +208,13 @@ class Tracing(object):
201
208
  """
202
209
 
203
210
  return str(ObjectId())
211
+
212
+ def _clear_recorded_spans(self) -> None:
213
+ """
214
+ Clear the list of recorded spans to prepare for next batch processing.
215
+ """
216
+
217
+ self.recorded_spans = []
218
+ self.llm_logger.info(
219
+ f"Cleared all recorded spans from batch: {self.recorded_spans}"
220
+ )