Skip to main content

GPT Plugins for 4all

Project description

GPT Plugins 4All GPTPlugins4All logo

GPT Plugins 4All is a Python library designed to facilitate the integration of GPT and other large language models with various APIs, leveraging OpenAPI specifications. This library simplifies the process of parsing OpenAPI specs, managing different authentication methods, and dynamically interacting with APIs based on model responses. PyPI version Demo using the AlphaVantage API with OpenAI

Features

  • Parse and validate OpenAPI 3.1.0 specifications.
  • Handle diverse authentication methods, including OAuth 2.0, Basic Auth, Header Auth, and Query Parameter Auth.
  • Generate structured API representations for AI interactions.
  • Dynamically construct API calls based on OpenAPI specs.
  • Support OAuth2.0 flow for token acquisition and usage.
  • Easily create and manage instances of AI assistants and threads for interactive sessions
  • Command-Line Interface (CLI) for convenient management of configurations and interactions.

Installation

Install GPT Plugins 4All using pip:

pip install GPTPlugins4All

Using the CLI

The GPT Plugins 4All CLI provides a convenient way to manage configurations and interact with your APIs from the command line. ###Common Commands Search for Configurations

gpt-plugins-4all search --query "your_search_query"

Fetch a Specific Configuration

gpt-plugins-4all get --id "config_id_or_name"

List Your Configurations

gpt-plugins-4all my-configs --api-key "your_api_key"

Submit a New Configuration

gpt-plugins-4all submit-config --url "config_url" --auth-type "auth_type" --visibility "visibility" --api-key "your_api_key"

Usage

The CLI supports various operations such as searching for configurations, retrieving specific configurations, listing user configurations, and submitting new configurations. You can use these commands directly from your terminal to interact with the GPT Plugins 4All library.

For detailed usage and available options for each command, use the --help flag with any command:

gptplugins4all [command] --help

Quick Start

Initializing with an OpenAPI Specification

We support initializing with an OpenAPI Spec in two ways. One way is to just give the name of the spec from https://gptplugins4all.com like this:

config = Config('alpha_vantage')

We also support directly making a config from an OpenAPI spec.

from GPTPlugins4All.config import Config

# Initialize the Config object with your OpenAPI spec
spec_string = """..."""  # Your OpenAPI spec as a string
config = Config(spec_string)

Adding Authentication Methods

Add Basic Authentication

config.add_auth_method("BASIC", {"key": "your_api_key"})

Add OAuth Configuration

config.add_auth_method("OAUTH", {
    "client_id": "your_client_id",
    "client_secret": "your_client_secret",
    "auth_url": "https://example.com/auth",
    "token_url": "https://example.com/token",
    "redirect_uri": "https://yourapp.com/oauth-callback",
    "scope": "read write"
})

Generating Simplified API Representations

simplified_api = config.generate_simplified_api_representation()
print(simplified_api)

Generate Object for use with OpenAI functions

tools = config.generate_tools_representation()

Using the Assistant Class

The Assistant class (for now) provides a simplified interface between your plugins and various OpenAI models via the Assistants API.

Initializing the Assistant

from assistant import Assistant

# Create an assistant instance
my_assistant = Assistant(config, "My Assistant", "Your instructions", "model_name")

Interacting with the assistant

# Getting a response from the assistant
response = my_assistant.get_assistant_response("Your query here")
print(response)

OAuth Flow

auth_url = config.start_oauth_flow()
# Redirect the user to auth_url...

tokens = config.handle_oauth_callback(code_from_redirect)

Making API Calls

response = config.make_api_call("/endpoint", "GET", {"param": "value"})

Oauth

url = config5.start_oauth_flow() #use this url to get code first
callback = config5.handle_oauth_callback(code)
#example
response = config5.make_api_call_by_path(path, "POST", params=your_params, user_token=callback, is_json=True)

Contributing

Contributions are welcome! Please check out the contributing guidelines.

License

GPT Plugins 4All is released under the MIT License.

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

gptplugins4all-1.0.42.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

GPTPlugins4All-1.0.42-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file gptplugins4all-1.0.42.tar.gz.

File metadata

  • Download URL: gptplugins4all-1.0.42.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for gptplugins4all-1.0.42.tar.gz
Algorithm Hash digest
SHA256 d9e1bc8b2bf0fd8b038a5167149f0c718305f1c53023b49f540e97e5bc408205
MD5 75dfe841f2f208235400bbfd7ae53715
BLAKE2b-256 2a5424a46b6e0e6b0ccbc6431ee27f1b85c315c9f6cdcb8e2bae3f086ed04979

See more details on using hashes here.

File details

Details for the file GPTPlugins4All-1.0.42-py3-none-any.whl.

File metadata

File hashes

Hashes for GPTPlugins4All-1.0.42-py3-none-any.whl
Algorithm Hash digest
SHA256 de714aa87078820bad8559147d368ea8d2cfc4b89b3dd57e28f250f9e9016f32
MD5 eb04ffa0a740121ec9947a30cc02f2fc
BLAKE2b-256 662fd7e1e78f57715798c3a51b8f91b9bbe609475236ba9b12bb77dad2fe04d9

See more details on using hashes here.

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