UNPKG

box-typescript-sdk-gen

Version:
72 lines (71 loc) 2.71 kB
import { serializeAiLlmEndpointParams } from './aiLlmEndpointParams.generated.js'; import { deserializeAiLlmEndpointParams } from './aiLlmEndpointParams.generated.js'; import { AiLlmEndpointParams } from './aiLlmEndpointParams.generated.js'; import { BoxSdkError } from '../box/errors.js'; import { SerializedData } from '../serialization/json.js'; import { sdIsEmpty } from '../serialization/json.js'; import { sdIsBoolean } from '../serialization/json.js'; import { sdIsNumber } from '../serialization/json.js'; import { sdIsString } from '../serialization/json.js'; import { sdIsList } from '../serialization/json.js'; import { sdIsMap } from '../serialization/json.js'; export interface AiAgentBasicTextToolBase { /** * The model used for the AI agent for basic text. For specific model values, see the [available models list](g://box-ai/supported-models). */ readonly model?: string; /** * The number of tokens for completion. */ readonly numTokensForCompletion?: number; readonly llmEndpointParams?: AiLlmEndpointParams; readonly rawData?: SerializedData; } export function serializeAiAgentBasicTextToolBase( val: AiAgentBasicTextToolBase, ): SerializedData { return { ['model']: val.model, ['num_tokens_for_completion']: val.numTokensForCompletion, ['llm_endpoint_params']: val.llmEndpointParams == void 0 ? val.llmEndpointParams : serializeAiLlmEndpointParams(val.llmEndpointParams), }; } export function deserializeAiAgentBasicTextToolBase( val: SerializedData, ): AiAgentBasicTextToolBase { if (!sdIsMap(val)) { throw new BoxSdkError({ message: 'Expecting a map for "AiAgentBasicTextToolBase"', }); } if (!(val.model == void 0) && !sdIsString(val.model)) { throw new BoxSdkError({ message: 'Expecting string for "model" of type "AiAgentBasicTextToolBase"', }); } const model: undefined | string = val.model == void 0 ? void 0 : val.model; if ( !(val.num_tokens_for_completion == void 0) && !sdIsNumber(val.num_tokens_for_completion) ) { throw new BoxSdkError({ message: 'Expecting number for "num_tokens_for_completion" of type "AiAgentBasicTextToolBase"', }); } const numTokensForCompletion: undefined | number = val.num_tokens_for_completion == void 0 ? void 0 : val.num_tokens_for_completion; const llmEndpointParams: undefined | AiLlmEndpointParams = val.llm_endpoint_params == void 0 ? void 0 : deserializeAiLlmEndpointParams(val.llm_endpoint_params); return { model: model, numTokensForCompletion: numTokensForCompletion, llmEndpointParams: llmEndpointParams, } satisfies AiAgentBasicTextToolBase; }