HostAI class

The IDE’s AI models, for an add-in to hold conversations with. Reached through Host.AI.

The models are those the user lists in the AI group of IDE Options, each an endpoint of an AI service, an API key and a model’s name. An add-in gets them as providers, starts a conversation with one, and has the IDE send the conversation’s messages to the service. The add-in never sees the endpoint or the key.

Private WithEvents Chat As AIConversation

Private Sub Host_OnProjectLoaded()
    If Host.AI.Providers.Count = 0 Then
        Host.ShowNotification "No AI model is set up in IDE Options."
        Exit Sub
    End If
    Set Chat = Host.AI.Providers.DefaultProvider.StartConversation()
    Chat.SystemPrompt = "Answer in one sentence."
    Chat.Ask "What is twinBASIC?", False
End Sub

Private Sub Chat_Completed(ByVal Response As String)
    Host.DebugConsole.PrintText Response
End Sub

Private Sub Chat_Failed(ByVal ErrorMessage As String)
    Host.DebugConsole.PrintText "The AI failed: " & ErrorMessage
End Sub

Properties

Providers

The models that the IDE’s options list and enable. As HostAIProviders, read-only.

See Also