addPromptOutput

Adds a prompt output to the promptOutputs collection. If the active view is OutputView, calls the view's addPromptOutput method.

Parameters

promptOutput Object

The prompt output to add. The output should have the following properties:

  • output - The output content generated from the prompt.
  • prompt - The prompt text used to generate this output.
  • id - Optional - The id of the prompt output. If none is provided, the id will be generated as a kendo.guid(). The ID is rendered as data-id attribute in the prompt output.
  • isLoading - Optional - Whether the output is in loading state (shows skeleton). Default: false
  • isStreaming - Optional - Whether the output is being streamed. Default: false
  • isRetry - Optional - Whether this output is from a retry operation. Default: false

Example

<div id="aiprompt"></div>
<script>
var aiprompt = $("#aiprompt").kendoAIPrompt({ activeView: 1 }).data("kendoAIPrompt");
aiprompt.addPromptOutput({ prompt: "create object 1", output: "Description 1" });
</script>

Example - Adding streaming output

<div id="aiprompt"></div>
<script>
var aiprompt = $("#aiprompt").kendoAIPrompt({ activeView: 1 }).data("kendoAIPrompt");

// Add output in loading state for streaming
var outputId = kendo.guid();
aiprompt.addPromptOutput({
    id: outputId,
    prompt: "Generate a story",
    output: "",
    isLoading: true,
    isStreaming: true
});

// Start streaming - this will show the stop button
aiprompt.startStreaming();

// Simulate streaming updates
setTimeout(() => {
    aiprompt.updatePromptOutputContent("Once upon a time...", outputId);
}, 1000);

setTimeout(() => {
    aiprompt.updatePromptOutputContent("Once upon a time, there was a brave knight...", outputId);
    aiprompt.stopStreaming(); // Stop streaming and show final content
}, 3000);
</script>
In this article
addPromptOutput
Not finding the help you need?
Contact Support