Skip to content

Prompt4Code is a command line tool that facilitates in-context learning, automatically by reading local source code examples and extracting doctrings and turning them into a conversation with openai's GPT models.

License

Notifications You must be signed in to change notification settings

khnshn/prompt4code

Repository files navigation

Prompt4Code logo

Prompt4Code: Automated In-Context Learning to Generate Code Provided Examples with Docstrings

Prompt4Code version license

Prompt4Code is a command line tool that facilitates in-context learning, automatically by reading local source code examples and extracting doctrings and turning them into a conversation with openai's GPT models.

Before you begin

Run pip install -r requirements.txt

Usage

Run python main.py -h or python main.py --help:

usage: main.py [-h] [-d DATA] [-v] [-p PROMPT] [-m MODEL] [-s SAVE] [-ca] [-l LIMIT] [-sh] [-r]

options:

-h, --help show this help message and exit
-d DATA, --data DATA training source code files directory
-v, --verbose display detailed processing information
-p PROMPT, --prompt PROMPT a short sentence or phrase that is used to initiate a conversation
-m MODEL, --model MODEL gpt model to be used
-s SAVE, --save SAVE directory to save the prompt as a json file
-ca, --callapi calls openai api to generate response based on the input prompt
-l LIMIT, --limit LIMIT limit the number of input files for context learning
-sh, --shuffle shuffle the order of the list of files to traverse
-r, --run immediately run and verbose the generated code

Example 1

python main.py
--prompt "this is my example prompt"
--data ./examples
--verbose
--limit 3
--shuffle
--save ./responses/

Example 2

python main.py --prompt "write a python program using simpy that simulates teachers activities during a day. teachers will receive notifications on their smartphone every 2 hours. then depending on their situation they either respond to the notification or ignore it. estimate the response rate to such notfication. run such program for 50 teachers" --data ./examples --verbose --shuffle --run --save ./responses/ --callapi

About

Prompt4Code is a command line tool that facilitates in-context learning, automatically by reading local source code examples and extracting doctrings and turning them into a conversation with openai's GPT models.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages