agenta 0.20.0a1__py3-none-any.whl → 0.20.0a4__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/client/backend/resources/observability/client.py +3 -0
- agenta/client/backend/types/span.py +1 -1
- agenta/client/backend/types/span_detail.py +1 -1
- agenta/client/backend/types/trace_detail.py +1 -1
- agenta/sdk/decorators/llm_entrypoint.py +40 -8
- agenta/sdk/decorators/tracing.py +32 -2
- {agenta-0.20.0a1.dist-info → agenta-0.20.0a4.dist-info}/METADATA +1 -1
- {agenta-0.20.0a1.dist-info → agenta-0.20.0a4.dist-info}/RECORD +10 -10
- {agenta-0.20.0a1.dist-info → agenta-0.20.0a4.dist-info}/WHEEL +0 -0
- {agenta-0.20.0a1.dist-info → agenta-0.20.0a4.dist-info}/entry_points.txt +0 -0
|
@@ -17,6 +17,9 @@ from ...types.span_detail import SpanDetail
|
|
|
17
17
|
from ...types.trace_detail import TraceDetail
|
|
18
18
|
from ...types.with_pagination import WithPagination
|
|
19
19
|
|
|
20
|
+
from agenta.sdk.tracing.logger import llm_logger as logging
|
|
21
|
+
|
|
22
|
+
|
|
20
23
|
try:
|
|
21
24
|
import pydantic.v1 as pydantic # type: ignore
|
|
22
25
|
except ImportError:
|
|
@@ -22,7 +22,7 @@ class SpanDetail(pydantic.BaseModel):
|
|
|
22
22
|
created_at: dt.datetime
|
|
23
23
|
variant: SpanVariant
|
|
24
24
|
environment: typing.Optional[str]
|
|
25
|
-
spankind:
|
|
25
|
+
spankind: str
|
|
26
26
|
status: SpanStatusCode
|
|
27
27
|
metadata: typing.Dict[str, typing.Any]
|
|
28
28
|
user_id: typing.Optional[str]
|
|
@@ -22,7 +22,7 @@ class TraceDetail(pydantic.BaseModel):
|
|
|
22
22
|
created_at: dt.datetime
|
|
23
23
|
variant: SpanVariant
|
|
24
24
|
environment: typing.Optional[str]
|
|
25
|
-
spankind:
|
|
25
|
+
spankind: str
|
|
26
26
|
status: SpanStatusCode
|
|
27
27
|
metadata: typing.Dict[str, typing.Any]
|
|
28
28
|
user_id: typing.Optional[str]
|
|
@@ -141,7 +141,11 @@ class entrypoint(BaseDecorator):
|
|
|
141
141
|
)
|
|
142
142
|
|
|
143
143
|
entrypoint_result = await self.execute_function(
|
|
144
|
-
func,
|
|
144
|
+
func,
|
|
145
|
+
True, # inline trace: True
|
|
146
|
+
*args,
|
|
147
|
+
params=func_params,
|
|
148
|
+
config_params=config_params,
|
|
145
149
|
)
|
|
146
150
|
|
|
147
151
|
return entrypoint_result
|
|
@@ -157,7 +161,7 @@ class entrypoint(BaseDecorator):
|
|
|
157
161
|
entrypoint.routes.append(
|
|
158
162
|
{
|
|
159
163
|
"func": func.__name__,
|
|
160
|
-
"endpoint":
|
|
164
|
+
"endpoint": route,
|
|
161
165
|
"params": {**config_params, **func_signature.parameters},
|
|
162
166
|
}
|
|
163
167
|
)
|
|
@@ -167,7 +171,7 @@ class entrypoint(BaseDecorator):
|
|
|
167
171
|
entrypoint.routes.append(
|
|
168
172
|
{
|
|
169
173
|
"func": func.__name__,
|
|
170
|
-
"endpoint": route
|
|
174
|
+
"endpoint": route,
|
|
171
175
|
"params": {**config_params, **func_signature.parameters},
|
|
172
176
|
}
|
|
173
177
|
)
|
|
@@ -194,7 +198,11 @@ class entrypoint(BaseDecorator):
|
|
|
194
198
|
)
|
|
195
199
|
|
|
196
200
|
entrypoint_result = await self.execute_function(
|
|
197
|
-
func,
|
|
201
|
+
func,
|
|
202
|
+
False, # inline trace: False
|
|
203
|
+
*args,
|
|
204
|
+
params=func_params,
|
|
205
|
+
config_params=config_params,
|
|
198
206
|
)
|
|
199
207
|
|
|
200
208
|
return entrypoint_result
|
|
@@ -205,7 +213,7 @@ class entrypoint(BaseDecorator):
|
|
|
205
213
|
ingestible_files,
|
|
206
214
|
)
|
|
207
215
|
|
|
208
|
-
if route_path == "
|
|
216
|
+
if route_path == "":
|
|
209
217
|
route_deployed = f"/{DEFAULT_PATH}_deployed"
|
|
210
218
|
app.post(route_deployed, response_model=BaseResponse)(wrapper_deployed)
|
|
211
219
|
|
|
@@ -226,6 +234,8 @@ class entrypoint(BaseDecorator):
|
|
|
226
234
|
)
|
|
227
235
|
### ---------------------- #
|
|
228
236
|
|
|
237
|
+
print(entrypoint.routes)
|
|
238
|
+
|
|
229
239
|
if self.is_main_script(func) and route_path == "":
|
|
230
240
|
self.handle_terminal_run(
|
|
231
241
|
func,
|
|
@@ -272,7 +282,9 @@ class entrypoint(BaseDecorator):
|
|
|
272
282
|
if name in func_params and func_params[name] is not None:
|
|
273
283
|
func_params[name] = self.ingest_file(func_params[name])
|
|
274
284
|
|
|
275
|
-
async def execute_function(
|
|
285
|
+
async def execute_function(
|
|
286
|
+
self, func: Callable[..., Any], inline_trace, *args, **func_params
|
|
287
|
+
):
|
|
276
288
|
"""Execute the function and handle any exceptions."""
|
|
277
289
|
|
|
278
290
|
try:
|
|
@@ -309,18 +321,33 @@ class entrypoint(BaseDecorator):
|
|
|
309
321
|
remaining_steps -= 1
|
|
310
322
|
|
|
311
323
|
trace = ag.tracing.dump_trace()
|
|
324
|
+
|
|
325
|
+
if not inline_trace:
|
|
326
|
+
trace = {"trace_id": trace["trace_id"]}
|
|
327
|
+
|
|
312
328
|
ag.tracing.flush_spans()
|
|
313
329
|
tracing_context.reset(token)
|
|
314
330
|
|
|
315
331
|
if isinstance(result, Context):
|
|
316
332
|
save_context(result)
|
|
317
333
|
|
|
334
|
+
DEFAULT_KEY = "message"
|
|
335
|
+
|
|
318
336
|
if isinstance(result, Dict):
|
|
319
337
|
data = result
|
|
338
|
+
|
|
339
|
+
# EVENTUALLY THIS PATCH SHOULD BE REMOVED
|
|
340
|
+
# PATCH: if message in result then only keep message key/value
|
|
341
|
+
# DEFAULT_KEY = "message"
|
|
342
|
+
|
|
343
|
+
if "message" in result.keys():
|
|
344
|
+
data = {DEFAULT_KEY: result["message"]}
|
|
345
|
+
# END OF PATCH
|
|
346
|
+
|
|
320
347
|
elif isinstance(result, str):
|
|
321
|
-
data = {
|
|
348
|
+
data = {DEFAULT_KEY: result}
|
|
322
349
|
elif isinstance(result, int) or isinstance(result, float):
|
|
323
|
-
data = {
|
|
350
|
+
data = {DEFAULT_KEY: str(result)}
|
|
324
351
|
|
|
325
352
|
if data is None:
|
|
326
353
|
warning = (
|
|
@@ -528,6 +555,7 @@ class entrypoint(BaseDecorator):
|
|
|
528
555
|
result = loop.run_until_complete(
|
|
529
556
|
self.execute_function(
|
|
530
557
|
func,
|
|
558
|
+
True, # inline trace: True
|
|
531
559
|
**{"params": args_func_params, "config_params": args_config_params},
|
|
532
560
|
)
|
|
533
561
|
)
|
|
@@ -608,9 +636,13 @@ class entrypoint(BaseDecorator):
|
|
|
608
636
|
|
|
609
637
|
return param_type
|
|
610
638
|
|
|
639
|
+
# Goes from '/some/path' to 'some_path'
|
|
640
|
+
endpoint = endpoint[1:].replace("/", "_")
|
|
641
|
+
|
|
611
642
|
schema_to_override = openapi_schema["components"]["schemas"][
|
|
612
643
|
f"Body_{func}_{endpoint}_post"
|
|
613
644
|
]["properties"]
|
|
645
|
+
|
|
614
646
|
for param_name, param_val in params.items():
|
|
615
647
|
if isinstance(param_val, GroupedMultipleChoiceParam):
|
|
616
648
|
subschema = find_in_schema(
|
agenta/sdk/decorators/tracing.py
CHANGED
|
@@ -65,7 +65,22 @@ class instrument(BaseDecorator):
|
|
|
65
65
|
):
|
|
66
66
|
result = await func(*args, **kwargs)
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
outputs = result
|
|
69
|
+
|
|
70
|
+
# EVENTUALLY THIS PATCH SHOULD BE REMOVED
|
|
71
|
+
# PATCH : if result is not a dict, make it a dict, in span
|
|
72
|
+
DEFAULT_KEY = "message"
|
|
73
|
+
|
|
74
|
+
if not isinstance(result, dict):
|
|
75
|
+
value = result
|
|
76
|
+
|
|
77
|
+
if result.__class__.__module__ != "__builtin__":
|
|
78
|
+
value = repr(value)
|
|
79
|
+
|
|
80
|
+
outputs = {DEFAULT_KEY: result}
|
|
81
|
+
# END OF PATH
|
|
82
|
+
|
|
83
|
+
ag.tracing.store_outputs(outputs)
|
|
69
84
|
|
|
70
85
|
return result
|
|
71
86
|
|
|
@@ -82,7 +97,22 @@ class instrument(BaseDecorator):
|
|
|
82
97
|
):
|
|
83
98
|
result = func(*args, **kwargs)
|
|
84
99
|
|
|
85
|
-
|
|
100
|
+
outputs = result
|
|
101
|
+
|
|
102
|
+
# EVENTUALLY THIS PATCH SHOULD BE REMOVED
|
|
103
|
+
# PATCH : if result is not a dict, make it a dict, in span
|
|
104
|
+
DEFAULT_KEY = "message"
|
|
105
|
+
|
|
106
|
+
if not isinstance(result, dict):
|
|
107
|
+
value = result
|
|
108
|
+
|
|
109
|
+
if result.__class__.__module__ != "__builtin__":
|
|
110
|
+
value = repr(value)
|
|
111
|
+
|
|
112
|
+
outputs = {DEFAULT_KEY: result}
|
|
113
|
+
# END OF PATH
|
|
114
|
+
|
|
115
|
+
ag.tracing.store_outputs(outputs)
|
|
86
116
|
|
|
87
117
|
return result
|
|
88
118
|
|
|
@@ -37,7 +37,7 @@ agenta/client/backend/resources/evaluations/client.py,sha256=T8ETcdUdAMzSA3TGu-C
|
|
|
37
37
|
agenta/client/backend/resources/evaluators/__init__.py,sha256=9mUnTDeA1TxYvkj1l01A1prqsJV0ERRY2tzkY1fA4MQ,64
|
|
38
38
|
agenta/client/backend/resources/evaluators/client.py,sha256=xaafddTNiiPpcxbiUFqimaN3tE6fiemYNOpt1wRLci0,21753
|
|
39
39
|
agenta/client/backend/resources/observability/__init__.py,sha256=9mUnTDeA1TxYvkj1l01A1prqsJV0ERRY2tzkY1fA4MQ,64
|
|
40
|
-
agenta/client/backend/resources/observability/client.py,sha256=
|
|
40
|
+
agenta/client/backend/resources/observability/client.py,sha256=sQuDHooWEFbTAnejYKK1tjFwcSMwH9cSrytvecH_9Rw,42986
|
|
41
41
|
agenta/client/backend/resources/testsets/__init__.py,sha256=9mUnTDeA1TxYvkj1l01A1prqsJV0ERRY2tzkY1fA4MQ,64
|
|
42
42
|
agenta/client/backend/resources/testsets/client.py,sha256=jVRwbUAPPgXoApClHjoDQNeVQTxZWq4c7-CT1YZ7DRA,25010
|
|
43
43
|
agenta/client/backend/resources/variants/__init__.py,sha256=BMR4SvsrqXC9FU8nPVzY8M9xGrBEhEGrmbgvy3iM1aE,171
|
|
@@ -94,8 +94,8 @@ agenta/client/backend/types/permission.py,sha256=MwGwNvKhH8W4I0uJZG_mUydJgwE5CF1
|
|
|
94
94
|
agenta/client/backend/types/result.py,sha256=XEUcohx29Rl8P9KfnygbdbeNcgvPgO6WOZv9bebCVsg,1055
|
|
95
95
|
agenta/client/backend/types/score.py,sha256=OAur_nJtRQmpboZfzFi2l1-zmNxFfETcl13C7OAvpMw,111
|
|
96
96
|
agenta/client/backend/types/simple_evaluation_output.py,sha256=gRLOCps1hhXPgioADjD2DfabNJf9WgmmhPI6lJY00q4,1117
|
|
97
|
-
agenta/client/backend/types/span.py,sha256
|
|
98
|
-
agenta/client/backend/types/span_detail.py,sha256=
|
|
97
|
+
agenta/client/backend/types/span.py,sha256=-TrMb3pnTjcbEeD4NA3STGl6V-VyXQ4de7VOjrjwxf4,1450
|
|
98
|
+
agenta/client/backend/types/span_detail.py,sha256=6x0qsMdFRDRvBQuLo7kdHyoR_vqFtxiVYWvKo4FZLYQ,1514
|
|
99
99
|
agenta/client/backend/types/span_kind.py,sha256=3i1C1U-NzDgFpgw8QL0c7CwHHhejCUpSmq5FD1YHiJI,1324
|
|
100
100
|
agenta/client/backend/types/span_status_code.py,sha256=uxcUEsPLQa2r2eIgYw8LRmMj5GQaE98UnL1JgUsdyuM,643
|
|
101
101
|
agenta/client/backend/types/span_variant.py,sha256=BQIrSv4zCNeUSLK5ad3l3BHoc856jXc-v9yd2oTwOkk,1008
|
|
@@ -103,7 +103,7 @@ agenta/client/backend/types/template.py,sha256=mInivp-YnXqt28mWM9y4zqNezOfvUEPcm
|
|
|
103
103
|
agenta/client/backend/types/template_image_info.py,sha256=BycGLw_7XHl9GWOBpu1eu3I_fSQ3n5UVFQdzC0cQ_v8,1189
|
|
104
104
|
agenta/client/backend/types/test_set_output_response.py,sha256=T1HtKP3y2z5UOvqR4_rpUadr7zfGQUxzXAhXBrsBWCg,1088
|
|
105
105
|
agenta/client/backend/types/test_set_simple_response.py,sha256=YI4tRQodB7-5PsIt4RVb8JwJ16vvsFXo7ed_0iHCoOM,1004
|
|
106
|
-
agenta/client/backend/types/trace_detail.py,sha256=
|
|
106
|
+
agenta/client/backend/types/trace_detail.py,sha256=BCx_GZqus6n5Zl2ZsHMFllXpogh2UUH47NpM23SeFxc,1498
|
|
107
107
|
agenta/client/backend/types/uri.py,sha256=dfnTFYdnqiqBzwKItet51L-UMuyd8hkdTw9g4aGrOjM,953
|
|
108
108
|
agenta/client/backend/types/validation_error.py,sha256=KiHcCQ9smOvyaCnwh9EqD-EfiR24wrczv6p-VDS9p5I,1086
|
|
109
109
|
agenta/client/backend/types/validation_error_loc_item.py,sha256=LAtjCHIllWRBFXvAZ5QZpp7CPXjdtN9EB7HrLVo6EP0,128
|
|
@@ -131,8 +131,8 @@ agenta/sdk/agenta_init.py,sha256=8MfDuypxohd0qRTdtGjX7L17KW-1UGmzNVdiqF15_ak,979
|
|
|
131
131
|
agenta/sdk/client.py,sha256=trKyBOYFZRk0v5Eptxvh87yPf50Y9CqY6Qgv4Fy-VH4,2142
|
|
132
132
|
agenta/sdk/context.py,sha256=q-PxL05-I84puunUAs9LGsffEXcYhDxhQxjuOz2vK90,901
|
|
133
133
|
agenta/sdk/decorators/base.py,sha256=9aNdX5h8a2mFweuhdO-BQPwXGKY9ONPIdLRhSGAGMfY,217
|
|
134
|
-
agenta/sdk/decorators/llm_entrypoint.py,sha256=
|
|
135
|
-
agenta/sdk/decorators/tracing.py,sha256=
|
|
134
|
+
agenta/sdk/decorators/llm_entrypoint.py,sha256=oZ_CWrysQ9KzT1oSh7ENpZ0TC_jRZWQ7Of3shqb_R6Q,28167
|
|
135
|
+
agenta/sdk/decorators/tracing.py,sha256=cMclr5uVN7isTW7MpF9E572B27mo6JUpUbVv-QO0nas,3749
|
|
136
136
|
agenta/sdk/router.py,sha256=0sbajvn5C7t18anH6yNo7-oYxldHnYfwcbmQnIXBePw,269
|
|
137
137
|
agenta/sdk/tracing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
138
138
|
agenta/sdk/tracing/callbacks.py,sha256=xWP3RRtmj3ogXeqYI6zdj6gF5QGu70UlQ17WNwdXIx8,8063
|
|
@@ -161,7 +161,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
|
|
|
161
161
|
agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
|
|
162
162
|
agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
|
|
163
163
|
agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
|
|
164
|
-
agenta-0.20.
|
|
165
|
-
agenta-0.20.
|
|
166
|
-
agenta-0.20.
|
|
167
|
-
agenta-0.20.
|
|
164
|
+
agenta-0.20.0a4.dist-info/METADATA,sha256=ZPKFul4FOqz3eLRdLr1H8UtQoKnlj6QOngWuxcYmGC0,26462
|
|
165
|
+
agenta-0.20.0a4.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
166
|
+
agenta-0.20.0a4.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
|
|
167
|
+
agenta-0.20.0a4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|