UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

126 lines (125 loc) 5.17 kB
import { AgentContextRequest, AiAgent, AiAgentContext, AiChatModelName, AiConnectedAgentMetadata, AiObserveStatusOptions, AiSearchOptions, AiSearchResultChunk, AiStatusMessage, AiTranscribeAndAskResponse, GuardrailsOptions, UpsertAgentRequest } from '../../../internal-common/src/public-types/ai-agent.public-types'; import { Observable } from 'rxjs'; import { AiAskOptions, AiAskOptionsWithVoice, AiChatOptionsWithoutVoice, AskWithVoiceResponse, TranscribeAndAskWithVoiceResponse, TranscribeAndChatResponse } from './ai-agent-client.types'; /** * Parameters for creating or updating an AI agent. * Excludes the `id` field, as it is derived from the agent instance. * @category AI */ export type UpsertAgentRequestParams = Omit<UpsertAgentRequest, 'id'>; /** * AiAgentReference provides methods for managing AI agents, including * retrieving, updating, and deleting agents, handling agent contexts, * and interacting with chat or voice-based AI functionalities. * @category AI */ export declare class AiAgentReference { private readonly agentId; private readonly ongoingChatSequences; private readonly statusUpdates; private readonly rpcManager; private readonly socketManager; /** * Retrieves metadata and configuration of the AI agent. */ get(): Promise<AiAgent | undefined>; /** * Creates or updates the AI agent with the provided parameters. */ upsert(agent: UpsertAgentRequestParams): Promise<void>; /** * Deletes the AI agent. */ delete(): Promise<void>; /** * Updates the agent's instruction prompt. */ updateInstructions(instructions: string): Promise<void>; /** * Changes the AI model used by the agent. */ updateModel(model: AiChatModelName): Promise<void>; /** * Updates the list of agents connected to this agent. */ updateConnectedAgents(connectedAgents: Array<AiConnectedAgentMetadata>): Promise<void>; /** * Retrieves a specific agent context by its ID. */ getContext(contextId: string): Promise<AiAgentContext | undefined>; /** * Lists all contexts associated with the agent. */ listContexts(): Promise<Array<AiAgentContext>>; /** * Deletes a specific context by its ID. */ deleteContext(contextId: string): Promise<void>; /** * Deletes multiple agent contexts. */ deleteContexts(contextIds: Array<string>): Promise<void>; /** * Adds or updates a single agent context. */ upsertContext(contextRequest: AgentContextRequest, file?: File): Promise<void>; /** * Adds or updates multiple agent contexts. */ upsertContexts(contextRequests: Array<AgentContextRequest>, files?: Array<File>): Promise<void>; /** * Sends user feedback to the agent. */ provideFeedback(feedback: string): Promise<void>; /** * Resets any feedback previously provided to the agent. */ resetFeedback(): Promise<void>; /** * Updates the agent's guardrails with the provided options. */ updateGuardrails(guardrails: GuardrailsOptions): Promise<void>; /** * Updates the agent's custom guardrails with the provided custom guardrail. */ updateCustomGuardrails(customGuardrail: string): Promise<void>; /** * Deletes the custom guardrails for the agent. */ deleteCustomGuardrail(): Promise<void>; /** * Sends a prompt to the agent and receives streamed text responses. */ chat<T extends AiChatModelName | undefined>(prompt: string, options?: AiChatOptionsWithoutVoice<T>): Observable<string>; /** * Transcribes the given file and performs a chat interaction. */ transcribeAndChat(fileToTranscribe: File, options?: AiChatOptionsWithoutVoice): Promise<TranscribeAndChatResponse>; /** * Performs a semantic search using the agent's knowledge base. */ search(options: AiSearchOptions): Promise<Array<AiSearchResultChunk>>; /** * Sends a prompt and receives a full string response. */ ask<T extends AiChatModelName | undefined = undefined>(prompt: string, options?: AiAskOptions<T>): Promise<string>; /** * Observes live status messages from the agent. */ observeStatusUpdates(options?: AiObserveStatusOptions): Observable<AiStatusMessage>; /** * Transcribes audio and sends it to the agent for response. */ transcribeAndAsk<T extends AiChatModelName | undefined>(fileToTranscribe: File, options?: AiAskOptions<T>): Promise<AiTranscribeAndAskResponse>; /** * Transcribes audio and gets both text and voice response from the agent. */ transcribeAndAskWithVoiceResponse<T extends AiChatModelName | undefined>(fileToTranscribe: File, options?: AiAskOptionsWithVoice<T>): Promise<TranscribeAndAskWithVoiceResponse>; /** * Sends a prompt and gets both text and voice response from the agent. */ askWithVoiceResponse<T extends AiChatModelName | undefined>(prompt: string, options?: AiAskOptionsWithVoice<T>): Promise<AskWithVoiceResponse>; private askInternal; private createStatusSubject; private chatInternal; }