@squidcloud/client 1.0.121 → 1.0.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -32247,8 +32247,8 @@ class AiAssistantClient {
32247
32247
  return new AiAssistantProfileReference(this, this.integrationId, id);
32248
32248
  }
32249
32249
  /** @internal */
32250
- async mutate(request) {
32251
- await this.rpcManager.post('ai/assistant/mutate', request);
32250
+ async mutate(request, file) {
32251
+ await this.rpcManager.post('ai/assistant/mutate', request, file ? [file] : []);
32252
32252
  }
32253
32253
  /**
32254
32254
  * Sends a prompt to the specified profile id.
@@ -32432,7 +32432,7 @@ class AiAssistantContextReference {
32432
32432
  * @param data.context - The context data.
32433
32433
  * @returns A promise that resolves when the context is successfully created.
32434
32434
  */
32435
- insert(data) {
32435
+ insert(data, file) {
32436
32436
  const { title, context } = data;
32437
32437
  const request = {
32438
32438
  type: 'insert',
@@ -32445,7 +32445,7 @@ class AiAssistantContextReference {
32445
32445
  context,
32446
32446
  },
32447
32447
  };
32448
- return this.client.mutate(request);
32448
+ return this.client.mutate(request, file);
32449
32449
  }
32450
32450
  /**
32451
32451
  * Updates an existing context entry on the assistant profile. This will result in an error if an entry has not yet
@@ -48547,23 +48547,38 @@ class RpcManager {
48547
48547
  async ready() {
48548
48548
  await this.authManager.waitForReadyState();
48549
48549
  }
48550
- async post(path, message) {
48550
+ async post(path, message, files = []) {
48551
48551
  this.onGoingRpcCounter.next(this.onGoingRpcCounter.value + 1);
48552
48552
  try {
48553
48553
  await (0,external_rxjs_namespaceObject.firstValueFrom)((0,external_rxjs_namespaceObject.from)(this.ready()).pipe((0,external_rxjs_namespaceObject.timeout)(20000)));
48554
- let headers = {
48555
- 'Content-Type': 'application/json',
48556
- };
48554
+ let headers = {};
48557
48555
  if (Object.keys(this.staticHeaders)) {
48558
48556
  headers = Object.assign(Object.assign({}, headers), this.staticHeaders);
48559
48557
  }
48560
48558
  DebugLogger.debug(`sending request: path: ${path} message: ${JSON.stringify(message)}`);
48561
48559
  const url = getApplicationUrl(this.region, this.appId, path);
48562
- const response = await external_cross_fetch_default()(url, {
48563
- method: 'POST',
48564
- body: serialization_serializeObj(message),
48565
- headers: headers,
48566
- });
48560
+ let response;
48561
+ if (files.length) {
48562
+ const formData = new FormData();
48563
+ files.forEach((file) => {
48564
+ formData.append('files', file);
48565
+ });
48566
+ formData.append('body', serialization_serializeObj(message));
48567
+ // Make the fetch call
48568
+ response = await external_cross_fetch_default()(url, {
48569
+ method: 'POST',
48570
+ body: formData,
48571
+ headers,
48572
+ });
48573
+ }
48574
+ else {
48575
+ headers['Content-Type'] = 'application/json';
48576
+ response = await external_cross_fetch_default()(url, {
48577
+ method: 'POST',
48578
+ body: serialization_serializeObj(message),
48579
+ headers,
48580
+ });
48581
+ }
48567
48582
  const parsedResponse = await this.parseResponse(response);
48568
48583
  DebugLogger.debug(`received response: ${JSON.stringify(parsedResponse)}`);
48569
48584
  return parsedResponse;
@@ -1,6 +1,6 @@
1
1
  /** The supported Open AI model names. */
2
2
  export type OpenAiModelName = 'gpt-3.5-turbo' | 'gpt-4';
3
- export type AiAssistantContextType = 'text' | 'url';
3
+ export type AiAssistantContextType = 'text' | 'url' | 'file';
4
4
  export interface AiAssistantTextContext {
5
5
  type: 'text';
6
6
  data: string;
@@ -9,4 +9,8 @@ export interface AiAssistantUrlContext {
9
9
  type: 'url';
10
10
  data: string;
11
11
  }
12
- export type AiAssistantContext = AiAssistantTextContext | AiAssistantUrlContext;
12
+ export interface AiAssistantFileContext {
13
+ type: 'file';
14
+ data: string;
15
+ }
16
+ export type AiAssistantContext = AiAssistantTextContext | AiAssistantUrlContext | AiAssistantFileContext;
@@ -111,7 +111,7 @@ declare class AiAssistantContextReference {
111
111
  insert(data: {
112
112
  title: string;
113
113
  context: AiAssistantContext;
114
- }): Promise<void>;
114
+ }, file?: File): Promise<void>;
115
115
  /**
116
116
  * Updates an existing context entry on the assistant profile. This will result in an error if an entry has not yet
117
117
  * been created for the current context id.
@@ -15,7 +15,7 @@ export declare class RpcManager {
15
15
  deleteStaticHeader(key: string): void;
16
16
  getStaticHeaders(): Record<string, string>;
17
17
  private ready;
18
- post<T>(path: string, message: any): Promise<T>;
18
+ post<T>(path: string, message: any, files?: File[]): Promise<T>;
19
19
  private parseResponse;
20
20
  }
21
21
  export declare class RpcError extends Error {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.121",
3
+ "version": "1.0.122",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/typescript-client/src/index.d.ts",