The ChatGPT Connector
Overview
The ChatGPT Connector enables integration with the ChatGPT API for automated translation requests. This connector is provided as part of the Translations Addon and allows you to send translation prompts directly to ChatGPT.
Prerequisites
- Access to a ChatGPT API account.
- The
translations-addon-connector-chatgptdependency added to your project. For installation instructions, see the installation page.
Configuration
You can configure the ChatGPT Connector using environment variables, system properties, or JCR properties. Environment variables are recommended for managing sensitive information.
Environment Variables
Set the following environment variables to configure the connector without storing values in the JCR:
| Property | Environment Variable | Spring AI Fallback |
|---|---|---|
| chatgpt.api.key | CHATGPT_API_KEY | SPRING_AI_OPENAI_API_KEY |
| chatgpt.api.url | CHATGPT_API_URL | SPRING_AI_OPENAI_API_URL |
| chatgpt.api.model | CHATGPT_API_MODEL | SPRING_AI_OPENAI_CHAT_OPTIONS_MODEL |
If these environment variables are not set, the connector will use system properties. If neither are set, the connector will retrieve values from the JCR.
JCR Configuration
You can also configure the connector directly in the JCR under the translationsaddon:connector node. The following properties are available:
| String Property | Default Value | Description |
|---|---|---|
| chatgpt.api.key | API key | |
| chatgpt.api.url | https://api.openai.com/v1/chat/completions | URL for sending requests |
| chatgpt.api.model | gpt-3.5-turbo | Model used for processing translation prompts |
Enable the Translation Results Processor Scheduler
To ensure that translation results are imported into the repository, enable the translation results processing scheduler job. This job pulls completed translations from the remote service.
- Navigate to the following JCR node:
/hippo:configuration/hippo:modules/scheduler/hippo:moduleconfig/translationsaddon/TranslationResultsProcessor/hipposched:triggers/every-minute
- Set the
hipposched:enabledproperty totrue. - Save your changes.
You can adjust the polling interval by modifying the hipposched:cronExpression property. For more details, see the configuration page.
Verification
After configuration, verify that translation prompts are sent to ChatGPT and that results are imported into the repository according to the scheduler settings.