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.

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.

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

Uploaded Source

Built Distribution

GPTPlugins4All-1.0.4-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: GPTPlugins4All-1.0.4.tar.gz
  • Upload date:
  • Size: 9.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.4.tar.gz
Algorithm Hash digest
SHA256 2cadb8407e894f7ed6c43f51055e728897d524d4e7702a44741ec909cf12e8dd
MD5 8a5b378603c7d97fc72c4ddab2a77dd3
BLAKE2b-256 5988c24e8ad8814b0ed11a5eccc14dd3d48e1e81ab3230f8bba7926a7cdef75a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for GPTPlugins4All-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 04bb942cf3f74603c3f2ae7fdc93a78c00be2ba84788bc3887026076ec26c577
MD5 a31631747688b2d6ba192b7134332fd0
BLAKE2b-256 cce8eebd82909726cbd81e8b218a148432d54ed4a670740eeda0469fcc9cc4cd

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