SenseiSnip Extension
Overview
The SenseiSnip extension is a Visual Studio Code extension that detects strings within your code that match a specific pattern, sends them to ChatGPT, and inserts the generated code snippets directly into your code.
Features
- Detects strings between
#
and ?
in the active text editor.
- Sends the detected strings as prompts to ChatGPT.
- Inserts the generated code snippets back into the code.
Requirements
- Visual Studio Code version 1.88.0 or higher.
- A valid OpenAI API key.
Installation
From the Visual Studio Code Marketplace
- Open Visual Studio Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing
Ctrl+Shift+X
.
- Search for "SenseiSnip".
- Click the
Install
button for the extension.
From a VSIX File
- Download the
.vsix
file from the Releases section of the GitHub repository or from the Visual Studio Code Marketplace.
- Open Visual Studio Code.
- Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing
Ctrl+Shift+X
.
- Click on the
...
icon at the top-right corner of the Extensions view, then select Install from VSIX...
.
- Select the downloaded
.vsix
file.
Configuration
- Obtain an API key from OpenAI by signing up on their.
- Open Visual Studio Code.
- Go to the Command Palette by pressing
Ctrl+Shift+P
.
- Select
Preferences: Open Settings (JSON)
.
- Add your OpenAI API key to your settings.json file:
{
"generatecode.apiKey": "YOUR_OPENAI_API_KEY"
}
Usage
Open a file in Visual Studio Code.
Ensure that the file contains strings in the format #your question?.
Go to the Command Palette by pressing Ctrl+Shift+P.
Run the command Generate Code
The extension will detect the strings, send them to ChatGPT, and insert the generated code snippets directly into your code.
Example
Consider the following code snippet:
Question :
-- # Write a Python code snippet using pandas to read an Excel file without instructions, just the code, put the code between those two strings : Code start, Code end?
-- After running the extension, the code snippet will be updated with the generated code:
import pandas as pd
# Read Excel file
df = pd.read_excel('file.xlsx')
# Display DataFrame
print(df)
Known Issues
The extension requires a stable internet connection to communicate with the OpenAI API.
The extension is limited by the rate limits and quota of the OpenAI API.
The limitations will be handled in future releases
Release Notes
1.0.3
Initial release of the SenseiSnip extension.
Contributing
If you would like to contribute to the development of this extension, please feel free to open an issue or submit a pull request on the GitHub repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Links
Explanation:
- Overview: A brief description of the extension.
- Features: Key functionalities of the extension.
- Requirements: Prerequisites for using the extension.
- Installation: Step-by-step instructions to install the extension either from the Marketplace or using a VSIX file.
- Configuration: Instructions on how to configure the extension, including setting up the OpenAI API key.
- Usage: Detailed steps on how to use the extension once it's installed and configured.
- Example: A practical example demonstrating the extension in action.
- Known Issues: Any known limitations or issues users might encounter.
- Release Notes: Information on the latest release and its features.
- Contributing: Information for potential contributors.
- License: Licensing information.
Enjoy!
IBC GROUP