Skip to main content

Class: AiClient

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.

Methods

agent

agent(agentId): AiAgentReference

Parameters

NameType
agentIdstring

Returns

AiAgentReference


assistant

assistant(): AiAssistantClient

Retrieves the AI assistant client.

Returns

AiAssistantClient

An instance of AiAssistantClient.


audio

audio(): AiAudioClient

Retrieves an AI audio client.

Returns

AiAudioClient


chatbot

chatbot(aiIntegrationId): AiChatbotClient

Retrieves an AI chatbot client for a specific AI integration.

Parameters

NameTypeDescription
aiIntegrationIdstringThe identifier for the AI integration.

Returns

AiChatbotClient

An instance of AiChatbotClient associated with the given AI integration ID.


executeAiQuery

executeAiQuery(integrationId, prompt): Promise<ExecuteAiQueryResponse>

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.

Parameters

NameTypeDescription
integrationIdstringThe identifier for the DB integration which is used to direct the query to the appropriate DB.
promptstringThe 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.

Returns

Promise<ExecuteAiQueryResponse>

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 https://docs.squid.cloud/docs/ai.


executeAiQueryMulti

executeAiQueryMulti(integrationIds, prompt): Promise<ExecuteAiQueryMultiResponse>

Parameters

NameType
integrationIdsstring[]
promptstring

Returns

Promise<ExecuteAiQueryMultiResponse>


image

image(): AiImageClient

Retrieves an AI image client.

Returns

AiImageClient