agenta 0.20.0a1__py3-none-any.whl → 0.20.0a3__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 +11 -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/agenta_init.py +6 -0
- agenta/sdk/decorators/llm_entrypoint.py +36 -7
- agenta/sdk/decorators/tracing.py +32 -2
- {agenta-0.20.0a1.dist-info → agenta-0.20.0a3.dist-info}/METADATA +1 -1
- {agenta-0.20.0a1.dist-info → agenta-0.20.0a3.dist-info}/RECORD +11 -11
- {agenta-0.20.0a1.dist-info → agenta-0.20.0a3.dist-info}/WHEEL +0 -0
- {agenta-0.20.0a1.dist-info → agenta-0.20.0a3.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:
|
|
@@ -769,6 +772,14 @@ class AsyncObservabilityClient:
|
|
|
769
772
|
],
|
|
770
773
|
)
|
|
771
774
|
"""
|
|
775
|
+
|
|
776
|
+
logging.debug("----")
|
|
777
|
+
logging.debug(
|
|
778
|
+
urllib.parse.urljoin(
|
|
779
|
+
f"{self._client_wrapper.get_base_url()}/", "observability/trace/"
|
|
780
|
+
),
|
|
781
|
+
)
|
|
782
|
+
logging.debug(self._client_wrapper.get_headers())
|
|
772
783
|
_response = await self._client_wrapper.httpx_client.request(
|
|
773
784
|
"POST",
|
|
774
785
|
urllib.parse.urljoin(
|
|
@@ -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]
|
agenta/sdk/agenta_init.py
CHANGED
|
@@ -68,6 +68,12 @@ class AgentaSingleton:
|
|
|
68
68
|
api_key or config.get("api_key") or os.environ.get("AGENTA_API_KEY")
|
|
69
69
|
)
|
|
70
70
|
|
|
71
|
+
print(api_key)
|
|
72
|
+
print(config.get("api_key"))
|
|
73
|
+
print(os.environ.get("AGENTA_API_KEY"))
|
|
74
|
+
print(self.api_key)
|
|
75
|
+
print(os.environ)
|
|
76
|
+
|
|
71
77
|
if not self.app_id:
|
|
72
78
|
raise ValueError(
|
|
73
79
|
"App ID must be specified. You can provide it in one of the following ways:\n"
|
|
@@ -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
|
|
@@ -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
|
)
|
|
@@ -537,7 +565,7 @@ class entrypoint(BaseDecorator):
|
|
|
537
565
|
print("-> data")
|
|
538
566
|
print(json.dumps(result.data, indent=2))
|
|
539
567
|
print("-> trace")
|
|
540
|
-
print(json.dumps(result.trace, indent=2))
|
|
568
|
+
# print(json.dumps(result.trace, indent=2))
|
|
541
569
|
|
|
542
570
|
def override_schema(
|
|
543
571
|
self, openapi_schema: dict, func: str, endpoint: str, params: dict
|
|
@@ -611,6 +639,7 @@ class entrypoint(BaseDecorator):
|
|
|
611
639
|
schema_to_override = openapi_schema["components"]["schemas"][
|
|
612
640
|
f"Body_{func}_{endpoint}_post"
|
|
613
641
|
]["properties"]
|
|
642
|
+
|
|
614
643
|
for param_name, param_val in params.items():
|
|
615
644
|
if isinstance(param_val, GroupedMultipleChoiceParam):
|
|
616
645
|
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 = "default"
|
|
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 = "default"
|
|
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=4kTC18reOl0SBdHP7iVLunVPyqOsXq2FFWZYLe5mbU0,43239
|
|
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
|
|
@@ -127,12 +127,12 @@ agenta/docker/docker-assets/lambda_function.py,sha256=h4UZSSfqwpfsCgERv6frqwm_4J
|
|
|
127
127
|
agenta/docker/docker-assets/main.py,sha256=7MI-21n81U7N7A0GxebNi0cmGWtJKcR2sPB6FcH2QfA,251
|
|
128
128
|
agenta/docker/docker_utils.py,sha256=5uHMCzXkCvIsDdEiwbnnn97KkzsFbBvyMwogCsv_Z5U,3509
|
|
129
129
|
agenta/sdk/__init__.py,sha256=ewYNjm6AHlqkIrPfX2D_pXZMwShOdhEUcWXb7xGA2bk,769
|
|
130
|
-
agenta/sdk/agenta_init.py,sha256=
|
|
130
|
+
agenta/sdk/agenta_init.py,sha256=WXsT266BLSr7LeNoYPEmDLNj8qoxPsggge-dto7f_9w,9953
|
|
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=-oVl2sBH8tIjFD_6q6l0LmEPrPlfRT9Iy8KqEYxJvwk,28099
|
|
135
|
+
agenta/sdk/decorators/tracing.py,sha256=jjHD6VY5YSSHLfC3C2Xl7-6psBq8ycczMB0kj1rYwl4,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.0a3.dist-info/METADATA,sha256=ejs-P0QRRYTn33Pukab6fxUj8olSqlXVYy0kdsBsTRk,26462
|
|
165
|
+
agenta-0.20.0a3.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
166
|
+
agenta-0.20.0a3.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
|
|
167
|
+
agenta-0.20.0a3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|