LastMile AI Python Library
This library provides access to the LastMile AI API from Python. The code should reflect the same API endpoints documented here: https://lastmileai.dev/docs/api
API Token
This library requires a LastMile AI API Token, which can be obtained from https://lastmileai.dev/settings?page=tokens.
Important note: this library should only be used from a server-side context, where the API key can be securely accessed. Using this library from client-side browser code will expose your private API key!
Installation
pip install lastmileai
Usage
Initialize Library with API Key
This library needs to be configured with your API Token (aka API key) obtained above. You can store the API key in an environment variable or alternative secure storage that can be accessed in your server-side code. For example, to initialize the library with the API key loaded from environment variable:
import os
from lastmileai import LastMile
lastmile = LastMile(api_key=os.environ["LASTMILEAI_API_KEY"])
Completions -- Open AI Models
OpenAI completions are supported out-of the box for ChatGPT and GPT3 models:
completion = lastmile.create_openai_completion(
completion_params = {
model: "text-davinci-003",
prompt: "Your prompt here",
}
)
completion = lastmile.create_openai_chat_completion(
completion_params = {
model: "gpt-3.5-turbo",
messages: [
{ role: "user", content: "Your prompt here" },
],
}
)
Completions -- Custom Models
completion = lastmile.create_openai_completion(
completion_params = {
model: "text-davinci-003",
prompt: "Your prompt here",
},
embedding_collection_id = "clfpqyvpp004npmzgp1d4j4fw"
)
Run tests
After setting LASTMILEAI_API_KEY in your shell environment, run the following:
pip3 install -e .
python3 -m unittest discover test
Metadata
Release files for lastmileai 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| lastmileai-0.0.3.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| lastmileai-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / lastmileai-0.0.3.tar.gz
| Download URL | lastmileai-0.0.3.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c28b2d71c9dd7ed00637e3d9ca8c3b9e92dd0c19ae0a0b30dd9dc74f67ae3e51
|
|
BLAKE2b-256 checksum How to use checksums |
e4a6bf52899987017ec07f0d5ab9abf61c4c91f6a75706f1beb10159f9f67d38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.9
|
Release files / lastmileai-0.0.3-py3-none-any.whl
| Download URL | lastmileai-0.0.3-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
08f0a1f24645f284927585556f7dd5b522d5c39b80f747fb9173b1fccc3eb806
|
|
BLAKE2b-256 checksum How to use checksums |
f4a5e1f50e28dc7eaf7ae6f146c0f85241dcb1a4d3b12266ba6ca0f7d1ecdd35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.11.9
|