Skip to main content

Template Engine V2 - Create software component skeletons from templates and generate new components with AI-assisted tools.

Project description

Template Engine V2

Hello there! Thank you for using the Template Engine. Please review our commercial license for legal use and contact us at support@entinco.com for inquiries and clarification.


Overview

The Template Engine is a powerful tool designed to create software component skeletons from templates. This tool streamlines the process of creating complex software components by leveraging templates and advanced AI-based descriptions for increased precision.

Features

Template-based Skeleton Generation

  • Copies a component template to a specified output directory and performs search & replace operations on targeted keywords.

AI-Powered Planning and Strategy Selection

  • Utilizes OpenAI's GPT model to analyze specifications and determine the most effective strategy for each task.
  • Automatically identifies dependencies and optimizes execution paths.
  • Supports generative assistance to create new templates and components based on custom needs and specifications.

CLI with Flexible Options

  • Offers intuitive command-line options for quiet, verbose, and replacement modes.
  • Supports batch operations for repeatable processes, enabling automated workflows.
  • Provides helpful error messages and usage hints for a smoother user experience.

Specification Handling

  • Reads JSON-formatted specification files to guide the component generation process.
  • Adapts dynamically based on user-provided descriptions and templates.
  • Integrates structured and unstructured input to provide a robust understanding of the component structure.
  • Supports .gitignore-style lists to skip unnecessary files and directories during generation.

Installation

Install this package from PyPI using the Python package installer (Pip):

pip install templateengine

Command-line Usage

To run the Template Engine, use the following command in your terminal:

templateengine [options]

General Arguments

  • -h, --help: Displays available command-line arguments.

    • Type: Utility
    • Required: No
  • --version: Displays the current version of the Template Engine.

    • Type: Utility
    • Required: No

Primary Parameters

  • -t, --template: Specifies the folder or directory path where the component template is located.

    • Type: Required
    • Shorthand: -t
  • -o, --output: Specifies the folder or directory path where the resulting component will be saved.

    • Type: Required
    • Shorthand: -o

Optional Parameters

  • -g, --ignore: Specifies the file name or relative path in the template directory for a list of ignored keywords. By default, it looks for a .gitignore file.

    • Type: Optional
    • Default: .gitignore
    • Shorthand: -g
  • -n, --name: Specifies a search and replacement keyword pair for renaming components. Can be repeated for multiple replacements.

    • Type: Optional but recommended
    • Shorthand: -n
    • Usage: --name=<old_name>:<new_name>
    • Example: --name=entity:product
  • -v, --verbose: Enables verbose output for detailed information during execution.

    • Type: Optional
    • Shorthand: -v
  • -q, --quiet: Mutes all output during execution. Overrides --verbose if both are present.

    • Type: Optional
    • Shorthand: -q
  • -s, --spec: Specifies the file path to the component specifications file (in JSON format).

    • Type: Optional
    • Shorthand: -s
    • Description: This file guides the generation process and helps describe subcomponents in detail.
  • -m, --model: Specifies the GPT model to use for AI-assisted generation.

    • Type: Optional
    • Default: gpt-4o
    • Shorthand: -m

OpenAI API Key

The Template Engine requires an OpenAI API key to use AI-assisted planning and component generation. The API key can be provided in two ways:

  1. Environment Variable: Set the OPENAI_API_KEY in your system environment.

    export OPENAI_API_KEY=your_openai_api_key_here
    
    • Benefits: Automatically read during execution for convenience.
  2. Manual Input: If the environment variable is not set, the Template Engine will prompt you to input the API key manually.

API Key Validation:

  • The API key must be at least 20 characters long.
  • If the key is invalid or missing, the program will terminate with an error code 4.
    Code 4 - Invalid or missing API key.
    
  • Security Tip: Do not share or hard-code your API key in scripts to avoid unauthorized access.

Example Usage

Here's an example of running the Template Engine from the command line:

#!/usr/bin/env pwsh

templateengine \
--template=../../templates/backend/node/service-cruddata-pipservices \
--output=../../output/service-products-pipservices \
--name=cruddata:products \
--name=entity:product \
--name=entities:products \
--spec=specifications/description.json \
--verbose

InputParams Structure

The InputParams class stores all the key parameters passed to the Template Engine. Here is a breakdown of its attributes:

  • command (str): Specifies the command to execute (e.g., create, extend, fix).
  • template_dir (str): Directory path to the template being used.
  • input_dir (str): Directory path to the input software component.
  • output_dir (str): Directory path where the output software component will be saved.
  • ignore_list (list): List of paths or filenames to ignore during template processing.
  • replacements (list of dicts): List of search and replacement keyword pairs for renaming components.
    • Example: [{"search": "cruddata", "replace": "products"}]
  • specs (dict): JSON-formatted specifications that guide the component generation process.
  • quiet (bool): Whether to suppress all output.
  • verbose (bool): Whether to display detailed execution logs.
  • model (str): Specifies the GPT model to use (default: omni).
  • api_key (str): OpenAI API key for accessing AI-powered features.

Contact

Please contact us at support@entinco.com for inquiries and clarification.


Thank you for using the Template Engine!

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

templateengine-2.0.6.tar.gz (36.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

templateengine-2.0.6-py3-none-any.whl (62.0 kB view details)

Uploaded Python 3

File details

Details for the file templateengine-2.0.6.tar.gz.

File metadata

  • Download URL: templateengine-2.0.6.tar.gz
  • Upload date:
  • Size: 36.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for templateengine-2.0.6.tar.gz
Algorithm Hash digest
SHA256 40782d621e05ed27b95ebe2e47ee4518a8a396bd03430df81b9a9aafcfbed3b2
MD5 ec9ea264cc71fab03890bb7a129484bc
BLAKE2b-256 8a8568cbf46c3d907306a2dd3eef075e990a60259209ce8099589099d9075192

See more details on using hashes here.

File details

Details for the file templateengine-2.0.6-py3-none-any.whl.

File metadata

  • Download URL: templateengine-2.0.6-py3-none-any.whl
  • Upload date:
  • Size: 62.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for templateengine-2.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 a2d6fcf4b0a1aa77552f3364db9ea0bdec472eb80f469d0d63528f5f891c3e45
MD5 d8184e10387b0d8e96edd560ce2f268c
BLAKE2b-256 13327379198a8e1aad55ac2fcbedc8e4bec6478a4ad145051137dbdec2c1b34c

See more details on using hashes here.

Supported by

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