A reverse engineered API wrapper for OpenPlayground (nat.dev)
Project description
Python OpenPlayground API
This is an unoffical API wrapper for the website OpenPlayground.
Features:
This library has the following abilities:
- List models
- Generate text
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.
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.
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. All code has been written by me, ading2210.
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.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2aa5646645c957ff33c2fabba3145db3352f8656674da04a9ae39159183ba07 |
|
MD5 | 18fcd33f756bac17debcce0c53878baa |
|
BLAKE2b-256 | cc888345f331ce47667f167bdb8c787e88cf0c651450f323ba65ece9e4a1d897 |