Skip to main content

Class: AiAssistantClient

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.

Methods

addFileToAssistant

addFileToAssistant(assistantId, file): Promise<string>

Adds a file to an AI assistant that can be available for retrieval or code analyzer.

Parameters

NameTypeDescription
assistantIdstringThe ID of the assistant.
fileBlobAndFilename | FileThe file or blob and filename to be added.

Returns

Promise<string>

A promise that resolves to the ID of the added file.


addFileToThread

addFileToThread(threadId, file): Promise<string>

Adds a file to a specific thread of an AI assistant. These files can be used when asking a question in the thread.

Parameters

NameTypeDescription
threadIdstringThe ID of the thread.
fileBlobAndFilename | FileThe file or blob and filename to be added.

Returns

Promise<string>

A promise that resolves to the ID of the added file.


createAssistant

createAssistant(name, instructions, functions, toolTypes?): Promise<string>

Creates a new AI assistant with specified characteristics.

Parameters

NameTypeDescription
namestringThe name of the assistant.
instructionsstringInstructions for the assistant.
functionsstring[]Array of function names annotated with "@aiFunction" in your Squid backend that will be available to the assistant.
toolTypes?AssistantToolType[]Optional array of tool types. If you want to use files for retrieval, you must add them using the addFileToAssistant method.

Returns

Promise<string>

A promise that resolves to the created assistant's ID.


createThread

createThread(assistantId): Promise<string>

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.

Parameters

NameTypeDescription
assistantIdstringThe ID of the assistant for which the thread is created.

Returns

Promise<string>

A promise that resolves to the created thread's ID.


deleteAssistant

deleteAssistant(assistantId): Promise<void>

Deletes an AI assistant.

Parameters

NameTypeDescription
assistantIdstringThe ID of the assistant to be deleted.

Returns

Promise<void>

A promise that resolves when the assistant is deleted.


deleteThread

deleteThread(threadId): Promise<void>

Deletes a thread of an AI assistant.

Parameters

NameTypeDescription
threadIdstringThe ID of the thread to be deleted.

Returns

Promise<void>

A promise that resolves when the thread is deleted.


queryAssistant

queryAssistant(assistantId, threadId, prompt, fileIds?, options?): Promise<string>

Queries an AI assistant within a specific thread.

Parameters

NameTypeDescription
assistantIdstringThe ID of the assistant.
threadIdstringThe ID of the thread.
promptstringThe query prompt.
fileIds?string[]Optional array of file IDs to include in the query. These file IDs need to be added using the addFileToThread method.
options?QueryAssistantOptionsOptional query options.

Returns

Promise<string>

A promise that resolves to the assistant's response.


removeFileFromAssistant

removeFileFromAssistant(assistantId, fileId): Promise<void>

Removes a file from an AI assistant.

Parameters

NameTypeDescription
assistantIdstringThe ID of the assistant.
fileIdstringThe ID of the file to be removed.

Returns

Promise<void>

A promise that resolves when the file is removed.