@builder.io/ai-utils
Advanced tools
Comparing version 0.0.34 to 0.0.35
import type { BuilderContent, BuilderElement, Component } from "@builder.io/sdk"; | ||
import type { MessageParam, SnippetParams } from "./messages"; | ||
import type { Message, MessageParam, SnippetParams } from "./messages"; | ||
import type { BuilderModel } from "./events"; | ||
@@ -33,3 +33,3 @@ export type BuilderContentData = BuilderContent["data"]; | ||
*/ | ||
messages: MessageParam[]; | ||
messages: (MessageParam | Message)[]; | ||
/** | ||
@@ -36,0 +36,0 @@ * Which platform (framework) the the user has choosen to get help with. |
@@ -6,3 +6,3 @@ import type { BuilderContent, BuilderElement } from "@builder.io/sdk"; | ||
export type BuilderAssistantEventHandler = (ev: BuilderAssistantEvent) => void; | ||
export type BuilderAssistantEvent = AssistantErrorEvent | AppCloseEvent | AppMessagesClickEvent | AppMessagesGenerationEvent | AppPromptAbortEvent | AppPromptFocusEvent | AppPromptTextEvent | AppReadyEvent | AppSettingsResetEvent | AppSettingsSetEvent | AppThreadNewEvent | BuilderEditorStateEvent | ContentUpdateEvent | ContentApplySnapshotEvent | ContentCompleteEvent | ModelCreateEvent | ModelUpdateEvent | ModelUndoEvent | ResultEvent | ThreadCreatedEvent | ThreadMessageDeltaEvent | ThreadMessageCompletedEvent | ThreadMessageFeedbackEvent | ThreadRunRequiresActionEvent | ThreadRunStepCreatedEvent | ThreadRunStepDeltaEvent; | ||
export type BuilderAssistantEvent = AssistantErrorEvent | AppCloseEvent | AppMessagesClickEvent | AppMessagesGenerationEvent | AppPromptAbortEvent | AppPromptFocusEvent | AppPromptTextEvent | AppReadyEvent | AppSettingsResetEvent | AppSettingsSetEvent | AppThreadNewEvent | AssistantStatsEvent | BuilderEditorStateEvent | ContentUpdateEvent | ContentApplySnapshotEvent | ModelCreateEvent | ModelUpdateEvent | ModelUndoEvent | ResultEvent | ThreadCreatedEvent | ThreadMessageDeltaEvent | ThreadMessageCompletedEvent | ThreadMessageFeedbackEvent | ThreadRunRequiresActionEvent | ThreadRunStepCreatedEvent | ThreadRunStepDeltaEvent; | ||
export interface AssistantError { | ||
@@ -148,12 +148,65 @@ message: string; | ||
} | ||
export interface ContentCompleteEvent { | ||
type: "assistant.content.complete"; | ||
data: ContentComplete; | ||
export interface AssistantStatsEvent { | ||
type: "assistant.stats"; | ||
data: AssistantStats; | ||
} | ||
export interface ContentComplete { | ||
export interface AssistantStats { | ||
/** | ||
* The unique id of the thread (not the openai threadId) | ||
*/ | ||
threadId: string; | ||
/** | ||
* The unique id of the completion, which is a combination of the user's prompt and assistant's response. | ||
*/ | ||
completionId: string; | ||
/** | ||
* The model id used to generate this completion. | ||
*/ | ||
modelId: string; | ||
message: AssistantMessage; | ||
ts: number; | ||
/** | ||
* The assistant's response message. | ||
*/ | ||
assistantMessage: string; | ||
/** | ||
* The user's prompt message. | ||
*/ | ||
userMessage: string; | ||
/** | ||
* The index within the thread the assistant message is. | ||
* For a first assistant message, the index will be 1 (the user message is index 0). | ||
* For a second assistant message, the index will be 3 (the user message is index 2), and so on. | ||
*/ | ||
assistantMessageIndex: number; | ||
/** | ||
* The timestamp (Date.now()) of when the user first submitted their prompt. | ||
*/ | ||
userPromptMs: number; | ||
/** | ||
* The timestamp of the first assistant chunk in the response. | ||
*/ | ||
firstChunkMs: number; | ||
/** | ||
* The timestamp of the last assistant chunk in the response. | ||
*/ | ||
lastChunkMs: number; | ||
/** | ||
* The total number of chunks in the assistant's streamed response. | ||
*/ | ||
chunkCount: number; | ||
/** | ||
* The total number of characters in the generated prompt sent to the LLM. | ||
*/ | ||
promptLength: number; | ||
/** | ||
* The total number of characters in the assistant's response. | ||
*/ | ||
completionLength: number; | ||
/** | ||
* If the user provided custom instructions for the prompt. | ||
*/ | ||
hasCustomInstructions: boolean; | ||
/** | ||
* Error message if there was one. | ||
*/ | ||
errorMessage?: string; | ||
} | ||
@@ -160,0 +213,0 @@ export interface ModelCreateEvent { |
{ | ||
"name": "@builder.io/ai-utils", | ||
"version": "0.0.34", | ||
"version": "0.0.35", | ||
"description": "Builder.io AI utils", | ||
@@ -5,0 +5,0 @@ "type": "module", |
24475
793