Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/installation and main #120

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 11 additions & 34 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,18 @@
import argparse




# for local testing
# python main.py --prompt "a simple JavaScript/HTML/CSS/Canvas app that is a one player game of PONG..." --generate_folder_path "generated" --debug True

if __name__ == "__main__":
prompt = """
a simple JavaScript/HTML/CSS/Canvas app that is a one player game of PONG.
The left paddle is controlled by the player, following where the mouse goes.
The right paddle is controlled by a simple AI algorithm, which slowly moves the paddle toward the ball at every frame, with some probability of error.
Make the canvas a 400 x 400 black square and center it in the app.
Make the paddles 100px long, yellow and the ball small and red.
Make sure to render the paddles and name them so they can controlled in javascript.
Implement the collision detection and scoring as well.
Every time the ball bouncess off a paddle, the ball should move faster.
It is meant to run in Chrome browser, so dont use anything that is not supported by Chrome, and don't use the import and export keywords.
"""
if len(sys.argv) == 2:
prompt = sys.argv[1]
else:

parser = argparse.ArgumentParser()
parser.add_argument("--prompt", type=str, help="Prompt for the app to be created.")
parser.add_argument("--model", type=str, default="gpt-4-0613", help="model to use. can also use gpt-3.5-turbo-0613")
parser.add_argument("--generate_folder_path", type=str, default="generated", help="Path of the folder for generated code.")
parser.add_argument("--debug", type=bool, default=False, help="Enable or disable debug mode.")
args = parser.parse_args()
if args.prompt:
prompt = args.prompt
parser = argparse.ArgumentParser()
parser.add_argument("--prompt", required=True, type=str, help="Prompt for the app to be created.")
parser.add_argument("--model", type=str, default="gpt-4-0613", help="model to use. can also use gpt-3.5-turbo-0613")
parser.add_argument("--generate_folder_path", type=str, default="generated", help="Path of the folder for generated code.")
parser.add_argument("--debug", type=bool, default=False, help="Enable or disable debug mode.")
args = parser.parse_args()

# read file from prompt if it ends in a .md filetype
if len(prompt) < 100 and prompt.endswith(".md"):
with open(prompt, "r") as promptfile:
prompt = promptfile.read()
if len(args.prompt) < 100 and args.prompt.endswith(".md"):
with open(args.prompt, "r") as promptfile:
args.prompt = promptfile.read()

print(prompt)

main(prompt=prompt, generate_folder_path=args.generate_folder_path, debug=args.debug, model=args.model)
print(args.prompt)
main(prompt=args.prompt, generate_folder_path=args.generate_folder_path, debug=args.debug, model=args.model)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.3"
description = "python module of smol developer"
authors = ["swyx <[email protected]>"]
license = "MIT"
readme = "README.md"
readme = "readme.md"
packages = [{ include = "smol_dev" }]

[tool.poetry.dependencies]
Expand All @@ -22,4 +22,4 @@ src = "src.__main__:main"

[project.urls]
"Homepage" = "https://github.com/smol-ai/developer"
"Bug Tracker" = "https://github.com/smol-ai/developer/issues"
"Bug Tracker" = "https://github.com/smol-ai/developer/issues"
10 changes: 6 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ cd developer
poetry install # install dependencies. pip install poetry if you need

# run
python main.py "a HTML/JS/CSS Tic Tac Toe Game" # defaults to gpt-4-0613
# python main.py "a HTML/JS/CSS Tic Tac Toe Game" --model=gpt-3.5-turbo-0613
poetry run python main.py --prompt "a HTML/JS/CSS Tic Tac Toe Game"

# other cli flags
python main.py --prompt prompt.md # for longer prompts, move them into a markdown file
python main.py --prompt prompt.md --debug True # for debugging
poetry run python main.py --prompt prompt.md # for longer prompts, move them into a markdown file
poetry run python main.py --prompt prompt.md --debug True # for debugging
poetry run python main.py --prompt prompt.md --model gpt-3.5-turbo-0613 # change model, default is gpt-4-0613
# Change the target folder, default is generate/. Note that main will delete what is currently in the folder.
poetry run python main.py --prompt prompt.md --generate_folder_path /path/to/folder/
```

<details>
Expand Down