From 48c0dd9130edcb0c533aa1f9ac6ef30da313dbfb Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 14 Aug 2023 17:08:20 -0700 Subject: [PATCH 1/3] dev experience tweaks --- poetry.lock | 48 +++++++++++++++++++++++++++++++++++++++++++-- pyproject.toml | 3 ++- readme.md | 11 ++++++----- smol_dev/prompts.py | 5 +++++ 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/poetry.lock b/poetry.lock index 996194ddd..0f3bd0d06 100644 --- a/poetry.lock +++ b/poetry.lock @@ -166,6 +166,7 @@ files = [ ] [package.dependencies] +exceptiongroup = {version = "*", markers = "python_version < \"3.11\""} idna = ">=2.8" sniffio = ">=1.1" @@ -323,6 +324,20 @@ files = [ {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] +[[package]] +name = "exceptiongroup" +version = "1.1.3" +description = "Backport of PEP 654 (exception groups)" +optional = false +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.1.3-py3-none-any.whl", hash = "sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3"}, + {file = "exceptiongroup-1.1.3.tar.gz", hash = "sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9"}, +] + +[package.extras] +test = ["pytest (>=6)"] + [[package]] name = "fastapi" version = "0.100.0" @@ -477,6 +492,7 @@ files = [ h11 = "*" h2 = ">=3.1.0" priority = "*" +tomli = {version = "*", markers = "python_version < \"3.11\""} wsproto = ">=0.14.0" [package.extras] @@ -740,13 +756,29 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} iniconfig = "*" packaging = "*" pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"] +[[package]] +name = "python-dotenv" +version = "1.0.0" +description = "Read key-value pairs from a .env file and set them as environment variables" +optional = false +python-versions = ">=3.8" +files = [ + {file = "python-dotenv-1.0.0.tar.gz", hash = "sha256:a8df96034aae6d2d50a4ebe8216326c61c3eb64836776504fcca410e5937a3ba"}, + {file = "python_dotenv-1.0.0-py3-none-any.whl", hash = "sha256:f5971a9226b701070a4bf2c38c89e5a3f0d64de8debda981d1db98583009122a"}, +] + +[package.extras] +cli = ["click (>=5.0)"] + [[package]] name = "python-multipart" version = "0.0.6" @@ -806,6 +838,7 @@ files = [ [package.dependencies] anyio = ">=3.4.0,<5" +typing-extensions = {version = ">=3.10.0", markers = "python_version < \"3.10\""} [package.extras] full = ["httpx (>=0.22.0)", "itsdangerous", "jinja2", "python-multipart", "pyyaml"] @@ -824,6 +857,17 @@ files = [ [package.extras] doc = ["reno", "sphinx", "tornado (>=4.5)"] +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + [[package]] name = "tqdm" version = "4.65.0" @@ -975,5 +1019,5 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" -python-versions = "^3.11" -content-hash = "c9659022543244cf9ad46ebfe70156f3f10cedacf2f67e38ec943b994f78ca5b" +python-versions = ">=3.9, <4.0" +content-hash = "0dd47e4699bb5c42a875f1fa3e93faf184a23aafaaff41be1e7544b90333c780" diff --git a/pyproject.toml b/pyproject.toml index dd43301b1..1663f6179 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,11 +8,12 @@ readme = "readme.md" packages = [{ include = "smol_dev" }] [tool.poetry.dependencies] -python = ">=3.8" +python = ">=3.9, <4.0" openai = "^0.27.8" openai-function-call = "^0.0.5" tenacity = "^8.2.2" agent-protocol = "^0.2.3" +python-dotenv = "^1.0.0" [build-system] requires = ["poetry-core"] diff --git a/readme.md b/readme.md index e4f1a0ce2..049e12d8e 100644 --- a/readme.md +++ b/readme.md @@ -33,14 +33,15 @@ After the [successful initial v0 launch](https://twitter.com/swyx/status/1657578 git clone https://github.com/smol-ai/developer.git cd developer poetry install # install dependencies. pip install poetry if you need +poetry shell # activate virtualenv # 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 +python3 main.py "a HTML/JS/CSS Tic Tac Toe Game" # defaults to gpt-4-0613 +# python3 main.py "a HTML/JS/CSS Tic Tac Toe Game" --model=gpt-3.5-turbo-0613 # 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 +python3 main.py --prompt prompt.md # for longer prompts, move them into a markdown file +python3 main.py --prompt prompt.md --debug True # for debugging ```
@@ -110,7 +111,7 @@ poetry run api ``` or ```bash -python smol_dev/api.py +python3 smol_dev/api.py ``` and then you can call the API using either the following commands: diff --git a/smol_dev/prompts.py b/smol_dev/prompts.py index 0ab19c556..a7a242b21 100644 --- a/smol_dev/prompts.py +++ b/smol_dev/prompts.py @@ -11,9 +11,14 @@ wait_random_exponential, ) import logging +import os +from dotenv import load_dotenv logger = logging.getLogger(__name__) +load_dotenv() +openai.api_key = os.environ.get("OPENAI_API_KEY") + SMOL_DEV_SYSTEM_PROMPT = """ You are a top tier AI developer who is trying to write a program that will generate code for the user based on their intent. From 3b328c08399c29f11f36dcd806a6646792dfec2a Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 14 Aug 2023 17:21:47 -0700 Subject: [PATCH 2/3] add poetry-install .vscode task --- .gitignore | 1 - .vscode/launch.json | 15 +++++++++++++++ .vscode/settings.json | 4 ++++ .vscode/tasks.json | 12 ++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.gitignore b/.gitignore index 29843ebb0..1154ddbe5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ .env env __pycache__ -.vscode .idea /.idea/ venv/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..ba4a8bc63 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Debug main.py", + "type": "python", + "request": "launch", + "program": "main.py", + "console": "integratedTerminal", + "justMyCode": true, + "args": ["--debug", "'a HTML/JS/CSS Tic Tac Toe Game'"], + "preLaunchTask": "poetry-install", + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..9a21ec846 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python3" + } + \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..679c0a9e6 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,12 @@ +{ + "version": "2.0.0", + "tasks": [ + // Install or update all dependencies for all projects in the monrepo + { + "label": "poetry-install", + "type": "shell", + "command": "poetry install", + "problemMatcher": [], // Empty so users are not promted to select progress reporting + }, + ] +} \ No newline at end of file From 690476f92b573a20594b0499ddd6e15402b393d6 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Mon, 14 Aug 2023 17:27:36 -0700 Subject: [PATCH 3/3] update readme --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index 049e12d8e..9c4b6af00 100644 --- a/readme.md +++ b/readme.md @@ -44,6 +44,8 @@ python3 main.py --prompt prompt.md # for longer prompts, move them into a markdo python3 main.py --prompt prompt.md --debug True # for debugging ``` +> Make sure to copy `.example.env` to `.env` and fill in your OpenAI API key +
This lets you develop apps as a human in the loop, as per the original version of smol developer. @@ -73,6 +75,8 @@ Loop until happiness is attained. Notice that AI is only used as long as it is a In this way you can use your clone of this repo itself to prototype/develop your app. +Alternatively, you can install and debug smol-developer in VS Code just by pressing F5 (using the preconfigured `launch.json`). + ### In Library mode This is the new thing in smol developer v1! Add `smol developer` to your own projects!