Skip to content

The OpenWiz CLI is a powerful command-line tool that utilizes the OpenAI API to generate code snippets based on user prompts. It is designed to assist developers by providing code suggestions and templates directly into their development environment, thereby enhancing coding efficiency.

License

Notifications You must be signed in to change notification settings

basith-ahmed/openwiz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenWiz CLI

Overview

The OpenWiz CLI is a powerful command-line tool that utilizes the OpenAI API to generate code snippets based on user prompts. It is designed to assist developers by providing code suggestions and templates directly into their development environment, thereby enhancing coding efficiency. The CLI also offers functionalities to save and load sessions, manage configurations, and handle generated code effectively.

Features

  • Generate Code: Create code snippets based on textual prompts using the OpenAI API.
  • Save Generated Code: Directly save generated code to specified files.
  • Save and Load Sessions: Save the current state of your prompts and generated code for later use and seamlessly continue working with previously saved sessions.
  • Configuration Management: Easily configure your OpenAI API key and other settings.

Installation Guide

Prerequisites

  • Python 3.7 or later
  • OpenAI API key

Developer Setup

  1. Clone the Repository:

    git clone https://github.com/basith-ahmed/openwiz.git
    cd openwiz
  2. Virtual Environment Setup:

    python -m venv venv
    .\venv\Scripts\activate
    pip install -r requirements.txt
  3. API Key Configuration:

    python src\cli.py configure

Usage Instructions

1. Configuration

python src\cli.py configure

Output:

Enter your OpenAI API key: <your_api_key>

2. Code Generation

python src\cli.py generate "Create a Python function to add two numbers"

Sample Output:

Generated Code:
def add(a, b):
    return a + b

3. Saving Generated Code

python src\cli.py generate "Create a Python function to subtract two numbers" --file-name subtract.py

Sample Output:

Generated Code:
def subtract(a, b):
    return a - b

> Code saved to subtract.py

4. Session Management

Save the current session with a specific name for later retrieval.

python src\cli.py save --session-name my_session --prompt "Create a Python function to add two numbers"

Sample Output:

Generated Code:
def add(a, b):
    return a + b

> Session my_session saved

Explanation: This command saves the current session with the provided prompt under the name my_session.

5. Loading Sessions

Load a previously saved session to resume work from a specific state.

python src\cli.py load --session-name my_session

Sample Output:

Loaded Session:
{
    "prompt": "Create a Python function to add two numbers",
    "generated_code": "def add(a, b):\n    return a + b"
}

Explanation: This command loads the session named my_session, allowing access to the associated prompt and generated code.

Installation

Install the package from PyPI to integrate with existing projects.

pip install openwiz

Configuration and Usage

Configure the OpenAI API key and utilize the CLI functionalities as demonstrated in the previous section.

1. Configuration

owc configure

2. Code Generation

owc generate "Create a Python function to add two numbers"

3. Saving Generated Code

owc generate "Create a Python function to subtract two numbers" --file-name subtract.py

4. Session Management

owc save --session-name my_session --prompt "Create a Python function to add two numbers"

5. Loading Sessions

owc load --session-name my_session

Command Reference

Command Description Options
generate Generate code based on a prompt. --file-name: Save the generated code to a specified file.
save Save the current session with a specified name. --session-name: Save the generated code as a session to view later.
load Load a previously saved session. --f: Load and view all the saved sessions.
--d: Delete a specific session.
--session-name: Load a specific session from the saved sessions.
configure Configure the OpenAI API key.

Development Guidelines

Running Tests

Ensure code integrity by running unit tests.

pytest tests/

Explanation: This command executes the unit tests located in the tests directory to validate the functionality of the codebase.

Contribution Workflow

Contribute to the project by following these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Implement changes and add corresponding tests.
  4. Commit the changes (git commit -am 'Add new feature').
  5. Push the changes to the branch (git push origin feature-branch).
  6. Create a new Pull Request for review and integration.

Contributing

We welcome contributions! Please see the CONTRIBUTING.md file for more details.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

The OpenWiz CLI is a powerful command-line tool that utilizes the OpenAI API to generate code snippets based on user prompts. It is designed to assist developers by providing code suggestions and templates directly into their development environment, thereby enhancing coding efficiency.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages