This project automates the task of combining a base prompt from a prompt.txt
file with the contents of .txt
files from a folder and processes them using an AI API. The application preserves the folder's structure while unifying files within the same folder into three formats (.txt
, .odt
, and .md
). It also uses a securely stored API key for authentication.
- Prompt Automation: Combines a base prompt from
prompt.txt
with the contents of.txt
files in a folder. - Folder Structure Preservation: Retains the original folder hierarchy.
- Unified Outputs: Merges
.txt
files from the same folder into a single file in three formats:- Plain text (
.txt
) - OpenDocument Text (
.odt
) - Markdown (
.md
)
- Plain text (
- API Integration: Processes combined prompts using an AI API with secure authentication through a
.env
file.
Before running this project, ensure the following are installed:
- Python (>= 3.8)
- A valid API key for the Gemini or OpenAI service (stored in a
.env
file). - Pandoc for converting text to
.odt
and.md
.
- Clone the Repository
git clone https://github.com/Eclipse91/Automated-Prompt-Processing.git
- Navigate to the Project Directory
cd Automated-Prompt-Processing
- Install Pandoc Install Pandoc, which is required for file format conversions:
- Linux:
sudo apt install pandoc
- macOS:
brew install pandoc
- Windows:
Download the installer from the official Pandoc page or install via Chocolatey:choco install pandoc
-
Install the required dependencies (creating a virtual environment is strongly recommended):
pip install -r requirements.txt
-
Set Up the
.env
File Create a.env
file in the root directory with the following content:
API_KEY=your_api_key_here
- Prepare the
prompt.txt
File Create aprompt.txt
file containing the base prompt to be appended to all files. For example:
Please process the following content intelligently:
-
Add a folder with the files to elaborate Add a folder to the root directory containing the files to be processed.
-
Run the Application Run the main script:
python3 main.py
- Visit the Gemini API Signup Page.
- Log in or create a new account.
- Navigate to Settings > API Settings.
- Click Create a New API Key:
- Select appropriate permissions (e.g., read-only, trading).
- Assign the API key to a specific scope or sub-account, if required.
- Confirm the request via Gemini’s two-factor authentication (2FA).
- Copy and securely store the generated API key.
- Entry point of the application.
- Iterates through the
input_folder
directory. - Calls
ai_automation.py
for prompt processing andtoODT.py
for file format conversions.
- Reads the API key from
.env
. - Combines
prompt.txt
with the contents of.txt
files in each folder. - Sends the combined text to the AI API and processes the response.
- Converts
.md
files into.odt
formats using Pandoc. - Ensures compatibility with tools like LibreOffice and Microsoft Word.
- Securely stores the API key for accessing the AI API.
- Contains the base prompt text to be appended to all the text in the files.
- Input Folder Structure:
├── input_folder/ │ ├── folder1/ │ │ ├── file1.txt │ │ └── file2.txt │ ├── folder2/ │ │ └── file3.txt
- Base Prompt (
prompt.txt
):Please process the following content intelligently:
- Output Folder Structure (after running
main.py
):├──output_folder/ │ ├── folder1/ │ │ ├── file1.txt │ │ └── file2.txt │ ├── folder2/ │ │ └── file3.txt | ├── folder1.odt │ ├── folder1.md │ ├── folder1.txt │ ├── folder2.odt │ ├── folder2.md │ ├── folder2.txt
- Input files must be in
.txt
format. - Customize the
prompt.txt
file before running the script to suit your processing requirements. - Ensure the
.env
file contains a valid API key.
This project is licensed under the GNU General Public License. See the LICENSE file for more details.