|
| 1 | +import { BoxSdkError } from '../box/errors.js'; |
| 2 | +import { SerializedData } from '../serialization/json.js'; |
| 3 | +import { sdIsEmpty } from '../serialization/json.js'; |
| 4 | +import { sdIsBoolean } from '../serialization/json.js'; |
| 5 | +import { sdIsNumber } from '../serialization/json.js'; |
| 6 | +import { sdIsString } from '../serialization/json.js'; |
| 7 | +import { sdIsList } from '../serialization/json.js'; |
| 8 | +import { sdIsMap } from '../serialization/json.js'; |
| 9 | +export type AiLlmEndpointParamsAwsTypeField = 'aws_params'; |
| 10 | +export class AiLlmEndpointParamsAws { |
| 11 | + /** |
| 12 | + * The type of the AI LLM endpoint params object for AWS. |
| 13 | + * This parameter is **required**. */ |
| 14 | + readonly type: AiLlmEndpointParamsAwsTypeField = |
| 15 | + 'aws_params' as AiLlmEndpointParamsAwsTypeField; |
| 16 | + /** |
| 17 | + * What sampling temperature to use, between 0 and 1. Higher values like 0.8 will make the output more random, |
| 18 | + * while lower values like 0.2 will make it more focused and deterministic. |
| 19 | + * We generally recommend altering this or `top_p` but not both. */ |
| 20 | + readonly temperature?: number; |
| 21 | + /** |
| 22 | + * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results |
| 23 | + * of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability |
| 24 | + * mass are considered. We generally recommend altering this or temperature but not both. */ |
| 25 | + readonly topP?: number; |
| 26 | + readonly rawData?: SerializedData; |
| 27 | + constructor( |
| 28 | + fields: Omit<AiLlmEndpointParamsAws, 'type'> & |
| 29 | + Partial<Pick<AiLlmEndpointParamsAws, 'type'>> |
| 30 | + ) { |
| 31 | + if (fields.type) { |
| 32 | + this.type = fields.type; |
| 33 | + } |
| 34 | + if (fields.temperature) { |
| 35 | + this.temperature = fields.temperature; |
| 36 | + } |
| 37 | + if (fields.topP) { |
| 38 | + this.topP = fields.topP; |
| 39 | + } |
| 40 | + if (fields.rawData) { |
| 41 | + this.rawData = fields.rawData; |
| 42 | + } |
| 43 | + } |
| 44 | +} |
| 45 | +export interface AiLlmEndpointParamsAwsInput { |
| 46 | + /** |
| 47 | + * The type of the AI LLM endpoint params object for AWS. |
| 48 | + * This parameter is **required**. */ |
| 49 | + readonly type?: AiLlmEndpointParamsAwsTypeField; |
| 50 | + /** |
| 51 | + * What sampling temperature to use, between 0 and 1. Higher values like 0.8 will make the output more random, |
| 52 | + * while lower values like 0.2 will make it more focused and deterministic. |
| 53 | + * We generally recommend altering this or `top_p` but not both. */ |
| 54 | + readonly temperature?: number; |
| 55 | + /** |
| 56 | + * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results |
| 57 | + * of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability |
| 58 | + * mass are considered. We generally recommend altering this or temperature but not both. */ |
| 59 | + readonly topP?: number; |
| 60 | + readonly rawData?: SerializedData; |
| 61 | +} |
| 62 | +export function serializeAiLlmEndpointParamsAwsTypeField( |
| 63 | + val: AiLlmEndpointParamsAwsTypeField |
| 64 | +): SerializedData { |
| 65 | + return val; |
| 66 | +} |
| 67 | +export function deserializeAiLlmEndpointParamsAwsTypeField( |
| 68 | + val: SerializedData |
| 69 | +): AiLlmEndpointParamsAwsTypeField { |
| 70 | + if (val == 'aws_params') { |
| 71 | + return val; |
| 72 | + } |
| 73 | + throw new BoxSdkError({ |
| 74 | + message: "Can't deserialize AiLlmEndpointParamsAwsTypeField", |
| 75 | + }); |
| 76 | +} |
| 77 | +export function serializeAiLlmEndpointParamsAws( |
| 78 | + val: AiLlmEndpointParamsAws |
| 79 | +): SerializedData { |
| 80 | + return { |
| 81 | + ['type']: serializeAiLlmEndpointParamsAwsTypeField(val.type), |
| 82 | + ['temperature']: val.temperature == void 0 ? void 0 : val.temperature, |
| 83 | + ['top_p']: val.topP == void 0 ? void 0 : val.topP, |
| 84 | + }; |
| 85 | +} |
| 86 | +export function deserializeAiLlmEndpointParamsAws( |
| 87 | + val: SerializedData |
| 88 | +): AiLlmEndpointParamsAws { |
| 89 | + if (!sdIsMap(val)) { |
| 90 | + throw new BoxSdkError({ |
| 91 | + message: 'Expecting a map for "AiLlmEndpointParamsAws"', |
| 92 | + }); |
| 93 | + } |
| 94 | + if (val.type == void 0) { |
| 95 | + throw new BoxSdkError({ |
| 96 | + message: |
| 97 | + 'Expecting "type" of type "AiLlmEndpointParamsAws" to be defined', |
| 98 | + }); |
| 99 | + } |
| 100 | + const type: AiLlmEndpointParamsAwsTypeField = |
| 101 | + deserializeAiLlmEndpointParamsAwsTypeField(val.type); |
| 102 | + if (!(val.temperature == void 0) && !sdIsNumber(val.temperature)) { |
| 103 | + throw new BoxSdkError({ |
| 104 | + message: |
| 105 | + 'Expecting number for "temperature" of type "AiLlmEndpointParamsAws"', |
| 106 | + }); |
| 107 | + } |
| 108 | + const temperature: undefined | number = |
| 109 | + val.temperature == void 0 ? void 0 : val.temperature; |
| 110 | + if (!(val.top_p == void 0) && !sdIsNumber(val.top_p)) { |
| 111 | + throw new BoxSdkError({ |
| 112 | + message: 'Expecting number for "top_p" of type "AiLlmEndpointParamsAws"', |
| 113 | + }); |
| 114 | + } |
| 115 | + const topP: undefined | number = val.top_p == void 0 ? void 0 : val.top_p; |
| 116 | + return { |
| 117 | + type: type, |
| 118 | + temperature: temperature, |
| 119 | + topP: topP, |
| 120 | + } satisfies AiLlmEndpointParamsAws; |
| 121 | +} |
| 122 | +export function serializeAiLlmEndpointParamsAwsInput( |
| 123 | + val: AiLlmEndpointParamsAwsInput |
| 124 | +): SerializedData { |
| 125 | + return { |
| 126 | + ['type']: |
| 127 | + val.type == void 0 |
| 128 | + ? void 0 |
| 129 | + : serializeAiLlmEndpointParamsAwsTypeField(val.type), |
| 130 | + ['temperature']: val.temperature == void 0 ? void 0 : val.temperature, |
| 131 | + ['top_p']: val.topP == void 0 ? void 0 : val.topP, |
| 132 | + }; |
| 133 | +} |
| 134 | +export function deserializeAiLlmEndpointParamsAwsInput( |
| 135 | + val: SerializedData |
| 136 | +): AiLlmEndpointParamsAwsInput { |
| 137 | + if (!sdIsMap(val)) { |
| 138 | + throw new BoxSdkError({ |
| 139 | + message: 'Expecting a map for "AiLlmEndpointParamsAwsInput"', |
| 140 | + }); |
| 141 | + } |
| 142 | + const type: undefined | AiLlmEndpointParamsAwsTypeField = |
| 143 | + val.type == void 0 |
| 144 | + ? void 0 |
| 145 | + : deserializeAiLlmEndpointParamsAwsTypeField(val.type); |
| 146 | + if (!(val.temperature == void 0) && !sdIsNumber(val.temperature)) { |
| 147 | + throw new BoxSdkError({ |
| 148 | + message: |
| 149 | + 'Expecting number for "temperature" of type "AiLlmEndpointParamsAwsInput"', |
| 150 | + }); |
| 151 | + } |
| 152 | + const temperature: undefined | number = |
| 153 | + val.temperature == void 0 ? void 0 : val.temperature; |
| 154 | + if (!(val.top_p == void 0) && !sdIsNumber(val.top_p)) { |
| 155 | + throw new BoxSdkError({ |
| 156 | + message: |
| 157 | + 'Expecting number for "top_p" of type "AiLlmEndpointParamsAwsInput"', |
| 158 | + }); |
| 159 | + } |
| 160 | + const topP: undefined | number = val.top_p == void 0 ? void 0 : val.top_p; |
| 161 | + return { |
| 162 | + type: type, |
| 163 | + temperature: temperature, |
| 164 | + topP: topP, |
| 165 | + } satisfies AiLlmEndpointParamsAwsInput; |
| 166 | +} |
0 commit comments