UNPKG

@squidcloud/client

Version:

A typescript implementation of the Squid client

73 lines (72 loc) 3.63 kB
import { AssistantToolType, QueryAssistantOptions } from './public-types'; /** * Client class for interacting with an AI Assistant server. * Provides functionalities like creating and deleting assistants and threads, * querying assistants, and managing files associated with assistants and threads. * @category AI */ export declare class AiAssistantClient { private readonly rpcManager; /** * Creates a new AI assistant with specified characteristics. * @param name - The name of the assistant. * @param instructions - Instructions for the assistant. * @param functions - Array of function names annotated with "@aiFunction" in your Squid backend that will be * available to the assistant. * @param toolTypes - Optional array of tool types. If you want to use files for retrieval, you must add them using * the addFileToAssistant method. * @returns A promise that resolves to the created assistant's ID. */ createAssistant(name: string, instructions: string, functions: Array<string>, toolTypes?: Array<AssistantToolType>): Promise<string>; /** * Deletes an AI assistant. * @param assistantId - The ID of the assistant to be deleted. * @returns A promise that resolves when the assistant is deleted. */ deleteAssistant(assistantId: string): Promise<void>; /** * Creates a new thread for an AI assistant. A thread is a long-lived conversation with the assistant that you can * always send questions to. * @param assistantId - The ID of the assistant for which the thread is created. * @returns A promise that resolves to the created thread's ID. */ createThread(assistantId: string): Promise<string>; /** * Deletes a thread of an AI assistant. * @param threadId - The ID of the thread to be deleted. * @returns A promise that resolves when the thread is deleted. */ deleteThread(threadId: string): Promise<void>; /** * Queries an AI assistant within a specific thread. * @param assistantId - The ID of the assistant. * @param threadId - The ID of the thread. * @param prompt - The query prompt. * @param fileIds - Optional array of file IDs to include in the query. These file IDs need to be added using the * addFileToThread method. * @param options - Optional query options. * @returns A promise that resolves to the assistant's response. */ queryAssistant(assistantId: string, threadId: string, prompt: string, fileIds?: string[], options?: QueryAssistantOptions): Promise<string>; /** * Adds a file to an AI assistant that can be available for retrieval or code analyzer. * @param assistantId - The ID of the assistant. * @param file - The file to be added. * @returns A promise that resolves to the ID of the added file. */ addFileToAssistant(assistantId: string, file: File): Promise<string>; /** * Removes a file from an AI assistant. * @param assistantId - The ID of the assistant. * @param fileId - The ID of the file to be removed. * @returns A promise that resolves when the file is removed. */ removeFileFromAssistant(assistantId: string, fileId: string): Promise<void>; /** * Adds a file to a specific thread of an AI assistant. These files can be used when asking a question in the thread. * @param threadId - The ID of the thread. * @param file - The file to be added. * @returns A promise that resolves to the ID of the added file. */ addFileToThread(threadId: string, file: File): Promise<string>; }