• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-typescript-sdk-gen / 13155027420

05 Feb 2025 10:12AM UTC coverage: 42.622% (-0.006%) from 42.628%
13155027420

Pull #509

github

web-flow
Merge 697e537ab into 026c9372e
Pull Request #509: test: Fix flaky test in search module (box/box-codegen#659)

4052 of 16047 branches covered (25.25%)

Branch coverage included in aggregate %.

13 of 35 new or added lines in 3 files covered. (37.14%)

5 existing lines in 2 files now uncovered.

14323 of 27065 relevant lines covered (52.92%)

92.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.0
/src/schemas/aiAsk.generated.ts
1
import { serializeAiItemAsk } from './aiItemAsk.generated.js';
144✔
2
import { deserializeAiItemAsk } from './aiItemAsk.generated.js';
144✔
3
import { serializeAiDialogueHistory } from './aiDialogueHistory.generated.js';
144✔
4
import { deserializeAiDialogueHistory } from './aiDialogueHistory.generated.js';
144✔
5
import { serializeAiAgentAsk } from './aiAgentAsk.generated.js';
144✔
6
import { deserializeAiAgentAsk } from './aiAgentAsk.generated.js';
144✔
7
import { AiItemAsk } from './aiItemAsk.generated.js';
8
import { AiDialogueHistory } from './aiDialogueHistory.generated.js';
9
import { AiAgentAsk } from './aiAgentAsk.generated.js';
10
import { BoxSdkError } from '../box/errors.js';
144✔
11
import { SerializedData } from '../serialization/json.js';
12
import { sdIsEmpty } from '../serialization/json.js';
13
import { sdIsBoolean } from '../serialization/json.js';
144✔
14
import { sdIsNumber } from '../serialization/json.js';
15
import { sdIsString } from '../serialization/json.js';
144✔
16
import { sdIsList } from '../serialization/json.js';
144✔
17
import { sdIsMap } from '../serialization/json.js';
144✔
18
export type AiAskModeField = 'multiple_item_qa' | 'single_item_qa' | string;
19
export interface AiAsk {
20
  /**
21
   * The mode specifies if this request is for a single or multiple items. If you select `single_item_qa` the `items` array can have one element only. Selecting `multiple_item_qa` allows you to provide up to 25 items. */
22
  readonly mode: AiAskModeField;
23
  /**
24
   * The prompt provided by the client to be answered by the LLM. The prompt's length is limited to 10000 characters. */
25
  readonly prompt: string;
26
  /**
27
   * The items to be processed by the LLM, often files.
28
   *
29
   * **Note**: Box AI handles documents with text representations up to 1MB in size, or a maximum of 25 files, whichever comes first.
30
   * If the file size exceeds 1MB, the first 1MB of text representation will be processed.
31
   * If you set `mode` parameter to `single_item_qa`, the `items` array can have one element only.  */
32
  readonly items: readonly AiItemAsk[];
33
  /**
34
   * The history of prompts and answers previously passed to the LLM. This provides additional context to the LLM in generating the response. */
35
  readonly dialogueHistory?: readonly AiDialogueHistory[];
36
  /**
37
   * A flag to indicate whether citations should be returned. */
38
  readonly includeCitations?: boolean;
39
  readonly aiAgent?: AiAgentAsk;
40
  readonly rawData?: SerializedData;
41
}
42
export function serializeAiAskModeField(val: AiAskModeField): SerializedData {
144✔
43
  return val;
4✔
44
}
45
export function deserializeAiAskModeField(val: SerializedData): AiAskModeField {
144✔
46
  if (val == 'multiple_item_qa') {
×
47
    return val;
×
48
  }
49
  if (val == 'single_item_qa') {
×
50
    return val;
×
51
  }
52
  if (sdIsString(val)) {
×
53
    return val;
×
54
  }
55
  throw new BoxSdkError({ message: "Can't deserialize AiAskModeField" });
×
56
}
57
export function serializeAiAsk(val: AiAsk): SerializedData {
144✔
58
  return {
4✔
59
    ['mode']: serializeAiAskModeField(val.mode),
60
    ['prompt']: val.prompt,
61
    ['items']: val.items.map(function (item: AiItemAsk): SerializedData {
62
      return serializeAiItemAsk(item);
6✔
63
    }) as readonly any[],
64
    ['dialogue_history']:
65
      val.dialogueHistory == void 0
4!
66
        ? val.dialogueHistory
67
        : (val.dialogueHistory.map(function (
68
            item: AiDialogueHistory,
69
          ): SerializedData {
70
            return serializeAiDialogueHistory(item);
×
71
          }) as readonly any[]),
72
    ['include_citations']: val.includeCitations,
73
    ['ai_agent']:
74
      val.aiAgent == void 0 ? val.aiAgent : serializeAiAgentAsk(val.aiAgent),
4!
75
  };
76
}
77
export function deserializeAiAsk(val: SerializedData): AiAsk {
144✔
78
  if (!sdIsMap(val)) {
×
79
    throw new BoxSdkError({ message: 'Expecting a map for "AiAsk"' });
×
80
  }
81
  if (val.mode == void 0) {
×
82
    throw new BoxSdkError({
×
83
      message: 'Expecting "mode" of type "AiAsk" to be defined',
84
    });
85
  }
86
  const mode: AiAskModeField = deserializeAiAskModeField(val.mode);
×
87
  if (val.prompt == void 0) {
×
88
    throw new BoxSdkError({
×
89
      message: 'Expecting "prompt" of type "AiAsk" to be defined',
90
    });
91
  }
92
  if (!sdIsString(val.prompt)) {
×
93
    throw new BoxSdkError({
×
94
      message: 'Expecting string for "prompt" of type "AiAsk"',
95
    });
96
  }
97
  const prompt: string = val.prompt;
×
98
  if (val.items == void 0) {
×
99
    throw new BoxSdkError({
×
100
      message: 'Expecting "items" of type "AiAsk" to be defined',
101
    });
102
  }
103
  if (!sdIsList(val.items)) {
×
104
    throw new BoxSdkError({
×
105
      message: 'Expecting array for "items" of type "AiAsk"',
106
    });
107
  }
NEW
108
  const items: readonly AiItemAsk[] = sdIsList(val.items)
×
109
    ? (val.items.map(function (itm: SerializedData): AiItemAsk {
NEW
110
        return deserializeAiItemAsk(itm);
×
111
      }) as readonly any[])
112
    : [];
113
  if (!(val.dialogue_history == void 0) && !sdIsList(val.dialogue_history)) {
×
114
    throw new BoxSdkError({
×
115
      message: 'Expecting array for "dialogue_history" of type "AiAsk"',
116
    });
117
  }
118
  const dialogueHistory: undefined | readonly AiDialogueHistory[] =
119
    val.dialogue_history == void 0
×
120
      ? void 0
121
      : sdIsList(val.dialogue_history)
×
122
        ? (val.dialogue_history.map(function (
123
            itm: SerializedData,
124
          ): AiDialogueHistory {
125
            return deserializeAiDialogueHistory(itm);
×
126
          }) as readonly any[])
127
        : [];
128
  if (
×
129
    !(val.include_citations == void 0) &&
×
130
    !sdIsBoolean(val.include_citations)
131
  ) {
132
    throw new BoxSdkError({
×
133
      message: 'Expecting boolean for "include_citations" of type "AiAsk"',
134
    });
135
  }
136
  const includeCitations: undefined | boolean =
137
    val.include_citations == void 0 ? void 0 : val.include_citations;
×
138
  const aiAgent: undefined | AiAgentAsk =
139
    val.ai_agent == void 0 ? void 0 : deserializeAiAgentAsk(val.ai_agent);
×
140
  return {
×
141
    mode: mode,
142
    prompt: prompt,
143
    items: items,
144
    dialogueHistory: dialogueHistory,
145
    includeCitations: includeCitations,
146
    aiAgent: aiAgent,
147
  } satisfies AiAsk;
148
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc