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
Name | Type | Description |
---|---|---|
assistantId | string | The ID of the assistant. |
file | BlobAndFilename | File | The 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
Name | Type | Description |
---|---|---|
threadId | string | The ID of the thread. |
file | BlobAndFilename | File | The 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
Name | Type | Description |
---|---|---|
name | string | The name of the assistant. |
instructions | string | Instructions for the assistant. |
functions | string [] | 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
Name | Type | Description |
---|---|---|
assistantId | string | The 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
Name | Type | Description |
---|---|---|
assistantId | string | The 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
Name | Type | Description |
---|---|---|
threadId | string | The 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
Name | Type | Description |
---|---|---|
assistantId | string | The ID of the assistant. |
threadId | string | The ID of the thread. |
prompt | string | The 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? | QueryAssistantOptions | Optional 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
Name | Type | Description |
---|---|---|
assistantId | string | The ID of the assistant. |
fileId | string | The ID of the file to be removed. |
Returns
Promise
<void
>
A promise that resolves when the file is removed.