agenta 0.29.0__py3-none-any.whl → 0.30.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.
- agenta/sdk/decorators/routing.py +31 -102
- {agenta-0.29.0.dist-info → agenta-0.30.0a1.dist-info}/METADATA +2 -3
- {agenta-0.29.0.dist-info → agenta-0.30.0a1.dist-info}/RECORD +5 -5
- {agenta-0.29.0.dist-info → agenta-0.30.0a1.dist-info}/WHEEL +1 -1
- {agenta-0.29.0.dist-info → agenta-0.30.0a1.dist-info}/entry_points.txt +0 -0
agenta/sdk/decorators/routing.py
CHANGED
|
@@ -74,10 +74,13 @@ class route:
|
|
|
74
74
|
self.route_path = path
|
|
75
75
|
|
|
76
76
|
def __call__(self, f):
|
|
77
|
+
# If not running in Agenta, return the original function unchanged
|
|
78
|
+
if environ.get("AGENTA_RUNTIME") != "true":
|
|
79
|
+
return f
|
|
80
|
+
|
|
77
81
|
self.e = entrypoint(
|
|
78
82
|
f, route_path=self.route_path, config_schema=self.config_schema
|
|
79
83
|
)
|
|
80
|
-
|
|
81
84
|
return f
|
|
82
85
|
|
|
83
86
|
|
|
@@ -120,6 +123,23 @@ class entrypoint:
|
|
|
120
123
|
route_path="",
|
|
121
124
|
config_schema: Optional[BaseModel] = None,
|
|
122
125
|
):
|
|
126
|
+
self.func = func
|
|
127
|
+
self.route_path = route_path
|
|
128
|
+
self.config_schema = config_schema
|
|
129
|
+
|
|
130
|
+
def __call__(self, func=None):
|
|
131
|
+
if func is None:
|
|
132
|
+
func = self.func
|
|
133
|
+
route_path = self.route_path
|
|
134
|
+
config_schema = self.config_schema
|
|
135
|
+
else:
|
|
136
|
+
route_path = ""
|
|
137
|
+
config_schema = None
|
|
138
|
+
|
|
139
|
+
# If not running in Agenta, return the original function unchanged
|
|
140
|
+
if environ.get("AGENTA_RUNTIME") != "true":
|
|
141
|
+
return func
|
|
142
|
+
|
|
123
143
|
### --- Update Middleware --- #
|
|
124
144
|
try:
|
|
125
145
|
global _MIDDLEWARES # pylint: disable=global-statement
|
|
@@ -172,6 +192,11 @@ class entrypoint:
|
|
|
172
192
|
### --- Playground --- #
|
|
173
193
|
@wraps(func)
|
|
174
194
|
async def wrapper(*args, **kwargs) -> Any:
|
|
195
|
+
if environ.get("AGENTA_RUNTIME") != "true":
|
|
196
|
+
raise HTTPException(
|
|
197
|
+
status_code=403,
|
|
198
|
+
detail="This endpoint is only available when running in Agenta environment",
|
|
199
|
+
)
|
|
175
200
|
func_params, api_config_params = self.split_kwargs(kwargs, config_params)
|
|
176
201
|
self.ingest_files(func_params, ingestible_files)
|
|
177
202
|
if not config_schema:
|
|
@@ -234,6 +259,11 @@ class entrypoint:
|
|
|
234
259
|
### --- Deployed --- #
|
|
235
260
|
@wraps(func)
|
|
236
261
|
async def wrapper_deployed(*args, **kwargs) -> Any:
|
|
262
|
+
if environ.get("AGENTA_RUNTIME") != "true":
|
|
263
|
+
raise HTTPException(
|
|
264
|
+
status_code=403,
|
|
265
|
+
detail="This endpoint is only available when running in Agenta environment",
|
|
266
|
+
)
|
|
237
267
|
func_params = {
|
|
238
268
|
k: v
|
|
239
269
|
for k, v in kwargs.items()
|
|
@@ -306,14 +336,6 @@ class entrypoint:
|
|
|
306
336
|
config=route["config"],
|
|
307
337
|
)
|
|
308
338
|
|
|
309
|
-
if self.is_main_script(func) and route_path == "":
|
|
310
|
-
self.handle_terminal_run(
|
|
311
|
-
func,
|
|
312
|
-
func_signature.parameters, # type: ignore
|
|
313
|
-
config_params,
|
|
314
|
-
ingestible_files,
|
|
315
|
-
)
|
|
316
|
-
|
|
317
339
|
def extract_ingestible_files(
|
|
318
340
|
self,
|
|
319
341
|
func_signature: Signature,
|
|
@@ -615,99 +637,6 @@ class entrypoint:
|
|
|
615
637
|
"""
|
|
616
638
|
return func.__module__ == "__main__"
|
|
617
639
|
|
|
618
|
-
def handle_terminal_run(
|
|
619
|
-
self,
|
|
620
|
-
func: Callable,
|
|
621
|
-
func_params: Dict[str, Parameter],
|
|
622
|
-
config_params: Dict[str, Any],
|
|
623
|
-
ingestible_files: Dict,
|
|
624
|
-
):
|
|
625
|
-
"""
|
|
626
|
-
Parses command line arguments and sets configuration when script is run from the terminal.
|
|
627
|
-
|
|
628
|
-
Args:
|
|
629
|
-
func_params (dict): A dictionary containing the function parameters and their annotations.
|
|
630
|
-
config_params (dict): A dictionary containing the configuration parameters.
|
|
631
|
-
ingestible_files (dict): A dictionary containing the files that should be ingested.
|
|
632
|
-
"""
|
|
633
|
-
|
|
634
|
-
# For required parameters, we add them as arguments
|
|
635
|
-
parser = ArgumentParser()
|
|
636
|
-
for name, param in func_params.items():
|
|
637
|
-
if name in ingestible_files:
|
|
638
|
-
parser.add_argument(name, type=str)
|
|
639
|
-
else:
|
|
640
|
-
parser.add_argument(name, type=param.annotation)
|
|
641
|
-
|
|
642
|
-
for name, param in config_params.items():
|
|
643
|
-
if type(param) is MultipleChoiceParam:
|
|
644
|
-
parser.add_argument(
|
|
645
|
-
f"--{name}",
|
|
646
|
-
type=str,
|
|
647
|
-
default=param.default,
|
|
648
|
-
choices=param.choices, # type: ignore
|
|
649
|
-
)
|
|
650
|
-
else:
|
|
651
|
-
parser.add_argument(
|
|
652
|
-
f"--{name}",
|
|
653
|
-
type=type(param),
|
|
654
|
-
default=param,
|
|
655
|
-
)
|
|
656
|
-
|
|
657
|
-
args = parser.parse_args()
|
|
658
|
-
|
|
659
|
-
# split the arg list into the arg in the app_param and
|
|
660
|
-
# the args from the sig.parameter
|
|
661
|
-
args_config_params = {k: v for k, v in vars(args).items() if k in config_params}
|
|
662
|
-
args_func_params = {
|
|
663
|
-
k: v for k, v in vars(args).items() if k not in config_params
|
|
664
|
-
}
|
|
665
|
-
for name in ingestible_files:
|
|
666
|
-
args_func_params[name] = InFile(
|
|
667
|
-
file_name=Path(args_func_params[name]).stem,
|
|
668
|
-
file_path=args_func_params[name],
|
|
669
|
-
)
|
|
670
|
-
|
|
671
|
-
# Update args_config_params with default values from config_params if not provided in command line arguments
|
|
672
|
-
args_config_params.update(
|
|
673
|
-
{
|
|
674
|
-
key: value
|
|
675
|
-
for key, value in config_params.items()
|
|
676
|
-
if key not in args_config_params
|
|
677
|
-
}
|
|
678
|
-
)
|
|
679
|
-
|
|
680
|
-
loop = get_event_loop()
|
|
681
|
-
|
|
682
|
-
with routing_context_manager(config=args_config_params):
|
|
683
|
-
result = loop.run_until_complete(
|
|
684
|
-
self.execute_function(
|
|
685
|
-
func,
|
|
686
|
-
True, # inline trace: True
|
|
687
|
-
**{"params": args_func_params, "config_params": args_config_params},
|
|
688
|
-
)
|
|
689
|
-
)
|
|
690
|
-
|
|
691
|
-
if result.trace:
|
|
692
|
-
log.info("\n========= Result =========\n")
|
|
693
|
-
|
|
694
|
-
log.info(f"trace_id: {result.trace['trace_id']}")
|
|
695
|
-
log.info(f"latency: {result.trace.get('latency')}")
|
|
696
|
-
log.info(f"cost: {result.trace.get('cost')}")
|
|
697
|
-
log.info(f"usage: {list(result.trace.get('usage', {}).values())}")
|
|
698
|
-
|
|
699
|
-
log.info(" ")
|
|
700
|
-
log.info("data:")
|
|
701
|
-
log.info(dumps(result.data, indent=2))
|
|
702
|
-
|
|
703
|
-
log.info(" ")
|
|
704
|
-
log.info("trace:")
|
|
705
|
-
log.info("----------------")
|
|
706
|
-
log.info(dumps(result.trace.get("spans", []), indent=2))
|
|
707
|
-
log.info("----------------")
|
|
708
|
-
|
|
709
|
-
log.info("\n==========================\n")
|
|
710
|
-
|
|
711
640
|
def override_config_in_schema(
|
|
712
641
|
self,
|
|
713
642
|
openapi_schema: dict,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: agenta
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.30.0a1
|
|
4
4
|
Summary: The SDK for agenta is an open-source LLMOps platform.
|
|
5
5
|
Home-page: https://agenta.ai
|
|
6
6
|
Keywords: LLMOps,LLM,evaluation,prompt engineering
|
|
@@ -13,8 +13,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.9
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
17
|
Classifier: Topic :: Software Development :: Libraries
|
|
19
18
|
Requires-Dist: cachetools (>=5.3.3,<6.0.0)
|
|
20
19
|
Requires-Dist: click (>=8.1.3,<9.0.0)
|
|
@@ -181,7 +181,7 @@ agenta/sdk/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
|
181
181
|
agenta/sdk/context/routing.py,sha256=ycUgmJZyWhL4bHjKtUSAsTlt_0Fujr_6OpoaEH1lAN0,683
|
|
182
182
|
agenta/sdk/context/tracing.py,sha256=UmmW15UFFsvxS0myS6aD9wBk5iNepNlQi4tEQ_ejfYM,96
|
|
183
183
|
agenta/sdk/decorators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
184
|
-
agenta/sdk/decorators/routing.py,sha256=
|
|
184
|
+
agenta/sdk/decorators/routing.py,sha256=wtBLzk075DlMsVfsAEDg-LU1lkqgqAm1Fc6bFBg7jXM,34190
|
|
185
185
|
agenta/sdk/decorators/tracing.py,sha256=vL5e6TVX6TQwO0t9raZwnzXHV3vElVT0pHS1vD-vzEo,8523
|
|
186
186
|
agenta/sdk/litellm/__init__.py,sha256=Bpz1gfHQc0MN1yolWcjifLWznv6GjHggvRGQSpxpihM,37
|
|
187
187
|
agenta/sdk/litellm/litellm.py,sha256=Ke0It-jA1z0KQ2770gIlWIEgramZGmt1k0GjmpEnFV4,8793
|
|
@@ -227,7 +227,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
|
|
|
227
227
|
agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
|
|
228
228
|
agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
|
|
229
229
|
agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
|
|
230
|
-
agenta-0.
|
|
231
|
-
agenta-0.
|
|
232
|
-
agenta-0.
|
|
233
|
-
agenta-0.
|
|
230
|
+
agenta-0.30.0a1.dist-info/METADATA,sha256=155SCLF7rcKPbx6G51p_Lm1pk3xj6OlHbTRN_U0Q6FU,28992
|
|
231
|
+
agenta-0.30.0a1.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
|
232
|
+
agenta-0.30.0a1.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
|
|
233
|
+
agenta-0.30.0a1.dist-info/RECORD,,
|
|
File without changes
|