AI DevKit
Search Results for

    Show / Hide Table of Contents

    Class AssistantController

    Formarly AssistantsAPIv2, this class is now called AssistantController. The Assistants API allows you to build AI assistants within your own applications. An Assistant has instructions and can leverage models, tools, and files to respond to user queries. The Assistants API currently supports three types of tools: Code Interpreter, File Search, and Function calling.

    Inheritance
    object
    AssistantController
    Namespace: Glitch9.AIDevKit.OpenAI.Assistants
    Assembly: .dll
    Syntax
    public sealed class AssistantController
    Remarks

    AssistantTool now uses Assistants APIv2. Assistants APIv1 will no longer be used. (Updated on 2024-05-23 by Munchkin)

    Constructors

    AssistantController(AssistantSettings, RunRequest)

    Declaration
    public AssistantController(AssistantSettings settings, RunRequest defaultRunRequest = null)
    Parameters
    Type Name Description
    AssistantSettings settings
    RunRequest defaultRunRequest

    Fields

    MIN_INTERNAL_OPERATION_MILLIS

    The minimum interval between operations in milliseconds.

    Declaration
    public const int MIN_INTERNAL_OPERATION_MILLIS = 1000
    Field Value
    Type Description
    int

    MIN_INTERVAL_REQUEST_MILLIS

    The minimum interval between requests in milliseconds.

    Declaration
    public const int MIN_INTERVAL_REQUEST_MILLIS = 2000
    Field Value
    Type Description
    int

    SavedThreadMessages

    Declaration
    public static PrefsDictionary<string, ThreadMessage> SavedThreadMessages
    Field Value
    Type Description
    PrefsDictionary<string, ThreadMessage>

    Properties

    AssistantId

    Declaration
    public string AssistantId { get; }
    Property Value
    Type Description
    string

    AssistantName

    Gets or sets the name of this assistant.

    Declaration
    public string AssistantName { get; set; }
    Property Value
    Type Description
    string

    AssistantStatus

    Gets the current stage of the Assistants API.

    Declaration
    public AssistantStatus AssistantStatus { get; }
    Property Value
    Type Description
    AssistantStatus

    AutoCancelOnRequiredAction

    Declaration
    public bool AutoCancelOnRequiredAction { get; set; }
    Property Value
    Type Description
    bool

    Client

    Gets the OpenAiClient instance used by this tool.

    Declaration
    public OpenAI Client { get; }
    Property Value
    Type Description
    OpenAI

    CurrentAssistant

    The current assistant instance.

    Declaration
    public Assistant CurrentAssistant { get; }
    Property Value
    Type Description
    Assistant

    CurrentRun

    The current run instance.

    Declaration
    public Run CurrentRun { get; set; }
    Property Value
    Type Description
    Run

    CurrentRunId

    The current run ID.

    Declaration
    public string CurrentRunId { get; }
    Property Value
    Type Description
    string

    CurrentRunStep

    The current run step instance.

    Declaration
    public RunStep CurrentRunStep { get; set; }
    Property Value
    Type Description
    RunStep

    CurrentThread

    The current thread instance.

    Declaration
    public Thread CurrentThread { get; set; }
    Property Value
    Type Description
    Thread

    CurrentThreadId

    The current thread ID.

    Declaration
    public string CurrentThreadId { get; }
    Property Value
    Type Description
    string

    DefaultRunRequest

    Gets or sets the default run request options for this tool.

    Declaration
    public RunRequest DefaultRunRequest { get; }
    Property Value
    Type Description
    RunRequest

    Description

    Gets or sets the description of this assistant.

    Declaration
    public string Description { get; set; }
    Property Value
    Type Description
    string

    ForcedTool

    If not null, it forces this AssistantsAPI to use a specific tool on every request.

    Declaration
    public ToolChoice ForcedTool { get; set; }
    Property Value
    Type Description
    ToolChoice

    Instructions

    Gets or sets the instructions for this assistant.

    Declaration
    public string Instructions { get; set; }
    Property Value
    Type Description
    string

    IsBusy

    Indicates whether the AssistantsAPI is busy.

    Declaration
    public bool IsBusy { get; }
    Property Value
    Type Description
    bool

    IsInitialized

    Indicates whether the AssistantsAPI instance is initialized.

    Declaration
    public bool IsInitialized { get; }
    Property Value
    Type Description
    bool

    LastAssistantMessage

    The last assistant message received from the AssistantsAPI.

    Declaration
    public ThreadMessage LastAssistantMessage { get; }
    Property Value
    Type Description
    ThreadMessage

    LastMessageRequest

    The last ThreadMessageRequest sent to the AssistantsAPI.

    Declaration
    public ThreadMessageRequest LastMessageRequest { get; }
    Property Value
    Type Description
    ThreadMessageRequest

    LastToolMessage

    Last tool message received from the AssistantsAPI.

    Declaration
    public ThreadMessage LastToolMessage { get; }
    Property Value
    Type Description
    ThreadMessage

    LastUserMessage

    The last user message sent to the AssistantsAPI.

    Declaration
    public ThreadMessage LastUserMessage { get; }
    Property Value
    Type Description
    ThreadMessage

    MaxRequestLength

    Gets or sets the maximum request length.

    Declaration
    public int MaxRequestLength { get; set; }
    Property Value
    Type Description
    int

    Messages

    Declaration
    public List<ThreadMessage> Messages { get; }
    Property Value
    Type Description
    List<ThreadMessage>

    Metadata

    Gets or sets the metadata associated with this assistant.

    Declaration
    public Dictionary<string, string> Metadata { get; set; }
    Property Value
    Type Description
    Dictionary<string, string>

    Model

    Gets or sets the GPT model used by this assistant.

    Declaration
    public Model Model { get; set; }
    Property Value
    Type Description
    Model

    OneTimeRunRequest

    Declaration
    public RunRequest OneTimeRunRequest { get; }
    Property Value
    Type Description
    RunRequest

    RequiredActionTimeoutSeconds

    Declaration
    public int RequiredActionTimeoutSeconds { get; set; }
    Property Value
    Type Description
    int

    RequiredActions

    Declaration
    public List<string> RequiredActions { get; }
    Property Value
    Type Description
    List<string>

    RequiresAction

    Indicates whether the AssistantsAPI requires action.

    Declaration
    public bool RequiresAction { get; }
    Property Value
    Type Description
    bool

    ResponseFormat

    Gets or sets the response format for this assistant.

    Declaration
    public TextFormat? ResponseFormat { get; set; }
    Property Value
    Type Description
    TextFormat?

    RunStatus

    Gets the current run status of the Assistants API.

    Declaration
    public RunStatus RunStatus { get; }
    Property Value
    Type Description
    RunStatus

    SaveMessagesToPrefs

    Indicates whether to save thread messages.

    Declaration
    public bool SaveMessagesToPrefs { get; set; }
    Property Value
    Type Description
    bool

    Stream

    Indicates if the tool is set to stream (not supported yet).

    Declaration
    public bool Stream { get; set; }
    Property Value
    Type Description
    bool

    Temperature

    Gets or sets the temperature setting for this assistant's responses.

    Declaration
    public float Temperature { get; set; }
    Property Value
    Type Description
    float

    ToolResources

    Give the tools like code_interpreter and file_search access to files. Files are uploaded using the File upload endpoint and must have the purpose set to assistants to be used with this API.

    Declaration
    public ToolResources ToolResources { get; set; }
    Property Value
    Type Description
    ToolResources

    Tools

    Give the Assistant access to up to 128 tools. You can give it access to OpenAI-hosted tools like code_interpreter and file_search, or call a third-party tools via a function calling.

    Declaration
    public List<ToolCall> Tools { get; set; }
    Property Value
    Type Description
    List<ToolCall>

    TopP

    Gets or sets the top-p setting for this assistant's responses.

    Declaration
    public float TopP { get; set; }
    Property Value
    Type Description
    float

    Methods

    CancelRunAsync()

    Cancels the current run operation.

    Declaration
    public UniTask CancelRunAsync()
    Returns
    Type Description
    UniTask

    A UniTask representing the asynchronous operation.

    CreateThreadAsync(bool)

    Create a new thread and set it as the current thread. If deleteCurrent is true, the current thread will be deleted before creating a new one.

    Declaration
    public UniTask<Thread> CreateThreadAsync(bool deleteCurrent = false)
    Parameters
    Type Name Description
    bool deleteCurrent
    Returns
    Type Description
    UniTask<Thread>

    DeleteThreadAsync(string)

    Delete the thread with the threadId.

    Declaration
    public UniTask<bool> DeleteThreadAsync(string threadId)
    Parameters
    Type Name Description
    string threadId
    Returns
    Type Description
    UniTask<bool>

    InitializeAsync(Action)

    Initializes the AssistantsAPI instance asynchronously.

    Declaration
    public UniTask InitializeAsync(Action onInitialized = null)
    Parameters
    Type Name Description
    Action onInitialized
    Returns
    Type Description
    UniTask

    A UniTask representing the asynchronous operation.

    LoadThreadAsync(string)

    Switch to the existing thread with threadId. The thread with the threadId must exist.

    Declaration
    public UniTask<Thread> LoadThreadAsync(string threadId)
    Parameters
    Type Name Description
    string threadId
    Returns
    Type Description
    UniTask<Thread>

    RequestAsync(AudioClip, RunRequest)

    Declaration
    public UniTask<ThreadMessage> RequestAsync(AudioClip audioPrompt, RunRequest runRequest = null)
    Parameters
    Type Name Description
    AudioClip audioPrompt
    RunRequest runRequest
    Returns
    Type Description
    UniTask<ThreadMessage>

    RequestAsync(ThreadMessageRequest, RunRequest)

    Declaration
    public UniTask<ThreadMessage> RequestAsync(ThreadMessageRequest messageRequest, RunRequest runRequest = null)
    Parameters
    Type Name Description
    ThreadMessageRequest messageRequest
    RunRequest runRequest
    Returns
    Type Description
    UniTask<ThreadMessage>

    RequestAsync(TranscriptionRequest, RunRequest)

    Declaration
    public UniTask<ThreadMessage> RequestAsync(TranscriptionRequest transcriptionRequest, RunRequest runRequest = null)
    Parameters
    Type Name Description
    TranscriptionRequest transcriptionRequest
    RunRequest runRequest
    Returns
    Type Description
    UniTask<ThreadMessage>

    RequestAsync(File<AudioClip>, RunRequest)

    Declaration
    public UniTask<ThreadMessage> RequestAsync(File<AudioClip> audioPrompt, RunRequest runRequest = null)
    Parameters
    Type Name Description
    File<AudioClip> audioPrompt
    RunRequest runRequest
    Returns
    Type Description
    UniTask<ThreadMessage>

    RequestAsync(string, RunRequest)

    Requests a response from the assistant asynchronously.

    Declaration
    public UniTask<ThreadMessage> RequestAsync(string textPrompt, RunRequest runRequest = null)
    Parameters
    Type Name Description
    string textPrompt

    The text prompt to send to the assistant.

    RunRequest runRequest

    Optional custom run request options.

    Returns
    Type Description
    UniTask<ThreadMessage>

    A task representing the result of the request.

    RequestAsync(string, RunRequest, params File<Texture2D>[])

    Declaration
    public UniTask<ThreadMessage> RequestAsync(string textPrompt, RunRequest runRequest, params File<Texture2D>[] imageFiles)
    Parameters
    Type Name Description
    string textPrompt
    RunRequest runRequest
    File<Texture2D>[] imageFiles
    Returns
    Type Description
    UniTask<ThreadMessage>

    RequestAsync(string, RunRequest, params string[])

    Declaration
    public UniTask<ThreadMessage> RequestAsync(string textPrompt, RunRequest runRequest, params string[] imageUrls)
    Parameters
    Type Name Description
    string textPrompt
    RunRequest runRequest
    string[] imageUrls
    Returns
    Type Description
    UniTask<ThreadMessage>

    SubmitToolOutputAsync(string, string)

    Declaration
    public UniTask<ThreadMessage> SubmitToolOutputAsync(string toolCallId, string outputToSubmit)
    Parameters
    Type Name Description
    string toolCallId
    string outputToSubmit
    Returns
    Type Description
    UniTask<ThreadMessage>

    UpdateAssistantAsync()

    Update(modify) the assistant with the AssistantRequest.

    Declaration
    public UniTask<Assistant> UpdateAssistantAsync()
    Returns
    Type Description
    UniTask<Assistant>
    In this article
    Back to top Generated by DocFX