An AI code writer application using OpenAI APIs for audio transcription and chat completion.
When running this application, the files and directories in the current working directory will be sent to OpenAI for processing. See more in the filters section to know which files are involved.
The application uses the following filters for file collection and monitoring, which can be configured via environment variables:
- Include Patterns:
INCLUDE_PATTERNS
(default:*.ts,*.json,*.yml,*.yaml,*.md,*.js,.env.dist
) - Exclude Directories:
EXCLUDE_DIRS
(default:node_modules,build,dist,.git
) - Exclude Files:
EXCLUDE_FILES
(default:package-lock.json,.*
)
In addition to the mandatory OPENAI_API_KEY
, the application supports several optional environment variables:
- OPENAI_API_ORG: Your OpenAI organization ID (if applicable).
- OPENAI_AUDIO_TEMPERATURE: The temperature setting for audio transformations (default:
0.1
). - OPENAI_CHAT_TEMPERATURE: The temperature setting for chat completions (default:
0.75
). - INCLUDE_PATTERNS: Patterns for files to include in processing (
default:
*.ts,*.json,*.yml,*.yaml,*.md,*.js,.env.dist
). - EXCLUDE_DIRS: Directories to exclude from processing (default:
node_modules,build,dist,.git
). - EXCLUDE_FILES: Files to exclude from processing (default:
package-lock.json,.?*
). - DEBUG_TO_FILE: If set to
true
, logs the conversation to a file (default:false
). - OPENAI_CHAT_MODEL: The model to be used for chat completions (default:
gpt-4o
).
- SOX (Sound eXchange): This application requires SOX for audio recording. Install SOX via your package manager:
- macOS:
brew install sox
- Windows: Download the installer from the official website
- Linux: Use your distribution's package manager, e.g.,
apt-get install sox
- macOS:
npx ai-code-writer
-
Starting the Application:
- Ensure that the environment variable
OPENAI_API_KEY
is set. - Optionally, set the filter environment variables as described in the "Optional Environment Variables" section.
- Start the application with the command
npx ai-code-writer
.
- Ensure that the environment variable
-
Interaction:
- After starting the application, a welcome message will be played: "The AI Code Writer is ready."
- Speak your input into the microphone. The application will record your speech and convert it to text.
-
Conversation:
- The transcribed input will be sent to the OpenAI API to get a response.
- The AI's response will be read out loud and displayed on the console.
- If the response contains file tasks (e.g., create, move, delete files), these will be executed automatically.
-
File Monitoring:
- Changes to the monitored files will be detected and recorded in the conversation history.
- These changes can influence the AI's responses.
-
Ending the Application:
- The application runs in an infinite loop waiting for user input.
- To end the application, use the usual methods to stop a Node.js process (e.g.,
Ctrl+C
in the console).
MIT - LICENSE
Endre Bock