Skip to main content

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 as text-davinci-003.
  • version - The version of the model. This may return None 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

openplayground-api-0.0.1.tar.gz (15.2 kB view hashes)

Uploaded Source

Built Distribution

openplayground_api-0.0.1-py3-none-any.whl (15.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page