Simple Large Language Inference Model
sllim serves as a quality of life wrapper around the openai-python library.
I found myself writing and rewriting the same helper functions with each new project I began, so now I am working to put these functions together into a easy to use library.
Nothing here is ground-breaking; everything here is opinionated.
Usage
Use the chat function to connect with the ChatCompletion.create models. By default, it uses the gpt-3.5-turbo model, but you can pass a model param to use gpt-4
from sllim import chat
chat(
[
{
"role": "system",
"content": "Example system message",
},
{
"role": "user",
"content": "Example user message",
}
]
)
complete works just like Completion.create, and embed is Embedding.create.
Map Reduce
from sllim import map_reduce
template = [
{
"role": "system",
"content": "You are an excellent copy writer and you will rewrite my work into {adjective} words."
},
{
"role": "user",
"content": "Below is my writing, please improve it.\n\n{writing}"
},
]
writings = [...] # long list of copywriting
for adjective in ["clearer", "more expressive", "fewer"]:
# Since `writings` is a list, this is what we will reduce over.
# The other variables are treated as constants through the reduction.
gen = map_reduce(template, adjective=adjective, writing=writings, model="gpt-4")
for idx, result in enumerate(gen):
# This is a multithreaded generator to optimize latency to networked services
original = writings[idx]
print("Was:", original, "\nNow:", result)
Benefits
-
Local file caching. Each of the functions is locally cached in request-response key-pairs to prevent excessive network activity.
-
Auto-retry. Timeouts for rate limits, retry for internal errors (>=500 status code).
-
Parameter names are in the functions so that you don't have to go looking at the docs constantly.
-
Map reduce prompts onto data
-
TODO: Cost estimates before running long tasks
-
TODO: Describe task -> run task
-
TODO: Allow easy estimate
-
TODO: Allow easy logging
Metadata
Release files for sllim 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sllim-0.2.2.tar.gz | 8.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sllim-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / sllim-0.2.2.tar.gz
| Download URL | sllim-0.2.2.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8244b8924273c9029339c84f25d56dbda72d9ec614128a88f5a61e9169d915b
|
|
BLAKE2b-256 checksum How to use checksums |
d840a395d65f120eb36141abef811b3dbe9abcee39583f3ece04496e3e39338a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.8.6 Darwin/22.6.0
|
Release files / sllim-0.2.2-py3-none-any.whl
| Download URL | sllim-0.2.2-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
084385423e49bac967a20b08268e5cd29d02a1818f51044680f5a62e8f884d98
|
|
BLAKE2b-256 checksum How to use checksums |
53a9bf67e560a58c3d7bbeef17948a6a6c7f013fbe0741aa8c1e9572b0a8df3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.8.6 Darwin/22.6.0
|
Security for sllim 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.