@squidcloud/client 1.0.144-beta → 1.0.145-beta

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.
@@ -1,5 +1,6 @@
1
1
  /** The supported AI model names. */
2
- export type AiModelName = 'gpt-3.5-turbo' | 'gpt-4' | 'claude-2' | 'gpt-4-1106-preview';
2
+ export declare const AI_MODEL_NAMES: readonly ["gpt-3.5-turbo", "gpt-4", "claude-2", "gpt-4-1106-preview"];
3
+ export type AiModelName = (typeof AI_MODEL_NAMES)[number];
3
4
  /** The possible sources for the LLM provider API key. */
4
5
  export type ApiKeySource = 'user' | 'system';
5
6
  export type AiChatbotContextType = 'text' | 'url' | 'file';
@@ -21,5 +22,6 @@ export interface AiChatbotChatOptions {
21
22
  maxTokens?: number;
22
23
  chatId?: string;
23
24
  disableHistory?: boolean;
25
+ includeReference?: boolean;
24
26
  }
25
27
  export {};
@@ -1,11 +1,73 @@
1
1
  import { RpcManager } from './rpc.manager';
2
2
  import { AssistantToolType, FunctionName } from '@squidcloud/common';
3
+ import { BlobAndFilename } from './types';
4
+ /**
5
+ * Client class for interacting with an AI Assistant server.
6
+ * Provides functionalities like creating and deleting assistants and threads,
7
+ * querying assistants, and managing files associated with assistants and threads.
8
+ */
3
9
  export declare class AiAssistantClient {
4
10
  private readonly rpcManager;
5
11
  constructor(rpcManager: RpcManager);
12
+ /**
13
+ * Creates a new AI assistant with specified characteristics.
14
+ * @param name - The name of the assistant.
15
+ * @param instructions - Instructions for the assistant.
16
+ * @param functions - Array of function names annotated with "@aiFunction" in your Squid backend that will be
17
+ * available tol the assistant.
18
+ * @param toolTypes - Optional array of tool types. If you want to use files for retrieval, you must add them using
19
+ * the addFileToAssistant method.
20
+ * @returns A promise that resolves to the created assistant's ID.
21
+ */
6
22
  createAssistant(name: string, instructions: string, functions: Array<FunctionName>, toolTypes?: Array<AssistantToolType>): Promise<string>;
23
+ /**
24
+ * Deletes an AI assistant.
25
+ * @param assistantId - The ID of the assistant to be deleted.
26
+ * @returns A promise that resolves when the assistant is deleted.
27
+ */
7
28
  deleteAssistant(assistantId: string): Promise<void>;
29
+ /**
30
+ * Creates a new thread for an AI assistant. A thread is a long-lived conversation with the assistant that you can
31
+ * always send questions to.
32
+ * @param assistantId - The ID of the assistant for which the thread is created.
33
+ * @returns A promise that resolves to the created thread's ID.
34
+ */
8
35
  createThread(assistantId: string): Promise<string>;
36
+ /**
37
+ * Deletes a thread of an AI assistant.
38
+ * @param threadId - The ID of the thread to be deleted.
39
+ * @returns A promise that resolves when the thread is deleted.
40
+ */
9
41
  deleteThread(threadId: string): Promise<void>;
10
- queryAssistant(assistantId: string, threadId: string, prompt: string, fileContent?: string): Promise<string>;
42
+ /**
43
+ * Queries an AI assistant within a specific thread.
44
+ * @param assistantId - The ID of the assistant.
45
+ * @param threadId - The ID of the thread.
46
+ * @param prompt - The query prompt.
47
+ * @param fileIds - Optional array of file IDs to include in the query. These file IDs need to be added using the
48
+ * addFileToThread method.
49
+ * @returns A promise that resolves to the assistant's response.
50
+ */
51
+ queryAssistant(assistantId: string, threadId: string, prompt: string, fileIds?: string[]): Promise<string>;
52
+ /**
53
+ * Adds a file to an AI assistant that can be available for retrieval or code analyzer.
54
+ * @param assistantId - The ID of the assistant.
55
+ * @param file - The file or blob and filename to be added.
56
+ * @returns A promise that resolves to the ID of the added file.
57
+ */
58
+ addFileToAssistant(assistantId: string, file: File | BlobAndFilename): Promise<string>;
59
+ /**
60
+ * Removes a file from an AI assistant.
61
+ * @param assistantId - The ID of the assistant.
62
+ * @param fileId - The ID of the file to be removed.
63
+ * @returns A promise that resolves when the file is removed.
64
+ */
65
+ removeFileFromAssistant(assistantId: string, fileId: string): Promise<void>;
66
+ /**
67
+ * Adds a file to a specific thread of an AI assistant. These files can be used when asking a question in the thread.
68
+ * @param threadId - The ID of the thread.
69
+ * @param file - The file or blob and filename to be added.
70
+ * @returns A promise that resolves to the ID of the added file.
71
+ */
72
+ addFileToThread(threadId: string, file: File | BlobAndFilename): Promise<string>;
11
73
  }
@@ -1,5 +1,3 @@
1
- import { IntegrationId } from '@squidcloud/common';
2
- import { AiChatbotClient } from './ai-chatbot-client';
3
1
  import { RpcManager } from './rpc.manager';
4
2
  import { SocketManager } from './socket.manager';
5
3
  export declare class AiChatbotClientFactory {
@@ -7,5 +5,4 @@ export declare class AiChatbotClientFactory {
7
5
  private readonly socketManager;
8
6
  private readonly chatbotsMap;
9
7
  constructor(rpcManager: RpcManager, socketManager: SocketManager);
10
- getChatbot(integrationId: IntegrationId): AiChatbotClient;
11
8
  }
@@ -12,12 +12,26 @@ export interface ExecuteAiQueryResponse {
12
12
  explanation?: string;
13
13
  executedQuery?: string;
14
14
  }
15
+ /**
16
+ * AiClient class serves as a facade for interacting with different AI services.
17
+ * It provides simplified access to AI chatbot and assistant functionalities
18
+ * through its methods.
19
+ */
15
20
  export declare class AiClient {
16
21
  private readonly aiChatbotClientFactory;
17
22
  private readonly rpcManager;
18
23
  private readonly aiAssistantClient;
19
24
  constructor(aiChatbotClientFactory: AiChatbotClientFactory, rpcManager: RpcManager);
20
- chatbot(integrationId: IntegrationId): AiChatbotClient;
25
+ /**
26
+ * Retrieves an AI chatbot client for a specific AI integration.
27
+ * @param aiIntegrationId - The identifier for the AI integration.
28
+ * @returns An instance of AiChatbotClient associated with the given AI integration ID.
29
+ */
30
+ chatbot(aiIntegrationId: IntegrationId): AiChatbotClient;
31
+ /**
32
+ * Retrieves the AI assistant client.
33
+ * @returns An instance of AiAssistantClient.
34
+ */
21
35
  assistant(): AiAssistantClient;
22
36
  /**
23
37
  * Executes an AI query using a specific DB integration, sending a prompt to the AI and returning its response.
@@ -1,5 +1,4 @@
1
1
  import { ApiKey, AuthToken, IntegrationId } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
2
  import { SquidAuthProvider } from './squid';
4
3
  /** Holds authentication token for the specified integration. */
5
4
  export interface AuthData {
@@ -10,12 +9,6 @@ export declare class AuthManager {
10
9
  private readonly apiKey;
11
10
  private authProvider?;
12
11
  constructor(apiKey: ApiKey | undefined, authProvider?: SquidAuthProvider | undefined);
13
- /**
14
- * Sets a new ID token or an ID token provider.
15
- * @deprecated: Pass the provider via constructor options parameters or `setAuthTokenProvider()`.
16
- */
17
- setAuthIdToken(tokenArg: string | undefined | Promise<string | undefined> | Observable<string | undefined> | SquidAuthProvider, integrationId?: IntegrationId): void;
18
- private setAuthProviderForDeprecatedCode;
19
12
  /**
20
13
  * Sets a new auth-token provider to Squid.
21
14
  * All future squid backend requests will use this token provider.
@@ -2,6 +2,7 @@ import { SupportedSquidRegion } from '@squidcloud/common';
2
2
  import { AuthManager } from './auth.manager';
3
3
  import { ClientIdService } from './client-id.service';
4
4
  import { DestructManager } from './destruct.manager';
5
+ import { BlobAndFilename } from './types';
5
6
  export declare class RpcManager {
6
7
  private readonly region;
7
8
  private readonly appId;
@@ -16,8 +17,8 @@ export declare class RpcManager {
16
17
  setStaticHeader(key: string, value: string): void;
17
18
  deleteStaticHeader(key: string): void;
18
19
  getStaticHeaders(): Record<string, string>;
19
- post<T>(path: string, message: any, files?: File[]): Promise<T>;
20
- private parseResponse;
20
+ post<T>(path: string, message: any, files?: Array<File | BlobAndFilename>, filesFieldName?: string): Promise<T>;
21
+ private tryDeserializing;
21
22
  private getRateLimiterBucket;
22
23
  }
23
24
  export declare class RpcError extends Error {
@@ -1,5 +1,4 @@
1
1
  import { ApiEndpointId, ApiKey, AppId, CollectionName, DocumentData, EnvironmentId, IntegrationId, QueryName, SquidDeveloperId, SupportedSquidRegion } from '@squidcloud/common';
2
- import { Observable } from 'rxjs';
3
2
  import { CollectionReference } from './collection-reference';
4
3
  import { ConnectionDetails } from './connection-details';
5
4
  import { DistributedLock } from './distributed-lock.manager';
@@ -122,19 +121,6 @@ export declare class Squid {
122
121
  * @returns An array of all the global Squid instances.
123
122
  */
124
123
  static getInstances(): Array<Squid>;
125
- /**
126
- * Sets the authorization access token (OAuth2.0) that will be sent to the server and will be used for providing the
127
- * `auth` object to the security rules.
128
- *
129
- * @deprecated: pass `AuthTokenProvider` in the constructor of the class.
130
- *
131
- * @param accessToken The OAuth2.0 access token or a promise that resolves with the access token.
132
- * When undefined, no authorization information is sent.
133
- * The Observable variant of the parameter is deprecated and will be removed soon.
134
- * @param integrationId The id of the integration.
135
- * @returns void
136
- */
137
- setAuthIdToken: (accessToken: string | undefined | Promise<string | undefined> | Observable<string | undefined> | SquidAuthProvider, integrationId?: IntegrationId) => void;
138
124
  /**
139
125
  * Sets the authorization access token (OAuth2.0) provider that will be sent to the server and will be used for
140
126
  * providing the `auth` object to the security rules.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.144-beta",
3
+ "version": "1.0.145-beta",
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",
@@ -32,9 +32,10 @@
32
32
  "license": "ISC",
33
33
  "dependencies": {
34
34
  "@apollo/client": "^3.7.4",
35
- "@squidcloud/common": "1.0.144-beta",
35
+ "@squidcloud/common": "1.0.145-beta",
36
36
  "@supercharge/promise-pool": "^2.3.2",
37
37
  "cross-fetch": "^3.1.5",
38
+ "axios": "^1.6.2",
38
39
  "lodash": "^4.17.21",
39
40
  "ws": "^8.13.0"
40
41
  },