agenta 0.13.0a0__py3-none-any.whl → 0.13.0a1__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 (97) 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 +10 -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 -2
  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/tracing/llm_tracing.py +31 -18
  92. agenta/sdk/types.py +38 -0
  93. {agenta-0.13.0a0.dist-info → agenta-0.13.0a1.dist-info}/METADATA +46 -96
  94. agenta-0.13.0a1.dist-info/RECORD +161 -0
  95. agenta-0.13.0a0.dist-info/RECORD +0 -161
  96. {agenta-0.13.0a0.dist-info → agenta-0.13.0a1.dist-info}/WHEEL +0 -0
  97. {agenta-0.13.0a0.dist-info → agenta-0.13.0a1.dist-info}/entry_points.txt +0 -0
@@ -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)
@@ -92,7 +92,7 @@ class Tracing(object):
92
92
  self.tags.extend(tags)
93
93
 
94
94
  def start_parent_span(
95
- self, name: str, inputs: Dict[str, Any], config: Dict[str, Any]
95
+ self, name: str, inputs: Dict[str, Any], config: Dict[str, Any], **kwargs
96
96
  ):
97
97
  trace_id = self._create_trace_id()
98
98
  span_id = self._create_span_id()
@@ -104,6 +104,7 @@ class Tracing(object):
104
104
  inputs=inputs,
105
105
  name=name,
106
106
  config=config,
107
+ environment=kwargs.get("environment"),
107
108
  spankind=SpanKind.WORKFLOW.value,
108
109
  status=SpanStatusCode.UNSET.value,
109
110
  start_time=datetime.now(timezone.utc),
@@ -111,7 +112,9 @@ class Tracing(object):
111
112
  self.active_trace = span
112
113
  self.recording_trace_id = trace_id
113
114
  self.parent_span_id = span.id
114
- self.llm_logger.info(f"Recorded active_trace and parent_span_id: {span.id}")
115
+ self.llm_logger.info(
116
+ f"Recorded active_trace and setting parent_span_id: {span.id}"
117
+ )
115
118
 
116
119
  def start_span(
117
120
  self,
@@ -126,7 +129,10 @@ class Tracing(object):
126
129
  id=span_id,
127
130
  inputs=input,
128
131
  name=name,
132
+ app_id=self.app_id,
133
+ variant_id=self.variant_id,
129
134
  config=config,
135
+ environment=self.active_trace.environment,
130
136
  parent_span_id=self.parent_span_id,
131
137
  spankind=spankind.upper(),
132
138
  attributes={},
@@ -137,7 +143,9 @@ class Tracing(object):
137
143
  self.active_span = span
138
144
  self.span_dict[span.id] = span
139
145
  self.parent_span_id = span.id
140
- self.llm_logger.info(f"Recorded active_span and parent_span_id: {span.id}")
146
+ self.llm_logger.info(
147
+ f"Recorded active_span and setting parent_span_id: {span.id}"
148
+ )
141
149
  return span
142
150
 
143
151
  def update_span_status(self, span: CreateSpan, value: str):
@@ -150,39 +158,34 @@ class Tracing(object):
150
158
  end_time=datetime.now(timezone.utc),
151
159
  outputs=[outputs["message"]],
152
160
  cost=outputs.get("cost", None),
153
- environment=kwargs.get("environment"),
154
161
  tokens=outputs.get("usage"),
155
162
  )
156
163
 
157
164
  # Push span to list of recorded spans
158
165
  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
166
  self.llm_logger.info(
172
- f"Pushed workflow span {updated_span.id} to recorded spans."
167
+ f"Pushed {updated_span.spankind} span {updated_span.id} to recorded spans."
173
168
  )
169
+
170
+ def end_recording(self, outputs: Dict[str, Any], span: CreateSpan, **kwargs):
171
+ self.end_span(outputs=outputs, span=span, **kwargs)
172
+ if self.api_key == "":
173
+ return
174
+
174
175
  self.llm_logger.info(f"Preparing to send recorded spans for processing.")
176
+ self.llm_logger.info(f"Recorded spans => {len(self.recorded_spans)}")
175
177
  self.tasks_manager.add_task(
176
178
  self.active_trace.id,
177
179
  "trace",
178
180
  self.client.create_traces(
179
- trace=self.recording_trace_id, spans=self.recorded_spans
181
+ trace=self.recording_trace_id, spans=self.recorded_spans # type: ignore
180
182
  ),
181
183
  self.client,
182
184
  )
183
185
  self.llm_logger.info(
184
186
  f"Tracing for {span.id} recorded successfully and sent for processing."
185
187
  )
188
+ self._clear_recorded_spans()
186
189
 
187
190
  def _create_trace_id(self) -> str:
188
191
  """Creates a unique mongo id for the trace object.
@@ -201,3 +204,13 @@ class Tracing(object):
201
204
  """
202
205
 
203
206
  return str(ObjectId())
207
+
208
+ def _clear_recorded_spans(self) -> None:
209
+ """
210
+ Clear the list of recorded spans to prepare for next batch processing.
211
+ """
212
+
213
+ self.recorded_spans = []
214
+ self.llm_logger.info(
215
+ f"Cleared all recorded spans from batch: {self.recorded_spans}"
216
+ )
agenta/sdk/types.py CHANGED
@@ -127,6 +127,44 @@ class MultipleChoiceParam(str):
127
127
  )
128
128
 
129
129
 
130
+ class GroupedMultipleChoiceParam(str):
131
+ def __new__(cls, default: str = None, choices: Dict[str, List[str]] = None):
132
+ if choices is None:
133
+ choices = {}
134
+
135
+ if default and not any(default in choices for choices in choices.values()):
136
+ if not choices:
137
+ print(
138
+ f"Warning: Default value {default} provided but choices are empty."
139
+ )
140
+ else:
141
+ raise ValueError(
142
+ f"Default value {default} is not in the provided choices"
143
+ )
144
+
145
+ if not default:
146
+ for choices in choices.values():
147
+ if choices:
148
+ default = choices[0]
149
+ break
150
+
151
+ instance = super().__new__(cls, default)
152
+ instance.choices = choices
153
+ instance.default = default
154
+ return instance
155
+
156
+ @classmethod
157
+ def __modify_schema__(cls, field_schema: dict[str, Any], **kwargs):
158
+ choices = kwargs.get("choices", {})
159
+ field_schema.update(
160
+ {
161
+ "x-parameter": "grouped_choice",
162
+ "type": "string",
163
+ "choices": choices,
164
+ }
165
+ )
166
+
167
+
130
168
  class Message(BaseModel):
131
169
  role: str
132
170
  content: str