Closed AI
⚠️ This project is in early development is a work in progress. ⚠️
closedai is a drop-in replacement for openai, but only with open models.
Installation
For now, install locally, as this project is a WIP and PyPi may be out of date.
git clone https://github.com/nateraw/closedai.git
cd closedai
pip install -e .
Usage
The idea is that you will run your own OpenAI-like server with whatever model you want. Once the server is running, you can hit it with openai python library (or any other SDK of your choosing) by overriding the api base endpoint with the URL to your running server.
Server
In your terminal, run:
closedai
You can see the available configuration flags with closedai --help.
Docker
docker build -t closedai .
docker run -p 7860:7860
Client
If using localhost, you can from closedai import openai. If running remotely, for now you can just import openai and override openai.api_base with your endpoint and openai.api_key with a dummy value.
Then, use it as you normally would...
Completions
from closedai import openai
completion = openai.Completion.create(model='asdf', prompt='hi there, my name is', stream=False)
print(completion)
Completions streaming
from closedai import openai
completion = openai.Completion.create(model='asdf', prompt='hi there, my name is', stream=True)
for new_text in completion:
print(new_text)
Chat Completions
from closedai import openai
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"},
],
stream=False,
)
print(completion)
Chat Completions streaming
from closedai import openai
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Who won the world series in 2020?"},
{"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{"role": "user", "content": "Where was it played?"},
],
stream=True,
)
for x in completion:
print(x)
Metadata
Release files for closedai 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 | Provenance | Actions |
|---|---|---|---|---|
| closedai-0.0.3.tar.gz | 12.0 kB | Without provenance | Details for closedai-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| closedai-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for closedai-0.0.3-py3-none-any.whl |
Total release size: 25.1 kB
Release files / closedai-0.0.3.tar.gz
| Download URL | closedai-0.0.3.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73da3da114d8e7be92897c800b6e187d57e56e034356e0e3af84dfea5d654c23
|
|
BLAKE2b-256 checksum How to use checksums |
76e903fb07d23fdf544739df98c3717fcabe4a0bf38efaec6cbea8524c7d6bae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Release files / closedai-0.0.3-py3-none-any.whl
| Download URL | closedai-0.0.3-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25cbc9c66a9853406af6746992f100e86e9e39c1822591e54af1f4e407eb173a
|
|
BLAKE2b-256 checksum How to use checksums |
150bb4a93d3c7f923085b2ec321ab8d436326d813819c9f71ea7e3e1cc80df46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.2
|
Security for closedai 0.0.3
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.