UNPKG

@crowdin/app-project-module

Version:

Module that generates for you all common endpoints for serving standalone Crowdin App

64 lines (63 loc) 1.57 kB
import { CrowdinClientRequest, CrowdinContextInfo, Environments, ModuleKey, UiModule } from '../../types'; import Crowdin from '@crowdin/crowdin-api-client'; export interface AiToolWidget extends BaseAiTool, UiModule { } export interface AiTool extends BaseAiTool, ModuleKey { /** * function to handle requests */ toolCalls: (options: AiToolArguments) => Promise<AiToolResponse>; } interface BaseAiTool extends Environments { /** * Tool type, default is 'function' */ toolType: string; /** * describe function object */ function: AiToolFunction; } interface AiToolFunction { /** * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes. */ name: string; /** * A description of what the function does, used by the AI model to choose when and how to call the function. */ description: string; /** * Describe as a JSON Schema object */ parameters?: { type: string; properties: object; required?: string[]; }; } interface AiToolArguments { client: Crowdin; args: object | null; projectId: number; payload: AiToolPayload; context: CrowdinContextInfo; request: CrowdinClientRequest; } interface AiToolPayload { function: { name: string; arguments: string; }; organization: { [key: string]: any; }; project: { [key: string]: any; }; } interface AiToolResponse { content: string | object; error?: string; } export {};