agenta 0.39.4__py3-none-any.whl → 0.41.0__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.
agenta/sdk/decorators/tracing.py
CHANGED
agenta/sdk/tracing/attributes.py
CHANGED
|
@@ -103,19 +103,63 @@ def _encode_key(
|
|
|
103
103
|
return f"ag.{namespace}.{key}"
|
|
104
104
|
|
|
105
105
|
|
|
106
|
-
def
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
def _make_serializable(value: Any) -> Any:
|
|
107
|
+
"""
|
|
108
|
+
Transform complex nested structures into JSON-serializable form.
|
|
109
|
+
Handles Pydantic models, nested dictionaries and lists recursively.
|
|
110
|
+
"""
|
|
111
|
+
if value is None or isinstance(value, (str, int, float, bool, bytes)):
|
|
112
|
+
return value
|
|
113
|
+
|
|
114
|
+
# Handle Pydantic objects (prioritize v2 over v1 API)
|
|
115
|
+
if hasattr(value, "model_dump"): # Pydantic v2
|
|
116
|
+
return value.model_dump()
|
|
117
|
+
elif hasattr(value, "dict"): # Pydantic v1
|
|
118
|
+
return value.dict()
|
|
119
|
+
|
|
120
|
+
if isinstance(value, dict):
|
|
121
|
+
try:
|
|
122
|
+
# Test serialization without modifying - optimizes for already-serializable dicts
|
|
123
|
+
dumps(
|
|
124
|
+
value
|
|
125
|
+
) # If serialization fails, we'll catch the exception and process deeply
|
|
126
|
+
return value # Avoid unnecessary recursion for serializable dicts
|
|
127
|
+
except TypeError:
|
|
128
|
+
return {k: _make_serializable(v) for k, v in value.items()}
|
|
129
|
+
elif isinstance(value, list):
|
|
130
|
+
try:
|
|
131
|
+
# Test serialization without modifying - optimizes for already-serializable lists
|
|
132
|
+
dumps(
|
|
133
|
+
value
|
|
134
|
+
) # If serialization fails, we'll catch the exception and process deeply
|
|
135
|
+
return value # Avoid unnecessary recursion for serializable lists
|
|
136
|
+
except TypeError:
|
|
137
|
+
return [_make_serializable(item) for item in value]
|
|
138
|
+
|
|
139
|
+
return repr(value)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def _encode_value(value: Any) -> Optional[Attribute]:
|
|
143
|
+
"""
|
|
144
|
+
Encode values for tracing, ensuring proper JSON serialization.
|
|
145
|
+
Adds the @ag.type=json: prefix only to appropriate values.
|
|
146
|
+
"""
|
|
109
147
|
if value is None:
|
|
110
148
|
return None
|
|
111
149
|
|
|
112
150
|
if isinstance(value, (str, int, float, bool, bytes)):
|
|
113
151
|
return value
|
|
114
152
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
153
|
+
try:
|
|
154
|
+
if (
|
|
155
|
+
isinstance(value, (dict, list))
|
|
156
|
+
or hasattr(value, "model_dump")
|
|
157
|
+
or hasattr(value, "dict")
|
|
158
|
+
):
|
|
159
|
+
serializable_value = _make_serializable(value)
|
|
160
|
+
return "@ag.type=json:" + dumps(serializable_value)
|
|
161
|
+
except TypeError:
|
|
162
|
+
pass
|
|
119
163
|
|
|
120
164
|
return repr(value)
|
|
121
165
|
|
|
@@ -207,7 +207,7 @@ agenta/sdk/context/routing.py,sha256=FEsjw8EttI1SMyUo96ptcUsvHJnhoKwdr1szlkxxJNU
|
|
|
207
207
|
agenta/sdk/context/tracing.py,sha256=xjErrXP1Nq1AfL-Cif1l-lNEfs12eQ3v_VCRgoKe7nY,743
|
|
208
208
|
agenta/sdk/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
209
209
|
agenta/sdk/decorators/routing.py,sha256=RUq55Y3GHkQilJlobQmUHnHBmPZrhHgQyPxKF_D9RXo,24799
|
|
210
|
-
agenta/sdk/decorators/tracing.py,sha256=
|
|
210
|
+
agenta/sdk/decorators/tracing.py,sha256=n3AZWw8HHKUoIHD79_ktPQcoZRIw3RthSxU5xkO-skg,10109
|
|
211
211
|
agenta/sdk/litellm/__init__.py,sha256=Bpz1gfHQc0MN1yolWcjifLWznv6GjHggvRGQSpxpihM,37
|
|
212
212
|
agenta/sdk/litellm/litellm.py,sha256=vZYuzcSss04zE258eC-3xjKjY-HToafB1ekjmKjMR4U,10202
|
|
213
213
|
agenta/sdk/litellm/mockllm.py,sha256=8V6dqdv8eA4P-VoXIwHNYlIjHG189P14POSfSfluVw0,678
|
|
@@ -230,7 +230,7 @@ agenta/sdk/middleware/otel.py,sha256=lHzhGUv4fq2RPuTPH2keJ16v-_cBUrLrTqWzHUmEVdI
|
|
|
230
230
|
agenta/sdk/middleware/vault.py,sha256=Hd_S8Lw1PLFdavnFwW_bb-HYlyYvaCxNJNwjvd2Bxyc,4043
|
|
231
231
|
agenta/sdk/router.py,sha256=mOguvtOwl2wmyAgOuWTsf98pQwpNiUILKIo67W_hR3A,119
|
|
232
232
|
agenta/sdk/tracing/__init__.py,sha256=rQNe5-zT5Kt7_CDhq-lnUIi1EYTBVzVf_MbfcIxVD98,41
|
|
233
|
-
agenta/sdk/tracing/attributes.py,sha256=
|
|
233
|
+
agenta/sdk/tracing/attributes.py,sha256=DwjjOk3mGOvz0jYu8EYr3hhItvawK5GX80_MfciqPrc,5559
|
|
234
234
|
agenta/sdk/tracing/conventions.py,sha256=JBtznBXZ3aRkGKkLl7cPwdMNh3w1G-H2Ta2YrAxbr38,950
|
|
235
235
|
agenta/sdk/tracing/exporters.py,sha256=ib-VSMaqKn3XDrChjjHlsPJ9Fu3ePgIYR-TAWxSJv9Q,3251
|
|
236
236
|
agenta/sdk/tracing/inline.py,sha256=tY9mH1zMlJMqf2WWKJdakLtMHJKNeYRaynqvsPeqpTY,31312
|
|
@@ -250,6 +250,6 @@ agenta/sdk/utils/logging.py,sha256=gBk2ecRvltN7f8qtnUHXBiZPWOdArN_b5civ_3w_Oek,8
|
|
|
250
250
|
agenta/sdk/utils/preinit.py,sha256=YlJL7RLfel0R7DFp-jK7OV-z4ZIQJM0oupYlk7g8b5o,1278
|
|
251
251
|
agenta/sdk/utils/singleton.py,sha256=17Ph7LGnnV8HkPjImruKita2ni03Ari5jr0jqm__4sc,312
|
|
252
252
|
agenta/sdk/utils/timing.py,sha256=hVzkF7ObjrBlRcB2lMowE8nUkWgYqU2kIJoqRZNXKdM,1556
|
|
253
|
-
agenta-0.
|
|
254
|
-
agenta-0.
|
|
255
|
-
agenta-0.
|
|
253
|
+
agenta-0.41.0.dist-info/METADATA,sha256=98LSFJoS97TCXN7BEsb7SMNiLqH_w04tpZVgkyihIW4,31346
|
|
254
|
+
agenta-0.41.0.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
|
255
|
+
agenta-0.41.0.dist-info/RECORD,,
|
|
File without changes
|