Skip to content

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.

index.js
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);
ParameterDescription
actionsAn array of supported prompt actions. If not provided, all actions are supported. Available action types: pre_translate, assist, qa_check, custom:type-of-action.
formSchemaReact JSON Schema for the form.

Used to generate prompts based on the options and payload provided.

  • options - Options selected by the user.
  • payload - Data provided by the AI provider.
  • client - Crowdin API client.
  • context - Context object.

The function should return the prompt text.