Skip to main content

GPT Plugins for 4all

Project description

GPT Plugins 4All

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.

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.

Installation

Install GPT Plugins 4All using pip:

pip install GPTPlugins4All

Quick Start

Initializing with an OpenAPI Specification

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()

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.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

GPTPlugins4All-1.0.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file GPTPlugins4All-1.0.2.tar.gz.

File metadata

  • Download URL: GPTPlugins4All-1.0.2.tar.gz
  • Upload date:
  • Size: 5.5 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.2.tar.gz
Algorithm Hash digest
SHA256 2ac1e2f86cbc6ea2733d1f61d35eb79e3d9f549507e9148152de5fd57ce96566
MD5 ab6a4ac60487d23650ad19c3ab2e57c5
BLAKE2b-256 13a6fcc6228012555b08617dbca07aee2b3a177b8f32c37119c1a178fa5d5b96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for GPTPlugins4All-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d5f896ebb22150b4c4016c57fa93284f457267ed7d9c479518d07a23d438b764
MD5 a2ef28b67d356b766ced2d8f704fce70
BLAKE2b-256 99a0fc459fd5872b05b050142c23a1746ff9cbc8b7a9dd1259bdf0eef7c68cff

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