https://github.com/bsilverthorn/maccarone Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Customer Stories + White papers, Ebooks, Webinars + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. {{ message }} bsilverthorn / maccarone Public * Notifications * Fork 0 * Star 77 AI-managed code blocks in Python [?][?] License MIT license 77 stars 0 forks Activity Star Notifications * Code * Issues 0 * Pull requests 0 * Actions * Security * Insights More * Code * Issues * Pull requests * Actions * Security * Insights bsilverthorn/maccarone This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 22 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/b] Use Git or checkout with SVN using the web URL. [gh repo clone bsilve] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @bsilverthorn bsilverthorn Merge pull request #16 from bsilverthorn/ mac-51-set-package__version__ ... f7585a8 Aug 24, 2023 Merge pull request #16 from bsilverthorn/ mac-51-set-package__version__ set `maccarone.__version__` from package metadata f7585a8 Git stats * 137 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows workflows/publish-to-pypi: run from 3.8. July 6, 2023 09:59 .vscode .vscode: add test settings. August 18, 2023 16:41 examples examples/: switch to "code blocks" style. July 5, 2023 15:42 src/maccarone __init__: set __version__ from metadata. August 24, 2023 09:56 .gitignore .gitignore: venv-* directories. July 19, 2023 10:01 LICENSE Initial commit May 19, 2023 16:38 README.md README: link to short blog post. August 24, 2023 08:58 dev-requirements.txt dev-requirements.txt: drop stale_maccarone. July 5, 2023 16:23 local-dev-requirements.txt dev-requirements files: add them. May 19, 2023 17:45 pyproject.toml pyproject.toml: require Python >= 3.8, from 3.10. July 5, 2023 16:18 View code [ ] Maccarone: AI-managed code blocks in Python [?][?] Example Quickstart Prerequisites Easy Mode - VS Code Extension Other Option - Command Line Usage notes Running maccarone on a directory Related work FAQs It needs my OpenAI API key? What prevents my program from behaving differently after each preprocessing run? What about non-English languages? What does "maccarone" mean? README.md Maccarone: AI-managed code blocks in Python [?][?] PyPI version Maccarone lets you delegate sections of your Python program to AI ownership. Here's what it looks like in the VS Code extension: screencap-20230629 Example You might write some code like this: def main(path: str): #<> for fn in filenames: #<> print(fn, size) #<> Maccarone then fills in the sections you've delegated: def main(path: str): #<> import os filenames = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))] #<> for fn in filenames: #<> size = os.path.getsize(os.path.join(path, fn)) #<> print(fn, size) #<> import argparse parser = argparse.ArgumentParser() parser.add_argument("path", type=str) args = parser.parse_args() main(args.path) #<> Make a change in your code, like adding an extension parameter to main, and Maccarone keeps its sections up to date: def main(path: str, extension: str | None = None): #<> ... if extension: filenames = [f for f in filenames if f.endswith(extension)] #<> ... #<> ... parser.add_argument("--extension", type=str, default=None) args = parser.parse_args() main(args.path, args.extension) #<> Quickstart Prerequisites * Python 3.8+ * OpenAI API key with GPT-4 (export OPENAI_API_KEY) Easy Mode - VS Code Extension Easy mode is the free extension from the VS Code marketplace. Install it in VS Code and you're done (if you have the prerequisites above). Other Option - Command Line If you don't use VS Code, you can still install Maccarone directly from PyPI: * pip install maccarone Then run maccarone to generate code and update your source file: $ maccarone --rewrite examples/file_sizes.py Usage notes Running maccarone on a directory Maccarone can rewrite all files in a directory: $ maccarone --rewrite --suffix .py examples/ Be careful! You should probably run this only on files in source control, for example. Related work * https://github.com/bsilverthorn/vernac FAQs It needs my OpenAI API key? Maccarone prompts GPT-4 to write code. It will make OpenAI API calls using your key and you will be charged by OpenAI. API calls are made every time Maccarone preprocesses a new version of a source file. The number of tokens consumed is proportional to the size of your completed code. You cannot accurately predict that number in advance. A small source module might cost $0.01-0.10 to preprocess. What prevents my program from behaving differently after each preprocessing run? The strength of your faith in GPT-4. What about non-English languages? They are likely to work, but less likely than English. What does "maccarone" mean? https://en.wikipedia.org/wiki/Macaronic_language About AI-managed code blocks in Python [?][?] Topics python generative-ai Resources Readme License MIT license Activity Stars 77 stars Watchers 2 watching Forks 0 forks Report repository Releases 22 v0.1.9 Latest Aug 24, 2023 + 21 releases Used by 1 * @bsilverthorn @bsilverthorn / maccarone-vscode Languages * Python 100.0% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time.