Impulse SDK for Python
The Impulse SDK for Python provides a convenient way to interact with the Impulse API for managing large language model (LLM) fine-tuning processes and related resources.
Features
- User management
- API key management
- Dataset operations
- Fine-tuning job management
- Model information retrieval
- Usage tracking
Installation
You can install the Impulse SDK using pip:
pip install impulse-api-sdk-python
Setting up API Key
Generate an API key by visiting the Impulse Dashboard at this settings page.
Setting environment variable
export IMPSDK_API_KEY=xxxxx
Usage – Python Client
User Management
import os
import asyncio
from impulse.api_sdk.sdk import ImpulseSDK
async def main():
async with ImpulseSDK(os.environ.get("IMPSDK_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.
import asyncio
import os
from impulse.api_sdk.sdk import ImpulseSDK
async def main():
async with ImpulseSDK(os.environ.get("IMPSDK_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 Impulse supports.
import os
import asyncio
from impulse.api_sdk.sdk import ImpulseSDK
async def main():
async with ImpulseSDK(os.environ.get("IMPSDK_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.
import os
import asyncio
from impulse.api_sdk.sdk import ImpulseSDK
from impulse.api_sdk.models import FineTuningJobCreate, FineTuningJobParameters
async def main():
async with ImpulseSDK(os.environ.get("IMPSDK_API_KEY")) as client:
files = await client.dataset.list_datasets()
job = await client.fine_tuning.create_fine_tuning_job(FineTuningJobCreate(
base_model_name="llm_llama3_1_8b",
dataset_name=files[0].name,
name="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
import os
import asyncio
from impulse.api_sdk.sdk import ImpulseSDK
from datetime import timedelta, date
async def main():
async with ImpulseSDK(os.environ.get("IMPSDK_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
If you encounter any problems or have any questions, please open an issue on the GitHub repository.
Metadata
Release files for impulse-api-sdk-python 0.11.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| impulse_api_sdk_python-0.11.1.tar.gz | 18.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| impulse_api_sdk_python-0.11.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.0 kB
Release files / impulse_api_sdk_python-0.11.1.tar.gz
| Download URL | impulse_api_sdk_python-0.11.1.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
695b344905101a9b7a39aca1a19d02036eae744da67796d8e85ad3eaa9345f1d
|
|
BLAKE2b-256 checksum How to use checksums |
225967443752c5f12410b1ab2ad14eac5fdcbf5477dd2e1b45dd8ab6ab477532
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|
Release files / impulse_api_sdk_python-0.11.1-py3-none-any.whl
| Download URL | impulse_api_sdk_python-0.11.1-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ff8161e9a13b35d4d1e3b948dd45bcc3fec8c9b0001fb84d749c72a341181fc
|
|
BLAKE2b-256 checksum How to use checksums |
9b7277b4775960a3fe122b8eb7460cbc08b424ab8428f27d4e5773a2bf7b7334
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.11
|