AIChatInteractionAPI
An API allowing to manipulate the AI Chat interaction while it is being streamed in the chat.
This set of helpers is dedicated to be used and available only inside AIToolEventCallback.
Properties
clearLoadingMessage : () => voidmodule:ai/aichat/aichat~AIChatInteractionAPI#clearLoadingMessageClears the currently displayed AI chat loading message. No text will be shown.
insertCustomElement : ( element: string | HTMLElement, id: string ) => Promise<AIChatFeedCustomElementView>module:ai/aichat/aichat~AIChatInteractionAPI#insertCustomElementInserts a custom element into the AI chat feed. The element can be provided as a HTML string or as a
HTMLElement.Passing an
idis optional. When passed, it is added to the wrapping HTML element asdata-cke-ai-idattribute, allowing to query it later with native DOM methods.Note, that the element is not immediately inserted into the UI when this method is called. Insertions are queued to ensure the element is rendered after currently processed content.
Returns a promise which is resolved after the element is finally attached to the DOM. You can use this promise to further manage the displayed content, for example, fetch asynchronous data and display it inside the inserted element.
insertTextReply : ( content: string, id: string ) => AIReplymodule:ai/aichat/aichat~AIChatInteractionAPI#insertTextReplyCreates a new reply in the current interaction. The created reply becomes the current reply of the interaction.
Passing an
idis optional. When passed, it is added to the wrapping HTML element asdata-cke-ai-idattribute, allowing to query it later with native DOM methods.This method allows adding custom text replies to the AI chat feed. You can pass plain text or Markdown-formatted text as the
contentparameter. Markdown is automatically converted to proper HTML formatting when rendered in the chat feed.Note, that the text reply is not immediately inserted into the UI when this method is called. Insertions are queued to ensure the reply is rendered after currently processed content.
Note also, that the content of the reply is visually streamed in the chat feed (word by word), so it will appear gradually.
setLoadingMessage : ( message: string ) => voidmodule:ai/aichat/aichat~AIChatInteractionAPI#setLoadingMessageSets the currently displayed AI chat loading message.