Skip to content

๐Ÿš€ Rapid AI-driven prototyping in Python using GPT-3, ChatGPT, and more ๐Ÿค–. Provide doctests, and let the AI do the rest!

License

Notifications You must be signed in to change notification settings

nilp0inter/gptrun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

66 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

gptrun

gptrun is a Python library that enables you to seamlessly harness the power of language models like GPT-3 and ChatGPT for rapid prototyping without writing any code, using a technique called few-shot prompting.

Instead of generating code to run like Github's Copilot, gptrun directly computes the answers to your function calls using GPT-3. All you need to do is provide some doctests for your desired function, and let GPT-3 do the rest.

Features

  • Effortless function mocking using GPT-3
  • Test-driven development with doctests
  • Customizable GPT-3 parameters using decorators
  • Easy integration with other AI models

Installation

To install gptrun, follow these steps:

  1. Install the library from the GitHub repository:
$ pip install git+https://github.com/nilp0inter/gptrun@main
  1. Set up your OpenAI API key:
$ export OPENAI_API_KEY="<your OPENAI key>"

If you don't have an API key, you can obtain one from the OpenAI API website.

Usage

Using gptrun is as simple as adding a decorator to your functions and providing some doctests. Here's a basic example:

from gptrun import gptrun

@gptrun
def capital(country):
    """
    Return the capital of a country.

    >>> capital("Angola")
    "Luanda"
    >>> capital("France")
    "Paris"
    >>> capital("Spain")
    "Madrid"
    """
    pass  # No need to write any code!

# Test your function
capital.test_task_generalization()

# Call your function
print(capital("China"))  # Output: "Beijing"

Not impressed yet? ๐Ÿค”

>>> from examples import is_irony
>>> is_irony("If you find me offensive. Then I suggest you quit finding me.")
True
>>> is_irony("If you find me offensive. Then I suggest you quit.")
False

You can adjust GPT3 parameters using the decorator. See examples.py. For more advanced usage and customization, check out the examples in examples.py.

Contributing

Contributions to gptrun are always welcome! If you have an idea for a new feature, a bug report, or a question, please open an issue on GitHub. To submit a pull request, please fork the repository and create a new branch with your changes.

About

๐Ÿš€ Rapid AI-driven prototyping in Python using GPT-3, ChatGPT, and more ๐Ÿค–. Provide doctests, and let the AI do the rest!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published