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

Uploaded Source

Built Distribution

GPTPlugins4All-1.0.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: GPTPlugins4All-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 0360e1b2562d08c54c6237452d9b06f827bef6aa5d56746f588c4b0d496cdfa9
MD5 7a1295ff1ec6eb6391bc86950755adb0
BLAKE2b-256 204fcb2d6842a39ca79d14f758b1a2d19dc2d90e1d4ba49e3ea001c26766d29e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for GPTPlugins4All-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90079639bc2512c491f394a2f7d161a0afafbbf8d33f6d188c686c648ea87ac5
MD5 5679590eded21b146127276599813f63
BLAKE2b-256 3ffddb0c98c080ad4075d9072b865ee549a724fbf50b1c2c4cfcb2e6653b81c2

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