UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

104 lines (103 loc) 5.09 kB
import { ExecuteAiApiResponse, ExecuteAiQueryOptions, ExecuteAiQueryResponse } from '../../internal-common/src/public-types/ai-query.public-types'; import { AiAgentReference } from './agent/ai-agent-client-reference'; import { AiAssistantClient } from './ai-assistant-client'; import { AiAudioClient } from './ai-audio-client'; import { AiImageClient } from './ai-image-client'; import { AiKnowledgeBaseReference } from './ai-knowledge-base/ai-knowledge-base-client-reference'; import { AiMatchMakingClient } from './ai-matchmaking-client'; import { AiAgent, AiAgentId, AiKnowledgeBase, AiKnowledgeBaseId, AiProviderType, ApplicationAiSettings, IntegrationId, SecretKey } from './public-types'; /** * 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 jobClient; private readonly aiAssistantClient; private aiAgentClient?; private aiKnowledgeBaseClient?; /** * 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; /** * Returns a reference to the specified AI knowledge base. */ knowledgeBase(knowledgeBaseId: AiKnowledgeBaseId): AiKnowledgeBaseReference; /** * Lists all available AI agents. */ listAgents(): Promise<Array<AiAgent>>; /** * Lists all available AI agents. */ listKnowledgeBases(): Promise<Array<AiKnowledgeBase>>; /** * 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>; /** * 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>; private getAiAgentClient; private getAiKnowledgeBaseClient; }