AI Prompt Provider
The AI Prompt Provider module is designed to streamline the process of generating prompts for both custom and natively supported AI providers.
AI Prompt Provider Module Read more on the Crowdin Developer Portal.
Sample
Section titled “Sample”const crowdinModule = require('@crowdin/app-project-module');const {PromptActions} = require("@crowdin/app-project-module/out/modules/ai-prompt-provider/types");
const configuration = { baseUrl: 'https://123.ngrok.io', clientId: 'clientId', clientSecret: 'clientSecret', name: 'Sample App', identifier: 'sample-app', description: 'Sample App description', dbFolder: __dirname, imagePath: __dirname + '/' + 'logo.png', aiPromptProvider: { actions: [PromptActions.PRE_TRANSLATE], formSchema: { type: "object", properties: { firstOption: { title: "Option 1", type: "string" } }, required: ['firstOption'] }, compile: async function(options, payload, client, context, requestData) { return 'Prompt text compiled based on options and payload'; } }};
crowdinModule.createApp(configuration);Configuration
Section titled “Configuration”| Parameter | Description |
|---|---|
actions | An array of supported prompt actions. If not provided, all actions are supported. Available action types: pre_translate, assist, qa_check, custom:type-of-action. |
formSchema | React JSON Schema for the form. |
compile Function
Section titled “compile Function”Used to generate prompts based on the options and payload provided.
Parameters
Section titled “Parameters”options- Options selected by the user.payload- Data provided by the AI provider.client- Crowdin API client.context- Context object.
Return Value
Section titled “Return Value”The function should return the prompt text.