Skip to main content

A Python class that does what you need

Project description

GPTClass

GPTClass is a Python class that uses OpenAI's GPT to generated the code that does what you need with minimal information.

version codecov

How it works?

It uses the method's name and information about the parameters used to build the source code using ChatGPT and then executes it locally.

Installation

pip install gptclass

Usage

Do whatever you need:

>>> import openai
>>> openai.api_key = "..."

>>> from gptclass import GPTClass
>>> gpt = GPTClass()

>>> gpt.add(1, 2)
3
>>> gpt.n_unique([1, 2, 5, 5])
3
>>> gpt.prime_numbers_below(10)
[2, 3, 5, 7]
>>> gpt.count_vowels("Today I had a nice coffee!")
10
>>> gpt.from_celsius_to_fahrenheit(25)
77.0
>>> gpt.random_plate_number(seed=123)
BIC6410

Show me the generated code

Adding explain before invoking the method will print the code:

>>> gpt.explain.from_celsius_to_fahrenheit(25)
def from_celsius_to_fahrenheit(celsius):
    return (celsius * 1.8) + 32

>>> gpt.explain.factorial(15)
def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)

Notes

Warning

  • The code produced may not be reliable and should be validated before executing it.

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

gptclass-0.4.0.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

gptclass-0.4.0-py3-none-any.whl (4.2 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