gpt-macro  by retrage

Rust proc macro for compile-time code generation via ChatGPT

Created 2 years ago
644 stars

Top 51.6% on SourcePulse

GitHubView on GitHub
Project Summary

This Rust crate provides a compile-time code generation utility powered by OpenAI's ChatGPT. It targets Rust developers seeking to automate repetitive coding tasks, such as generating function implementations or unit tests, by leveraging natural language prompts. The primary benefit is reduced boilerplate and faster development cycles.

How It Works

The gpt-macro crate utilizes Rust's procedural macro system to intercept code during compilation. The auto_impl! macro takes a natural language prompt and a code stub, sends them to the OpenAI API, and replaces the stub with the generated code from the API's response. The auto_test macro similarly generates unit tests based on provided test case names and a function stub. This approach integrates AI-driven code generation directly into the Rust build process.

Quick Start & Requirements

  • Install via cargo add gpt-macro.
  • Requires an OpenAI API key set as the OPENAI_API_KEY environment variable.
  • Uses the rustfmt tool for code formatting.

Highlighted Details

  • auto_impl!{} macro for generating function implementations from prompts.
  • #[auto_test(...)] attribute macro for generating unit tests.
  • Integrates directly into the Rust compile-time workflow.

Maintenance & Community

  • The project is maintained by retrage.
  • No community links (Discord, Slack) or roadmap are provided in the README.

Licensing & Compatibility

  • Released under the MIT license.
  • Permissive license suitable for commercial use and integration into closed-source projects.

Limitations & Caveats

The effectiveness of code generation is dependent on the quality of the prompt and the capabilities of the OpenAI API. Compilation time will increase due to external API calls. The project is in its early stages, and extensive testing or formal benchmarks are not yet available.

Health Check
Last Commit

2 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
0
Star History
0 stars in the last 30 days

Explore Similar Projects

Starred by Andrej Karpathy Andrej Karpathy(Founder of Eureka Labs; Formerly at Tesla, OpenAI; Author of CS 231n), Travis Fischer Travis Fischer(Founder of Agentic), and
6 more.

AlphaCodium by Codium-ai

0.1%
4k
Code generation research paper implementation
Created 1 year ago
Updated 9 months ago
Starred by Taranjeet Singh Taranjeet Singh(Cofounder of Mem0), Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), and
11 more.

gpt-migrate by joshpxyne

0.0%
7k
Code migration tool using LLMs
Created 2 years ago
Updated 1 year ago
Feedback? Help us improve.