#GPTConnect - GPT Functions Simplified with Python

7 messages · Page 1 of 1 (latest)

glass saffron
#

GPTConnect is a Python python package that simplifies the use of the new functions feature. It provides an easy-to-use framework for creating and interacting with GPT functions.

This package is in somewhat early stages of development, I'd appreciate your suggestions and feedback!

Example Usage:

import os

from gptconnect import GPTConnect, GPTFunction, GPTFunctionHandler
import requests
import dotenv

dotenv.load_dotenv()

ai = GPTConnect(token=os.environ.get("TOKEN"), model="gpt-3.5-turbo-0613")


@GPTFunctionHandler()
def custom_function_handler(function, args):
    # Please make sure to update or remove this code when adding new functions
    if function.__name__ == "ping_hostname":
        return function(args)
    else:
        return "The function called is invalid. Please let the user know this operation failed."


# Decorator based defining system
@GPTFunction(
    group="general_commands",
    description="Ping a hostname",
    params={
        "type": "object",
        "properties": {
            "hostname": {
                "type": "string",
                "description": "The hostname to ping",
            },
        },
        "required": ["hostname"],
    },
)
def ping_hostname(args: dict) -> str:
    print(f"Pinging hostname {args.get('hostname')}...")
    url = f"https://{args.get('hostname')}"
    response = requests.get(url)
    return f"Response code: {response.status_code}"


print(ai.call(prompt="Ping the hostname github.com", function_group="general_commands"))

# Output:
# Pinging hostname github.com...
# {
#     'content': 'The hostname "github.com" was successfully pinged with a response code of 200.',
#     'function_called': 'ping_hostname'
# }

Github Repo: https://github.com/SleepyStew/gptconnect
(I'd appreciate a star ✨ if you find this project helpful)
PyPI: https://pypi.org/project/GPTConnect/

elder axle
#

There's not enough documentation on Functions. I will try this with my Autocode bot.

elder axle
#

Your documentation is great bud sorry. I meant openai hasn't done much to make this simple to noobs like me.

glass saffron
glass saffron
elder axle
#

Thank you.