A reverse engineered API wrapper for OpenPlayground (nat.dev)
Project description
Python OpenPlayground API
This is an unoffical API wrapper for the website OpenPlayground, which provides access to a wide array of AI models for free.
Features:
This library has the following abilities:
- List models
- Generate text
Installation:
You can install this library by running the following command:
pip3 install openplayground-api
Documentation:
An example of how to use this library can be found in /examples/example.py
.
The Model
Class:
The openplayground.Model
class describes a model that is available to the user. Valid attributes are:
provider
- The company that developed the model (e.g., openai, anthropic)name
- The name of the model, such astext-davinci-003
.version
- The version of the model. This may returnNone
on some models.tag
- A string that combines the provider and name in this format:<provider>:<name>
. Example:openai:text-davinci-003
params
- A dictionary containing possible parameters for the model.
Logging In With an Email:
The openplayground.Auth
class can be used to get your token using an OTP code emailed to you.
The openplayground.Auth.login_part_1
function sends an email containing the OTP code to the specificed email address. Once you have the OTP code, you can use the openplayground.Auth.login_part_2
function to get your token from that OPT code.
Initializing the Client:
The openplayground.Client
class accepts one argument, which is your account's token. Your token can be obtained from the __session
field in your browser's cookies, or using the openplayground.Auth
class as show above.
Downloading the Available Models:
The openplayground.Client.get_models
function fetches the available models from https://nat.dev/api/all_models
, and returns a dictionary of openplayground.Model
objects.
Generating Text:
The openplayground.Client.generate
function generates some text given a model and a prompt. Optionally, you can also specify arguments such as the maximum length in the kwargs. You can find a list of valid arguments and their defaults in openplayground.Model.params
. A few common ones are:
maximum_length
temperature
top_k
top_p
The values returned from this function are streamed and expressed in a dictionary.
Copyright:
This project is licensed under the GNU GPL v3. Most of the code has been written by me, ading2210. A list of all the contributors can be found here.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for openplayground_api-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca6aadb728253223232d83bc2045b6bc5f2cd51bcccfe94715a593a4c65b34dd |
|
MD5 | 9891eb22a4389483ff7c472f269d29e1 |
|
BLAKE2b-256 | 5b81728bd809d5d9bf95e43c66cd924d01ccd040f194d48b1201e1fc0753d741 |