UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

101 lines (100 loc) 5.13 kB
import { AiAssistantClient } from './ai-assistant-client'; import { AiAgent, AiAgentId, AiProviderType, ApplicationAiSettings, IntegrationId, SecretKey } from './public-types'; import { AiImageClient } from './ai-image-client'; import { AiAudioClient } from './ai-audio-client'; import { AiMatchMakingClient } from './ai-matchmaking-client'; import { ExecuteAiApiResponse, ExecuteAiQueryMultiResponse, ExecuteAiQueryOptions, ExecuteAiQueryResponse } from './ai.types'; import { AiAgentReference } from './agent/ai-agent-client-reference'; /** * AiClient class serves as a facade for interacting with different AI services. * It provides simplified access to AI chatbot and assistant functionalities * through its methods. * @category AI */ export declare class AiClient { private readonly socketManager; private readonly rpcManager; private readonly aiAssistantClient; private aiAgentClient?; /** * Returns a reference to the specified AI agent. * If no ID is provided, the built-in agent is used by default. */ agent(agentId?: AiAgentId): AiAgentReference; /** * Lists all available AI agents. */ listAgents(): Promise<Array<AiAgent>>; /** * Retrieves the AI assistant client. * @returns An instance of AiAssistantClient. */ assistant(): AiAssistantClient; /** * Retrieves an AI image client. */ image(): AiImageClient; /** * Retrieves an AI audio client. */ audio(): AiAudioClient; /** * Retrieves an AI match-making client. */ matchMaking(): AiMatchMakingClient; /** * Executes an AI query using a specific DB integration, sending a prompt to the AI and returning its response. * This function allows for direct interaction with the AI's capabilities by sending text prompts and receiving * the AI's responses, which can be used for various applications such as automating tasks, generating content, * or obtaining information. * * @param integrationId The identifier for the DB integration which is used to direct the query to the * appropriate DB. * @param prompt The text prompt to send to the AI. This should be formulated in a way that the AI can * understand and respond to, taking into account the nature of the task or the information * sought. * @param options Additional options to customize the query execution. * @returns A promise that resolves to an `ExecuteAiQueryResponse`. This response includes the AI's * reply to the provided prompt, along with any other relevant information that is part of * the AI's response. The promise can be awaited to handle the response asynchronously. * * @example * ``` * const response = await ai().executeAiQuery(myDbIntegrationId, "How many transactions ran yesterday?"); * console.log(response); * ``` * * For more details on the usage and capabilities of the AI Assistant, refer to the documentation provided at * {@link https://docs.squid.cloud/docs/ai}. */ executeAiQuery(integrationId: IntegrationId, prompt: string, options?: ExecuteAiQueryOptions): Promise<ExecuteAiQueryResponse>; /** * Executes an AI query across multiple database integrations and returns their responses. * Useful when querying multiple sources with the same prompt. * * @param integrationIds The list of integration IDs to query. * @param prompt The prompt to send to the AI. * @param options Optional query execution parameters. * @returns A promise resolving to the responses from all queried integrations. */ executeAiQueryMulti(integrationIds: Array<IntegrationId>, prompt: string, options?: ExecuteAiQueryOptions): Promise<ExecuteAiQueryMultiResponse>; /** * Request to execute an AI-powered API call. * Allows specifying allowed endpoints and whether to provide an explanation. */ executeAiApiCall(integrationId: IntegrationId, prompt: string, allowedEndpoints?: string[], provideExplanation?: boolean): Promise<ExecuteAiApiResponse>; /** * Returns name of the secret that stores API key for the given AI provider type. * This API key is used for all requests to the AI provider done from the application. */ getApplicationAiSettings(): Promise<ApplicationAiSettings>; /** Sets new application AI settings. Overwrites the existing value. */ setApplicationAiSettings(settings: ApplicationAiSettings): Promise<void>; /** * Sets the name of the secret that stores API key for the given AI provider type. * This API key is used for all requests to the AI provider done from the application. * To delete the existing secret key use 'undefined' for the name of the secret. * Returns the updated state of the AI application settings. */ setAiProviderApiKeySecret(providerType: AiProviderType, secretKey: SecretKey | undefined): Promise<ApplicationAiSettings>; }