Skip to content

Commit 45d423b

Browse files
committed
Support for Plexe endpoints
1 parent 8f0207a commit 45d423b

6 files changed

Lines changed: 332 additions & 164 deletions

File tree

‎README.md‎

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,72 @@
1-
# Plexe
1+
# PlexeAI
22

3-
Create ML models from natural language descriptions.
3+
Create ML models from natural language descriptions. Upload your data and describe your ML problem - PlexeAI handles the rest.
44

5-
## Installation
5+
## Install
66

77
```bash
8-
pip install plexe
8+
pip install plexeai
99
```
1010

1111
## Usage
1212

13-
First, set your API key:
14-
```bash
15-
export PLEXE_API_KEY=your_api_key_here
16-
```
17-
18-
Then use it in your code:
19-
2013
```python
21-
import plexe
14+
import plexeai
2215

23-
# Create a model
24-
model_id, version, desc = plexe.create(
25-
"Create a model that predicts sentiment from text"
16+
# Set via environment or pass to functions
17+
# export PLEXE_API_KEY=your_api_key_here
18+
19+
# Build a model
20+
experiment_id = plexeai.build(
21+
goal="predict customer churn based on usage patterns",
22+
data_files="customer_data.csv", # Single file or list of files
23+
steps=3 # Number of improvement iterations
2624
)
2725

26+
# Check build status
27+
status = plexeai.get_status(experiment_id)
28+
# {"status": "completed", "result": {...}}
29+
2830
# Make predictions
29-
result = plexe.run(
30-
model_id=model_id,
31-
text_input="This product is amazing!"
31+
result = plexeai.infer(
32+
experiment_id=experiment_id,
33+
input_data={
34+
"usage": 100,
35+
"tenure": 12,
36+
"plan_type": "premium"
37+
}
3238
)
33-
print(result)
3439

3540
# Batch predictions
36-
results = plexe.batch_run(
37-
model_id=model_id,
41+
results = plexeai.batch_infer(
42+
experiment_id=experiment_id,
3843
inputs=[
39-
{"text": "This is great"},
40-
{"text": "This is terrible"}
44+
{"usage": 100, "tenure": 12, "plan_type": "premium"},
45+
{"usage": 50, "tenure": 6, "plan_type": "basic"}
4146
]
4247
)
4348

4449
# Async support
4550
async def main():
46-
model_id, version, desc = await plexe.acreate(
47-
"Create a classifier for text"
51+
experiment_id = await plexeai.abuild(
52+
goal="predict customer churn",
53+
data_files="customer_data.csv"
54+
)
55+
result = await plexeai.ainfer(
56+
experiment_id=experiment_id,
57+
input_data={"usage": 100, "tenure": 12}
4858
)
49-
result = await plexe.arun(model_id, text_input="Test")
5059
```
60+
61+
## Local Development
62+
63+
```bash
64+
git clone https://github.com/plexe-ai/plexe
65+
cd plexe
66+
pip install -e ".[dev]"
67+
pytest
68+
```
69+
70+
## License
71+
72+
MIT License

‎plexe/__init__.py‎

Lines changed: 58 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,65 @@
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

Comments
 (0)