autogenlib  by cofob

Python library for dynamic code generation using OpenAI's API

Created 4 months ago
380 stars

Top 75.0% on SourcePulse

GitHubView on GitHub
Project Summary

AutoGenLib is a Python library designed to automatically generate code on-the-fly using OpenAI's API. It targets developers who want to rapidly prototype or explore functionality by describing desired modules and functions, which are then created dynamically based on context and existing code. The primary benefit is accelerating development by generating boilerplate or novel code snippets without manual implementation.

How It Works

AutoGenLib leverages OpenAI's API to generate code. When a non-existent module or function is imported under the autogenlib namespace, the library analyzes the calling code and any previously generated modules. This context, along with a user-provided description, is sent to the OpenAI API. The generated code is then validated, executed, and made available for use, with options for caching to improve consistency and reduce API calls.

Quick Start & Requirements

  • Install via pip: pip install autogenlib or from source.
  • Requires Python 3.12+ and an OpenAI API key set as the OPENAI_API_KEY environment variable.
  • Optional configuration for OPENAI_API_BASE_URL and OPENAI_MODEL.
  • Quick start example: from autogenlib.tokens import generate_token; token = generate_token(length=32); print(token)
  • Official documentation and examples are available in the README.

Highlighted Details

  • Dynamic code generation for non-existent modules/functions.
  • Context-aware generation, analyzing calling code and existing modules.
  • Progressive enhancement of existing modules.
  • Automatic exception handling and explanation via LLM.
  • No default caching, promoting varied results; caching can be enabled.

Maintenance & Community

  • The project explicitly states "Contributions are not welcome! This is just a fun PoC project."
  • No community links (Discord/Slack) or roadmap are provided.

Licensing & Compatibility

  • Licensed under the MIT License.
  • Suitable for experimentation and prototyping; review generated code for production use.

Limitations & Caveats

This library requires an internet connection and depends on OpenAI API availability. The quality of generated code is contingent on the clarity of user descriptions. The project is explicitly marked as a Proof of Concept (PoC) and not recommended for production-critical code without thorough review.

Health Check
Last Commit

1 week ago

Responsiveness

1 day

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

Explore Similar Projects

Starred by Jared Palmer Jared Palmer(Ex-VP AI at Vercel; Founder of Turborepo; Author of Formik, TSDX), Vincent Weisser Vincent Weisser(Cofounder of Prime Intellect), and
8 more.

llm-vscode by huggingface

0.1%
1k
VSCode extension for LLM-powered code development
Created 2 years ago
Updated 1 year ago
Starred by Wei-Lin Chiang Wei-Lin Chiang(Cofounder of LMArena), Chip Huyen Chip Huyen(Author of "AI Engineering", "Designing Machine Learning Systems"), and
4 more.

qwen-code by QwenLM

3.4%
13k
AI coding agent for complex codebases
Created 2 months ago
Updated 18 hours ago
Feedback? Help us improve.