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

Uploaded Source

Built Distribution

GPTPlugins4All-1.0.4-py3-none-any.whl (10.7 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