Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __pycache__/
*.py[cod]
*.egg-info/
dist/
build/

# Environment variables file
.env
Expand Down
120 changes: 116 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Lumino SDK for Python

[![Static Badge](https://img.shields.io/badge/pypi-0.0.3-blue)](https://pypi.org/project/lumino/)
[![](https://dcbadge.limes.pink/api/server/https://discord.gg/62DThqunWx?style=flat&compact=true)](https://discord.gg/https://discord.gg/62DThqunWx)
[![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/luminoai)](https://x.com/luminoai)

The Lumino SDK for Python provides a convenient way to interact with the Lumino API for managing large language model (LLM) fine-tuning processes and related resources.

## Features
Expand All @@ -19,21 +23,129 @@ You can install the Lumino SDK using pip:
pip install lumino
```

## Quick Start
## Setting up API Key

Generate an API key by visiting the Lumino Dashboard at this [settings page](https://app.luminolabs.ai/settings).

## Setting environment variable

```
export LUMINO_API_KEY=xxxxx
```

## Usage – Python Client

Here's a simple example of how to use the Lumino SDK. More examples under `tests/e2e_test.py`.
### User Management

```python
import os
import asyncio
from lumino.sdk import LuminoSDK


async def main():
async with LuminoSDK("your-api-key", "http://localhost:5100/v1") as sdk:
user = await sdk.user.get_current_user()
async with LuminoSDK(os.environ.get("LUMINO_API_KEY")) as client:
user = await client.user.get_current_user()
print(user)

asyncio.run(main())
```

### Datasets
The files API is used for fine-tuning and allows developers to upload data to fine-tune on. It also has several methods to list all files, retrive files, and delete files. Please refer to our fine-tuning docs here.

```python
import os
import asyncio
from lumino.sdk import LuminoSDK


async def main():
async with LuminoSDK(os.environ.get("LUMINO_API_KEY")) as client:
files = await client.dataset.list_datasets()
await client.dataset.upload_dataset("somefile.jsonl")
await client.dataset.get_dataset("somefile.jsonl")
await client.dataset.delete("somefile.jsonl")

print(files)

asyncio.run(main())
```

### Models
This lists all the models that Lumino supports.

```python
import os
import asyncio
from lumino.sdk import LuminoSDK


async def main():
async with LuminoSDK(os.environ.get("LUMINO_API_KEY")) as client:
models = await client.model.list_base_models()
print(models)

asyncio.run(main())
```


### Fine-tunes
The finetune API is used for fine-tuning and allows developers to create finetuning jobs. It also has several methods to list all jobs, retrive statuses and get checkpoints. Please refer to our fine-tuning docs here.

```python
import os
import asyncio
from lumino.sdk import LuminoSDK


async def main():
async with LuminoSDK(os.environ.get("LUMINO_API_KEY")) as client:
files = await client.dataset.list_datasets()
job = await sdk.fine_tuning.create_fine_tuning_job(FineTuningJobCreate(
base_model_name="llm_llama3_1_8b",
dataset_name=files[0].name,
name=add_suffix("test-fine-tuning-job"),
parameters=FineTuningJobParameters(
batch_size=2,
shuffle=True,
num_epochs=1,
use_lora=True,
use_qlora=False
)
))

print(job)

jobs = await client.fine_tuning.list_fine_tuning_jobs()
print(jobs)

job_details = await client.fine_tuning.get_fine_tuning_job(job.name)
print(job_details)

asyncio.run(main())
```

### Usage Tracking

```python
import os
import asyncio
from lumino.sdk import LuminoSDK
from datetime import timedelta, date

async def main():
async with LuminoSDK(os.environ.get("LUMINO_API_KEY")) as client:
end_date = date.today()
start_date = end_date - timedelta(days=30)
total_cost = await client.usage.get_total_cost(start_date, end_date)
print(total_cost)

usage_records = await client.usage.list_usage_records(start_date, end_date)
print(usage_records)

asyncio.run(main())
```

## Support

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
0.0.3
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
version=version,
author="Lumino Labs AI",
author_email="engg@luminolabs.ai",
license="Apache License 2.0",
description="A Python SDK for interacting with the Lumino Labs API",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down