Skip to main content

AI-powered file generation CLI tool

Project description

FileCannon

Introduction

FileCannon is an AI-powered file generation CLI tool that creates new files based on examples and natural language descriptions. It leverages AI models to generate content, making it easy to quickly create files with a structure similar to provided examples.

Usage

To use FileCannon, you need to have Python installed on your system. First, clone the repository and install the required dependencies:

git clone git@github.com:255BITS/filecannon.git
cd filecannon
pip install -r requirements.txt

Then, you can use the filecannon command with the following syntax:

filecannon <prompt> [options]

Arguments:

  • prompt: Description of the file to generate (required)

Options:

  • -e, --example: Path to example file(s) (can be used multiple times)
  • -m, --model: Model to use (default: claude-3-5-sonnet-20240620)
  • -o, --output: Output directory (default: current directory)

Example:

filecannon "Create a Python script that calculates fibonacci numbers" -e examples/math_functions.py -o output/

Files

The main custom files in this project are:

  • filecannon.py: The main script containing the CLI logic and core functionality
  • ai_manager.py: Handles AI interactions and prompt management
  • file_manager.py: Manages file operations and tool implementations
  • tool_parser.py: Allows XML use of tools by FileCannon

Methods

AIManager

  • generate_content(prompt: str, examples: List[str], example_contents: List[str]) -> str
  • construct_prompt(user_prompt: str, context: dict) -> str

FileManager

  • list_files(directory: str) -> List[str]
  • read_file(path: str) -> str
  • write_file(path: str, content: str) -> bool
  • validate_path(path: str) -> bool

ToolParser

This component allows XML use of tools by FileCannon. The specific methods are not detailed in the specification.

Models

FileCannon supports the following AI models:

  • Claude 3.5 Sonnet (default)
  • OpenAI models (configurable)

Available CSS styles

This project is a CLI tool and does not include any CSS styles.

Available JS functions

This project is a CLI tool and does not include any JavaScript functions.

Additional notes

  1. Environment Variables:

  2. Dependencies:

    • openai
    • anthropic
  3. The tool uses a specific conversation flow for generating content, which includes system prompts, user prompts, and assistant responses.

  4. The write_file tool is used to output the generated content in XML format:

    <use_tool>
        <name>write_file</name>
        <path>path/to/output/filename.ext</path>
        <content>
            [generated content]
        </content>
    </use_tool>
    
  5. Always ensure you have the necessary API keys and permissions set up before using the tool.

  6. The generated content aims to be practical and production-ready, following the structure and conventions shown in the example files.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

filecannon-0.1.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

filecannon-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file filecannon-0.1.0.tar.gz.

File metadata

  • Download URL: filecannon-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for filecannon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f96d79d6f99dd489f69efbf3dbcb671ad873b7fa6e0577713deb490218d625b1
MD5 d01f2239a220f82154214169ed547283
BLAKE2b-256 7e7359e15f6f38a87a743abbf620cedf5b007a1a865eeca1087504891a0c12c4

See more details on using hashes here.

File details

Details for the file filecannon-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: filecannon-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for filecannon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 19c3cf43d8ed162bcfe9a435f4f09f258b57b136b8e9d6ac9aaf6681ed839c9e
MD5 0cf43d6e2738ca50a05bed812f296763
BLAKE2b-256 8e319a15c16df9d12a4d954661d3c97c65f9bf16373c31b5b733f1dc37f4efc9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page