UNPKG

box-node-sdk

Version:

Official SDK for Box Plaform APIs

66 lines 3.09 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; const url_path_1 = __importDefault(require("../util/url-path")); /** */ class AIManager { /** * @param {BoxClient} client The Box API Client that is responsible for making calls to the API */ constructor(client) { this.client = client; } /** * Send AI question request * * Sends an AI request to supported LLMs and returns an answer specifically focused on the user's question given the provided context. * @param {schemas.AiAsk} body * @param {object} [options] Options for the request * @param {Function} [callback] Passed the result if successful, error otherwise * @returns {Promise<schemas.AiResponseFull>} A promise resolving to the result or rejecting with an error */ ask(body, options, callback) { const { ...queryParams } = options, apiPath = (0, url_path_1.default)('ai', 'ask'), params = { qs: queryParams, body: body, }; return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback); } /** * Send AI request to generate text * * Sends an AI request to supported LLMs and returns an answer specifically focused on the creation of new text. * @param {schemas.AiTextGen} body * @param {object} [options] Options for the request * @param {Function} [callback] Passed the result if successful, error otherwise * @returns {Promise<schemas.AiResponse>} A promise resolving to the result or rejecting with an error */ textGen(body, options, callback) { const { ...queryParams } = options, apiPath = (0, url_path_1.default)('ai', 'text_gen'), params = { qs: queryParams, body: body, }; return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback); } /** * Get AI agent default configuration * * Get the AI agent default config * @param {object} options Options for the request * @param {"ask" | "text_gen"} options.mode The mode to filter the agent config to return. * @param {string} [options.language] The ISO language code to return the agent config for. If the language is not supported the default agent config is returned. * @param {string} [options.model] The model to return the default agent config for. * @param {Function} [callback] Passed the result if successful, error otherwise * @returns {Promise<schemas.AiAgentAsk | schemas.AiAgentTextGen>} A promise resolving to the result or rejecting with an error */ getAiAgentDefaultConfig(options, callback) { const { ...queryParams } = options, apiPath = (0, url_path_1.default)('ai_agent_default'), params = { qs: queryParams, }; return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback); } } module.exports = AIManager; //# sourceMappingURL=ai.generated.js.map