agenta 0.56.1__py3-none-any.whl → 0.56.3__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.

@@ -39,7 +39,7 @@ class RawVaultClient:
39
39
  Successful Response
40
40
  """
41
41
  _response = self._client_wrapper.httpx_client.request(
42
- "vault/v1/secrets",
42
+ "vault/v1/secrets/",
43
43
  method="GET",
44
44
  request_options=request_options,
45
45
  )
@@ -89,7 +89,7 @@ class RawVaultClient:
89
89
  Successful Response
90
90
  """
91
91
  _response = self._client_wrapper.httpx_client.request(
92
- "vault/v1/secrets",
92
+ "vault/v1/secrets/",
93
93
  method="POST",
94
94
  json={
95
95
  "header": convert_and_respect_annotation_metadata(
@@ -337,7 +337,7 @@ class AsyncRawVaultClient:
337
337
  Successful Response
338
338
  """
339
339
  _response = await self._client_wrapper.httpx_client.request(
340
- "vault/v1/secrets",
340
+ "vault/v1/secrets/",
341
341
  method="GET",
342
342
  request_options=request_options,
343
343
  )
@@ -387,7 +387,7 @@ class AsyncRawVaultClient:
387
387
  Successful Response
388
388
  """
389
389
  _response = await self._client_wrapper.httpx_client.request(
390
- "vault/v1/secrets",
390
+ "vault/v1/secrets/",
391
391
  method="POST",
392
392
  json={
393
393
  "header": convert_and_respect_annotation_metadata(
@@ -93,13 +93,18 @@ class ConfigMiddleware(BaseHTTPMiddleware):
93
93
 
94
94
  return parameters, references
95
95
 
96
- config = {}
96
+ config = dict()
97
+ app_ref = None
97
98
 
98
99
  is_test_path = request.url.path.endswith("/test")
99
100
  are_refs_missing = not variant_ref and not environment_ref
100
- should_fetch = not is_test_path or not are_refs_missing
101
+ should_fetch_application_revision = not is_test_path or not are_refs_missing
102
+ is_app_ref_incomplete = (
103
+ application_ref and application_ref.id and not application_ref.slug
104
+ )
105
+ should_fetch_application = is_app_ref_incomplete
101
106
 
102
- if should_fetch:
107
+ if should_fetch_application_revision:
103
108
  async with httpx.AsyncClient() as client:
104
109
  response = await client.post(
105
110
  f"{self.host}/api/variants/configs/fetch",
@@ -110,13 +115,26 @@ class ConfigMiddleware(BaseHTTPMiddleware):
110
115
  if response.status_code == 200:
111
116
  config = response.json()
112
117
 
113
- if not config:
114
- config["application_ref"] = refs[
115
- "application_ref"
116
- ] # by default, application_ref will always have an id
117
- parameters = None
118
- else:
118
+ elif should_fetch_application:
119
+ async with httpx.AsyncClient() as client:
120
+ response = await client.get(
121
+ f"{self.host}/api/apps/{application_ref.id}",
122
+ headers=headers,
123
+ )
124
+
125
+ if response.status_code == 200:
126
+ app = response.json()
127
+ app_ref = {
128
+ "id": app.get("app_id"),
129
+ "slug": app.get("app_name"),
130
+ }
131
+
132
+ if config:
119
133
  parameters = config.get("params")
134
+ else:
135
+ # by default, application_ref will always have an id
136
+ config["application_ref"] = app_ref or refs["application_ref"]
137
+ parameters = None
120
138
 
121
139
  references = {}
122
140
 
@@ -101,7 +101,7 @@ class VaultMiddleware(BaseHTTPMiddleware):
101
101
  try:
102
102
  async with httpx.AsyncClient() as client:
103
103
  response = await client.get(
104
- f"{self.host}/api/vault/v1/secrets",
104
+ f"{self.host}/api/vault/v1/secrets/",
105
105
  headers=headers,
106
106
  )
107
107
 
@@ -6,7 +6,7 @@ PrimitivesSequence = Sequence[Primitive]
6
6
  Attribute = Union[Primitive, PrimitivesSequence]
7
7
 
8
8
 
9
- def _marshal(
9
+ def _marshall(
10
10
  unmarshalled: Dict[str, Any],
11
11
  *,
12
12
  parent_key: Optional[str] = "",
@@ -59,7 +59,7 @@ def _marshal(
59
59
  dict_key = child_key
60
60
 
61
61
  marshalled.update(
62
- _marshal(
62
+ _marshall(
63
63
  value,
64
64
  parent_key=dict_key,
65
65
  depth=depth + 1,
@@ -76,7 +76,7 @@ def _marshal(
76
76
 
77
77
  if isinstance(item, (dict, list)):
78
78
  marshalled.update(
79
- _marshal(
79
+ _marshall(
80
80
  item,
81
81
  parent_key=list_key,
82
82
  depth=depth + 1,
@@ -177,7 +177,7 @@ def serialize(
177
177
  k: v
178
178
  for k, v in {
179
179
  _encode_key(namespace, key): _encode_value(value)
180
- for key, value in _marshal(attributes, max_depth=max_depth).items()
180
+ for key, value in _marshall(attributes, max_depth=max_depth).items()
181
181
  }.items()
182
182
  if v is not None
183
183
  }
@@ -532,11 +532,11 @@ from json import loads, JSONDecodeError, dumps
532
532
  from copy import copy
533
533
 
534
534
 
535
- def _unmarshal_attributes(
535
+ def _unmarshall_attributes(
536
536
  marshalled: Dict[str, Any],
537
537
  ) -> Dict[str, Any]:
538
538
  """
539
- Unmarshals a dictionary of marshalled attributes into a nested dictionary
539
+ Unmarshalls a dictionary of marshalled attributes into a nested dictionary
540
540
 
541
541
  Example:
542
542
  marshalled = {
@@ -566,42 +566,34 @@ def _unmarshal_attributes(
566
566
 
567
567
  for key, value in marshalled.items():
568
568
  keys = key.split(".")
569
-
570
- level = unmarshalled
571
-
572
- for i, part in enumerate(keys[:-1]):
573
- if part.isdigit():
574
- part = int(part)
575
-
576
- if not isinstance(level, list):
577
- level = []
578
-
579
- while len(level) <= part:
580
- level.append({})
581
-
582
- level = level[part]
583
-
569
+ current = unmarshalled
570
+
571
+ for i, key in enumerate(keys):
572
+ is_last = i == len(keys) - 1
573
+ next_key = keys[i + 1] if not is_last else None
574
+ is_index = key.isdigit()
575
+ key = int(key) if is_index else key
576
+
577
+ if is_last:
578
+ if isinstance(current, list) and isinstance(key, int):
579
+ while len(current) <= key:
580
+ current.append(None)
581
+ current[key] = value
582
+ elif isinstance(current, dict):
583
+ current[key] = value
584
584
  else:
585
- if part not in level:
586
- level[part] = {} if not keys[i + 1].isdigit() else []
587
-
588
- level = level[part]
589
-
590
- last_key = keys[-1]
591
-
592
- if last_key.isdigit():
593
- last_key = int(last_key)
594
-
595
- if not isinstance(level, list):
596
- level = []
597
-
598
- while len(level) <= last_key:
599
- level.append(None)
600
-
601
- level[last_key] = value
602
-
603
- else:
604
- level[last_key] = value
585
+ next_is_index = next_key.isdigit() if next_key else False
586
+
587
+ if isinstance(current, list) and isinstance(key, int):
588
+ while len(current) <= key:
589
+ current.append([] if next_is_index else {})
590
+ if current[key] is None:
591
+ current[key] = [] if next_is_index else {}
592
+ current = current[key]
593
+ elif isinstance(current, dict):
594
+ if key not in current:
595
+ current[key] = [] if next_is_index else {}
596
+ current = current[key]
605
597
 
606
598
  return unmarshalled
607
599
 
@@ -750,7 +742,7 @@ def _parse_from_attributes(
750
742
  for key in _data.keys():
751
743
  del otel_span_dto.attributes[_encode_key("data", key)]
752
744
 
753
- # _data = _unmarshal_attributes(_data)
745
+ # _data = _unmarshall_attributes(_data)
754
746
  _data = _data if _data else None
755
747
 
756
748
  # METRICS
@@ -759,7 +751,7 @@ def _parse_from_attributes(
759
751
  for key in _metrics.keys():
760
752
  del otel_span_dto.attributes[_encode_key("metrics", key)]
761
753
 
762
- # _metrics = _unmarshal_attributes(_metrics)
754
+ # _metrics = _unmarshall_attributes(_metrics)
763
755
  _metrics = _metrics if _metrics else None
764
756
 
765
757
  # META
@@ -768,7 +760,7 @@ def _parse_from_attributes(
768
760
  for key in _meta.keys():
769
761
  del otel_span_dto.attributes[_encode_key("meta", key)]
770
762
 
771
- # _meta = _unmarshal_attributes(_meta)
763
+ # _meta = _unmarshall_attributes(_meta)
772
764
  _meta = _meta if _meta else None
773
765
 
774
766
  # TAGS
@@ -904,7 +896,7 @@ def parse_to_agenta_span_dto(
904
896
  ) -> SpanDTO:
905
897
  # DATA
906
898
  if span_dto.data:
907
- span_dto.data = _unmarshal_attributes(span_dto.data)
899
+ span_dto.data = _unmarshall_attributes(span_dto.data)
908
900
 
909
901
  if "outputs" in span_dto.data:
910
902
  if "__default__" in span_dto.data["outputs"]:
@@ -912,19 +904,19 @@ def parse_to_agenta_span_dto(
912
904
 
913
905
  # METRICS
914
906
  if span_dto.metrics:
915
- span_dto.metrics = _unmarshal_attributes(span_dto.metrics)
907
+ span_dto.metrics = _unmarshall_attributes(span_dto.metrics)
916
908
 
917
909
  # META
918
910
  if span_dto.meta:
919
- span_dto.meta = _unmarshal_attributes(span_dto.meta)
911
+ span_dto.meta = _unmarshall_attributes(span_dto.meta)
920
912
 
921
913
  # TAGS
922
914
  if span_dto.tags:
923
- span_dto.tags = _unmarshal_attributes(span_dto.tags)
915
+ span_dto.tags = _unmarshall_attributes(span_dto.tags)
924
916
 
925
917
  # REFS
926
918
  if span_dto.refs:
927
- span_dto.refs = _unmarshal_attributes(span_dto.refs)
919
+ span_dto.refs = _unmarshall_attributes(span_dto.refs)
928
920
 
929
921
  if isinstance(span_dto.links, list):
930
922
  for link in span_dto.links:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agenta
3
- Version: 0.56.1
3
+ Version: 0.56.3
4
4
  Summary: The SDK for agenta is an open-source LLMOps platform.
5
5
  Keywords: LLMOps,LLM,evaluation,prompt engineering
6
6
  Author: Mahmoud Mabrouk
@@ -290,7 +290,7 @@ agenta/client/backend/variants/types/__init__.py,sha256=TVwvQoKg9uUo3mFSAhpvMEhC
290
290
  agenta/client/backend/variants/types/add_variant_from_base_and_config_response.py,sha256=KXnLr_ZwsEWvaamIlUqAjyu2X394WN4Xz82WX4dRXiQ,248
291
291
  agenta/client/backend/vault/__init__.py,sha256=ubAQC1MczTU-pkK0TqRAjY5X8buyQIlNZY2RuM4nJpc,84
292
292
  agenta/client/backend/vault/client.py,sha256=X8gzIHvAaFbe2acBcHXubnKP4olGgdZy6esxjzYt91M,11205
293
- agenta/client/backend/vault/raw_client.py,sha256=9C2pqxesrbS9QtVkXkeRl3Pxc8U-Usm0CFLjeqILVZA,21373
293
+ agenta/client/backend/vault/raw_client.py,sha256=lL7q9lbCLypepKxA3H8TgVf2zXH1Wufz4XPIzek8QTY,21377
294
294
  agenta/client/backend/workflows/__init__.py,sha256=ubAQC1MczTU-pkK0TqRAjY5X8buyQIlNZY2RuM4nJpc,84
295
295
  agenta/client/backend/workflows/client.py,sha256=SVH3Iv3hp1QpXu2NOb8HusCeUzQZldrdAf3kEpCf2e8,63639
296
296
  agenta/client/backend/workflows/raw_client.py,sha256=fXK3b6Q20FETvFD5cYus6j7kcQ-IcnzzXQ11ujb4TWQ,127390
@@ -332,19 +332,19 @@ agenta/sdk/middleware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
332
332
  agenta/sdk/middleware/adapt.py,sha256=hRMwaCv_-6vA80YiYRA25ONl7WHEClmVgqnbHUYfwLQ,7195
333
333
  agenta/sdk/middleware/auth.py,sha256=bcg2MrCIqruVblbsNuSKZXXkutu0iRfSQp_AJZtJs14,16389
334
334
  agenta/sdk/middleware/base.py,sha256=V-yjdm0BioM3myD0DXOCXlvb_8WYKLwUcboAR8mG-IE,1064
335
- agenta/sdk/middleware/config.py,sha256=zd57kxaeYheZMG8nD5VOYgHXw8j9zRlFacuzCGHWeEA,7978
335
+ agenta/sdk/middleware/config.py,sha256=0eKRkARI0fkXwmq3NNL4x7iOue0_xN3RQCgoHk8guTc,8723
336
336
  agenta/sdk/middleware/cors.py,sha256=q3r7lGkrIdMcT_vuhsburMcjG7pyl7w0ycxrIrGJ2e8,921
337
337
  agenta/sdk/middleware/flags.py,sha256=okku9RBmcD4Qka8XIsVqtroMDg-9IXevUwDiAA9whJg,990
338
338
  agenta/sdk/middleware/inline.py,sha256=ee8E4XBGcRSrHTvblqX1yRXuTN_sxLm7lY1jnywrBG8,901
339
339
  agenta/sdk/middleware/mock.py,sha256=bCUN9iJBxePyN9MBwBpJs-_iCNkUQeUjIIu3WElS1oQ,759
340
340
  agenta/sdk/middleware/otel.py,sha256=lHzhGUv4fq2RPuTPH2keJ16v-_cBUrLrTqWzHUmEVdI,1041
341
- agenta/sdk/middleware/vault.py,sha256=Sxd8y0yTMRIpT0r0iwYUNv3SVXTGUEcYf8RaXISIalQ,4058
341
+ agenta/sdk/middleware/vault.py,sha256=sF2CmWQdCvXJcmZppT4duV0KgqHW4c4wg4Fs_i1SvNs,4059
342
342
  agenta/sdk/router.py,sha256=mOguvtOwl2wmyAgOuWTsf98pQwpNiUILKIo67W_hR3A,119
343
343
  agenta/sdk/tracing/__init__.py,sha256=rQNe5-zT5Kt7_CDhq-lnUIi1EYTBVzVf_MbfcIxVD98,41
344
- agenta/sdk/tracing/attributes.py,sha256=DwjjOk3mGOvz0jYu8EYr3hhItvawK5GX80_MfciqPrc,5559
344
+ agenta/sdk/tracing/attributes.py,sha256=Brqle9hGV3DaEJjeYCBq7MDlbvHMAIwmkUj2Lni8dF4,5563
345
345
  agenta/sdk/tracing/conventions.py,sha256=JBtznBXZ3aRkGKkLl7cPwdMNh3w1G-H2Ta2YrAxbr38,950
346
346
  agenta/sdk/tracing/exporters.py,sha256=b1Aq5AcQYnmAxapQMYpN_MfaLOG4IGTzlQw3PfBiKgI,3486
347
- agenta/sdk/tracing/inline.py,sha256=y2S_MGGqmXgyUgbkNNyrb8_X-QtGuDy8JwxlwWibIx8,31507
347
+ agenta/sdk/tracing/inline.py,sha256=UKt10JGKdS6gVDIpExng3UC8vegAcuA2KxlzyvSdUZ0,31886
348
348
  agenta/sdk/tracing/processors.py,sha256=ZE6baO2U3ER73rckvXhdbNmLgs3jn6le7iAUQc6osbY,5141
349
349
  agenta/sdk/tracing/propagation.py,sha256=EeOqDMqnh_MoEhGd1do_vy_tQBYUcoC8kpLqVoZeqg0,2561
350
350
  agenta/sdk/tracing/spans.py,sha256=nqUOjjirBxB8Eacv8Qj4Ra_6rknGi3lbJdNyKmk5ODQ,3707
@@ -366,6 +366,6 @@ agenta/sdk/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
366
366
  agenta/sdk/workflows/registry.py,sha256=4FRSeU4njMmP6xFCIteF5f_W6NVlqFTx1AM7hsaGAQk,975
367
367
  agenta/sdk/workflows/types.py,sha256=SjYeT8FWVgwaIIC8sI3fRjKERLEA_oxuBGvYSaFqNg8,11720
368
368
  agenta/sdk/workflows/utils.py,sha256=ILfY8DSBWLrdWIuKg6mq7rANwKiiY6sxEeFiBFhjLYM,413
369
- agenta-0.56.1.dist-info/METADATA,sha256=1Rq5J7bPddrmALkGH_8k9M5rRElnzpRP-3PbGP3G3nw,31753
370
- agenta-0.56.1.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
371
- agenta-0.56.1.dist-info/RECORD,,
369
+ agenta-0.56.3.dist-info/METADATA,sha256=VEW9AVDRDBrKZa_Mmd5dsgZ8e9fYWcgotpCMyHL0cto,31753
370
+ agenta-0.56.3.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
371
+ agenta-0.56.3.dist-info/RECORD,,