1- from .client import PlexeClient
1+ from pathlib import Path
2+ from typing import Optional , Union , List
3+ from .client import PlexeAI
24
3- def create (task_description : str , api_key : str = "" ) -> tuple [str , int , str ]:
4- """Create a new ML model."""
5- client = PlexeClient (api_key = api_key )
6- return client .create (task_description = task_description )
5+ def build (goal : str ,
6+ data_files : Optional [Union [str , Path , List [Union [str , Path ]]]] = None ,
7+ data_dir : Optional [str ] = None ,
8+ api_key : str = "" ,
9+ steps : int = 5 ,
10+ eval_criteria : Optional [str ] = None ) -> str :
11+ """Build a new ML model.
12+
13+ Args:
14+ goal: Description of what the model should do
15+ data_files: Optional path(s) to data file(s) to upload
16+ data_dir: Optional data directory (if files already uploaded)
17+ api_key: API key for authentication
18+ steps: Number of improvement iterations
19+ eval_criteria: Optional evaluation criteria
20+
21+ Returns:
22+ experiment_id: ID of the created experiment
23+ """
24+ client = PlexeAI (api_key = api_key )
25+ return client .build (goal = goal , data_files = data_files , data_dir = data_dir ,
26+ steps = steps , eval_criteria = eval_criteria )
727
8- async def acreate (task_description : str , api_key : str = "" ) -> tuple [str , int , str ]:
9- """Create a new ML model asynchronously."""
10- client = PlexeClient (api_key = api_key )
11- return await client .acreate (task_description = task_description )
28+ async def abuild (goal : str ,
29+ data_files : Optional [Union [str , Path , List [Union [str , Path ]]]] = None ,
30+ data_dir : Optional [str ] = None ,
31+ api_key : str = "" ,
32+ steps : int = 5 ,
33+ eval_criteria : Optional [str ] = None ) -> str :
34+ """Build a new ML model asynchronously."""
35+ client = PlexeAI (api_key = api_key )
36+ return await client .abuild (goal = goal , data_files = data_files , data_dir = data_dir ,
37+ steps = steps , eval_criteria = eval_criteria )
1238
13- def run ( model_id : str , text_input : str = "" , version : int = - 1 , api_key : str = "" ) -> dict :
14- """Run predictions using a model."""
15- client = PlexeClient (api_key = api_key )
16- return client .run ( model_id = model_id , text_input = text_input , version = version )
39+ def infer ( experiment_id : str , input_data : dict , api_key : str = "" ) -> dict :
40+ """Run inference using a built model."""
41+ client = PlexeAI (api_key = api_key )
42+ return client .infer ( experiment_id = experiment_id , input_data = input_data )
1743
18- async def arun ( model_id : str , text_input : str = "" , version : int = - 1 , api_key : str = "" ) -> dict :
19- """Run predictions using a model asynchronously."""
20- client = PlexeClient (api_key = api_key )
21- return await client .arun ( model_id = model_id , text_input = text_input , version = version )
44+ async def ainfer ( experiment_id : str , input_data : dict , api_key : str = "" ) -> dict :
45+ """Run inference using a model asynchronously."""
46+ client = PlexeAI (api_key = api_key )
47+ return await client .ainfer ( experiment_id = experiment_id , input_data = input_data )
2248
23- def batch_run ( model_id : str , inputs : list , version : int = - 1 , api_key : str = "" ) -> list :
49+ def batch_infer ( experiment_id : str , inputs : List [ dict ], api_key : str = "" ) -> List [ dict ] :
2450 """Run batch predictions."""
25- client = PlexeClient (api_key = api_key )
26- return client .batch_run ( model_id = model_id , inputs = inputs , version = version )
51+ client = PlexeAI (api_key = api_key )
52+ return client .batch_infer ( experiment_id = experiment_id , inputs = inputs )
2753
28- __all__ = ['PlexeClient' , 'create' , 'acreate' , 'run' , 'arun' , 'batch_run' ]
54+ def get_status (experiment_id : str , api_key : str = "" ) -> dict :
55+ """Get status of an experiment build."""
56+ client = PlexeAI (api_key = api_key )
57+ return client .get_status (experiment_id = experiment_id )
58+
59+ async def aget_status (experiment_id : str , api_key : str = "" ) -> dict :
60+ """Get status of an experiment build asynchronously."""
61+ client = PlexeAI (api_key = api_key )
62+ return await client .aget_status (experiment_id = experiment_id )
63+
64+ __all__ = ['PlexeAI' , 'build' , 'abuild' , 'infer' , 'ainfer' ,
65+ 'batch_infer' , 'get_status' , 'aget_status' ]
0 commit comments