@meetsmore-oss/use-ai-client 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled.js +3837 -2406
- package/dist/bundled.js.map +1 -1
- package/dist/{chunk-QTQR7MAU.js → chunk-STF3H6F5.js} +1 -1
- package/dist/chunk-STF3H6F5.js.map +1 -0
- package/dist/{chunk-AKQM6IWU.js → chunk-UM4UCU4W.js} +1 -1
- package/dist/chunk-UM4UCU4W.js.map +1 -0
- package/dist/index.d.ts +94 -12
- package/dist/index.js +387 -89
- package/dist/index.js.map +1 -1
- package/dist/{types-64CH2HXY.js → types-GWPQMSYT.js} +2 -2
- package/dist/{types-STDS67SG.js → types-RJZTRF3U.js} +2 -2
- package/package.json +2 -2
- package/dist/chunk-AKQM6IWU.js.map +0 -1
- package/dist/chunk-QTQR7MAU.js.map +0 -1
- /package/dist/{types-64CH2HXY.js.map → types-GWPQMSYT.js.map} +0 -0
- /package/dist/{types-STDS67SG.js.map → types-RJZTRF3U.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/chatRepository/types.ts"],"sourcesContent":["import type { PersistedFileMetadata } from '../../fileUpload/types';\nimport type { FeedbackValue } from '@meetsmore-oss/use-ai-core';\n\n/**\n * Arbitrary metadata attached to a chat.\n * Use this to store context about the chat (e.g., how it was invoked, document type being processed).\n */\nexport type ChatMetadata = Record<string, unknown>;\n\n/**\n * Display mode for chat messages.\n * Determines the visual styling of the message bubble.\n */\nexport type MessageDisplayMode = 'default' | 'error';\n\n/**\n * Text content part for persisted messages.\n */\nexport interface PersistedTextContent {\n type: 'text';\n text: string;\n}\n\n/**\n * File content part for persisted messages.\n * Only stores metadata, not the actual file data.\n */\nexport interface PersistedFileContent {\n type: 'file';\n file: PersistedFileMetadata;\n}\n\n/**\n * Content part for persisted messages.\n * Can be text or file metadata.\n */\nexport type PersistedContentPart = PersistedTextContent | PersistedFileContent;\n\n/**\n * Content that can be persisted.\n * Simple string for text-only messages, or array for multimodal content.\n */\nexport type PersistedMessageContent = string | PersistedContentPart[];\n\n/**\n * Message format for persisted chat history.\n * Compatible with AI SDK's UIMessage format for future integration.\n */\nexport interface PersistedMessage {\n id: string;\n role: 'user' | 'assistant' | 'tool';\n /** Content can be a string or multimodal content array */\n content: PersistedMessageContent;\n createdAt: Date;\n displayMode?: MessageDisplayMode;\n /** Langfuse trace ID for feedback tracking (only for assistant messages) */\n traceId?: string;\n /** User feedback on this message (only for assistant messages) */\n feedback?: FeedbackValue;\n}\n\n/**\n * Represents a stored chat conversation.\n */\nexport interface Chat {\n id: string;\n title?: string;\n messages: PersistedMessage[];\n createdAt: Date;\n updatedAt: Date;\n /** Arbitrary metadata attached to the chat */\n metadata?: ChatMetadata;\n}\n\n/**\n * Options for creating a new chat.\n */\nexport interface CreateChatOptions {\n title?: string;\n /** Initial metadata for the chat */\n metadata?: ChatMetadata;\n}\n\n/**\n * Options for listing chats.\n */\nexport interface ListChatsOptions {\n limit?: number;\n offset?: number;\n}\n\n/**\n * Abstract repository interface for chat persistence.\n * Implementations can store chats locally (localStorage, IndexedDB)\n * or remotely (REST API, GraphQL, etc.)\n */\nexport interface ChatRepository {\n /**\n * Creates a new chat and returns its ID.\n * @param options Optional configuration for the new chat\n * @returns Promise resolving to the new chat ID\n */\n createChat(options?: CreateChatOptions): Promise<string>;\n\n /**\n * Loads a chat by ID.\n * @param id Chat ID to load\n * @returns Promise resolving to the chat, or null if not found\n */\n loadChat(id: string): Promise<Chat | null>;\n\n /**\n * Saves or updates a chat.\n * @param chat Chat to save\n * @returns Promise resolving when save is complete\n */\n saveChat(chat: Chat): Promise<void>;\n\n /**\n * Deletes a chat by ID.\n * @param id Chat ID to delete\n * @returns Promise resolving when deletion is complete\n */\n deleteChat(id: string): Promise<void>;\n\n /**\n * Lists all available chats (metadata only, without full message history).\n * @param options Optional pagination and filtering options\n * @returns Promise resolving to array of chat metadata\n */\n listChats(options?: ListChatsOptions): Promise<Array<Omit<Chat, 'messages'>>>;\n\n /**\n * Deletes all stored chats.\n * @returns Promise resolving when all chats are deleted\n */\n deleteAll(): Promise<void>;\n\n /**\n * Updates metadata for a chat.\n * By default, merges with existing metadata. Set `overwrite: true` to replace entirely.\n * @param id Chat ID\n * @param metadata Metadata to set/merge\n * @param overwrite If true, replaces all metadata instead of merging\n * @returns Promise resolving when update is complete\n */\n updateMetadata(id: string, metadata: ChatMetadata, overwrite?: boolean): Promise<void>;\n}\n\n/**\n * Generates a unique chat ID.\n */\nexport function generateChatId(): string {\n return `chat_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n}\n\n/**\n * Generates a unique message ID.\n */\nexport function generateMessageId(): string {\n return `msg_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n}\n"],"mappings":";AAwJO,SAAS,iBAAyB;AACvC,SAAO,QAAQ,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC,CAAC;AACzE;AAKO,SAAS,oBAA4B;AAC1C,SAAO,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC,CAAC;AACxE;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/providers/chatRepository/types.ts"],"sourcesContent":["import type { PersistedFileMetadata } from '../../fileUpload/types';\nimport type { FeedbackValue } from '@meetsmore-oss/use-ai-core';\n\n/**\n * Arbitrary metadata attached to a chat.\n * Use this to store context about the chat (e.g., how it was invoked, document type being processed).\n */\nexport type ChatMetadata = Record<string, unknown>;\n\n/**\n * Display mode for chat messages.\n * Determines the visual styling of the message bubble.\n */\nexport type MessageDisplayMode = 'default' | 'error';\n\n/**\n * Text content part for persisted messages.\n */\nexport interface PersistedTextContent {\n type: 'text';\n text: string;\n}\n\n/**\n * File content part for persisted messages.\n * Only stores metadata, not the actual file data.\n */\nexport interface PersistedFileContent {\n type: 'file';\n file: PersistedFileMetadata;\n}\n\n/**\n * Content part for persisted messages.\n * Can be text or file metadata.\n */\nexport type PersistedContentPart = PersistedTextContent | PersistedFileContent;\n\n/**\n * Content that can be persisted.\n * Simple string for text-only messages, or array for multimodal content.\n */\nexport type PersistedMessageContent = string | PersistedContentPart[];\n\n/**\n * Message format for persisted chat history.\n * Compatible with AI SDK's UIMessage format for future integration.\n */\nexport interface PersistedMessage {\n id: string;\n role: 'user' | 'assistant' | 'tool';\n /** Content can be a string or multimodal content array */\n content: PersistedMessageContent;\n createdAt: Date;\n displayMode?: MessageDisplayMode;\n /** Langfuse trace ID for feedback tracking (only for assistant messages) */\n traceId?: string;\n /** User feedback on this message (only for assistant messages) */\n feedback?: FeedbackValue;\n}\n\n/**\n * Represents a stored chat conversation.\n */\nexport interface Chat {\n id: string;\n title?: string;\n messages: PersistedMessage[];\n createdAt: Date;\n updatedAt: Date;\n /** Arbitrary metadata attached to the chat */\n metadata?: ChatMetadata;\n}\n\n/**\n * Options for creating a new chat.\n */\nexport interface CreateChatOptions {\n title?: string;\n /** Initial metadata for the chat */\n metadata?: ChatMetadata;\n}\n\n/**\n * Options for listing chats.\n */\nexport interface ListChatsOptions {\n limit?: number;\n offset?: number;\n}\n\n/**\n * Abstract repository interface for chat persistence.\n * Implementations can store chats locally (localStorage, IndexedDB)\n * or remotely (REST API, GraphQL, etc.)\n */\nexport interface ChatRepository {\n /**\n * Creates a new chat and returns its ID.\n * @param options Optional configuration for the new chat\n * @returns Promise resolving to the new chat ID\n */\n createChat(options?: CreateChatOptions): Promise<string>;\n\n /**\n * Loads a chat by ID.\n * @param id Chat ID to load\n * @returns Promise resolving to the chat, or null if not found\n */\n loadChat(id: string): Promise<Chat | null>;\n\n /**\n * Saves or updates a chat.\n * @param chat Chat to save\n * @returns Promise resolving when save is complete\n */\n saveChat(chat: Chat): Promise<void>;\n\n /**\n * Deletes a chat by ID.\n * @param id Chat ID to delete\n * @returns Promise resolving when deletion is complete\n */\n deleteChat(id: string): Promise<void>;\n\n /**\n * Lists all available chats (metadata only, without full message history).\n * @param options Optional pagination and filtering options\n * @returns Promise resolving to array of chat metadata\n */\n listChats(options?: ListChatsOptions): Promise<Array<Omit<Chat, 'messages'>>>;\n\n /**\n * Deletes all stored chats.\n * @returns Promise resolving when all chats are deleted\n */\n deleteAll(): Promise<void>;\n\n /**\n * Updates metadata for a chat.\n * By default, merges with existing metadata. Set `overwrite: true` to replace entirely.\n * @param id Chat ID\n * @param metadata Metadata to set/merge\n * @param overwrite If true, replaces all metadata instead of merging\n * @returns Promise resolving when update is complete\n */\n updateMetadata(id: string, metadata: ChatMetadata, overwrite?: boolean): Promise<void>;\n}\n\n/**\n * Generates a unique chat ID.\n */\nexport function generateChatId(): string {\n return `chat_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n}\n\n/**\n * Generates a unique message ID.\n */\nexport function generateMessageId(): string {\n return `msg_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwJO,SAAS,iBAAyB;AACvC,SAAO,QAAQ,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC,CAAC;AACzE;AAKO,SAAS,oBAA4B;AAC1C,SAAO,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,UAAU,GAAG,CAAC,CAAC;AACxE;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export { z } from 'zod';
|
|
3
3
|
import * as _meetsmore_oss_use_ai_core from '@meetsmore-oss/use-ai-core';
|
|
4
|
-
import { ToolDefinition, WorkflowStatus, AgentInfo, McpHeadersMap, MultimodalContent, AGUIEvent, Message as Message$1, UseAIClientMessage } from '@meetsmore-oss/use-ai-core';
|
|
5
|
-
export { AgentInfo, ToolDefinition } from '@meetsmore-oss/use-ai-core';
|
|
4
|
+
import { ToolAnnotations, ToolDefinition, WorkflowStatus, FeedbackValue, AgentInfo, McpHeadersMap, MultimodalContent, AGUIEvent, Message as Message$1, UseAIClientMessage } from '@meetsmore-oss/use-ai-core';
|
|
5
|
+
export { AgentInfo, ToolAnnotations, ToolDefinition } from '@meetsmore-oss/use-ai-core';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
import React$1, { ReactNode } from 'react';
|
|
8
8
|
|
|
@@ -10,8 +10,8 @@ import React$1, { ReactNode } from 'react';
|
|
|
10
10
|
* Options for configuring tool behavior.
|
|
11
11
|
*/
|
|
12
12
|
interface ToolOptions {
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/** MCP-aligned annotations for tool behavior hints */
|
|
14
|
+
annotations?: ToolAnnotations;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* JSON Schema representation type (simplified)
|
|
@@ -465,6 +465,10 @@ interface PersistedMessage {
|
|
|
465
465
|
content: PersistedMessageContent;
|
|
466
466
|
createdAt: Date;
|
|
467
467
|
displayMode?: MessageDisplayMode$1;
|
|
468
|
+
/** Langfuse trace ID for feedback tracking (only for assistant messages) */
|
|
469
|
+
traceId?: string;
|
|
470
|
+
/** User feedback on this message (only for assistant messages) */
|
|
471
|
+
feedback?: FeedbackValue;
|
|
468
472
|
}
|
|
469
473
|
/**
|
|
470
474
|
* Represents a stored chat conversation.
|
|
@@ -645,6 +649,8 @@ declare const defaultStrings: {
|
|
|
645
649
|
connectingPlaceholder: string;
|
|
646
650
|
/** Loading indicator text */
|
|
647
651
|
thinking: string;
|
|
652
|
+
/** File processing indicator text (shown during file transformation like OCR) */
|
|
653
|
+
processingFile: string;
|
|
648
654
|
};
|
|
649
655
|
fileUpload: {
|
|
650
656
|
/** Attach files button tooltip */
|
|
@@ -692,6 +698,10 @@ declare const defaultStrings: {
|
|
|
692
698
|
/** Error for unknown/unexpected errors */
|
|
693
699
|
UNKNOWN_ERROR: string;
|
|
694
700
|
};
|
|
701
|
+
toolExecution: {
|
|
702
|
+
/** Fallback messages when no tool title is provided (one randomly selected) */
|
|
703
|
+
fallbackMessages: string[];
|
|
704
|
+
};
|
|
695
705
|
};
|
|
696
706
|
/**
|
|
697
707
|
* Customizable text labels for the chat UI.
|
|
@@ -805,6 +815,10 @@ interface Message {
|
|
|
805
815
|
timestamp: Date;
|
|
806
816
|
/** Display mode for styling the message bubble */
|
|
807
817
|
displayMode?: MessageDisplayMode;
|
|
818
|
+
/** Langfuse trace ID for feedback tracking (only for assistant messages) */
|
|
819
|
+
traceId?: string;
|
|
820
|
+
/** User feedback on this message (only for assistant messages) */
|
|
821
|
+
feedback?: FeedbackValue;
|
|
808
822
|
}
|
|
809
823
|
/**
|
|
810
824
|
* Props for the chat panel component.
|
|
@@ -829,18 +843,28 @@ interface UseAIChatPanelProps {
|
|
|
829
843
|
selectedAgent?: string | null;
|
|
830
844
|
onAgentChange?: (agentId: string | null) => void;
|
|
831
845
|
fileUploadConfig?: FileUploadConfig;
|
|
846
|
+
/** File processing state for send-time transformations (e.g., OCR) */
|
|
847
|
+
fileProcessing?: FileProcessingState | null;
|
|
832
848
|
commands?: SavedCommand[];
|
|
833
849
|
onSaveCommand?: (name: string, text: string) => Promise<string>;
|
|
834
850
|
onRenameCommand?: (id: string, newName: string) => Promise<void>;
|
|
835
851
|
onDeleteCommand?: (id: string) => Promise<void>;
|
|
836
852
|
/** Optional close button to render in header (for floating mode) */
|
|
837
853
|
closeButton?: React$1.ReactNode;
|
|
854
|
+
/** Currently executing tool info for status display */
|
|
855
|
+
executingTool?: {
|
|
856
|
+
displayText: string;
|
|
857
|
+
} | null;
|
|
858
|
+
/** Whether feedback buttons are enabled (requires Langfuse on server) */
|
|
859
|
+
feedbackEnabled?: boolean;
|
|
860
|
+
/** Callback when user submits feedback on a message */
|
|
861
|
+
onFeedback?: (messageId: string, traceId: string, feedback: FeedbackValue) => void;
|
|
838
862
|
}
|
|
839
863
|
/**
|
|
840
864
|
* Chat panel content - fills its container.
|
|
841
865
|
* Use directly for embedded mode, or wrap with UseAIFloatingChatWrapper for floating mode.
|
|
842
866
|
*/
|
|
843
|
-
declare function UseAIChatPanel({ onSendMessage, messages, loading, connected, streamingText, currentChatId, onNewChat, onLoadChat, onDeleteChat, onListChats, onGetChat, suggestions, availableAgents, defaultAgent, selectedAgent, onAgentChange, fileUploadConfig, commands, onSaveCommand, onRenameCommand, onDeleteCommand, closeButton, }: UseAIChatPanelProps): react_jsx_runtime.JSX.Element;
|
|
867
|
+
declare function UseAIChatPanel({ onSendMessage, messages, loading, connected, streamingText, currentChatId, onNewChat, onLoadChat, onDeleteChat, onListChats, onGetChat, suggestions, availableAgents, defaultAgent, selectedAgent, onAgentChange, fileUploadConfig, fileProcessing, commands, onSaveCommand, onRenameCommand, onDeleteCommand, closeButton, executingTool, feedbackEnabled, onFeedback, }: UseAIChatPanelProps): react_jsx_runtime.JSX.Element;
|
|
844
868
|
|
|
845
869
|
/**
|
|
846
870
|
* Handler for AG-UI events from the server.
|
|
@@ -888,6 +912,8 @@ declare class UseAIClient {
|
|
|
888
912
|
private _currentAssistantMessage;
|
|
889
913
|
private _currentAssistantToolCalls;
|
|
890
914
|
private currentToolCalls;
|
|
915
|
+
private _langfuseEnabled;
|
|
916
|
+
private langfuseConfigHandlers;
|
|
891
917
|
/**
|
|
892
918
|
* Creates a new UseAI client instance.
|
|
893
919
|
*
|
|
@@ -1058,6 +1084,22 @@ declare class UseAIClient {
|
|
|
1058
1084
|
* @returns true if connected, false otherwise
|
|
1059
1085
|
*/
|
|
1060
1086
|
isConnected(): boolean;
|
|
1087
|
+
/**
|
|
1088
|
+
* Subscribes to Langfuse config changes.
|
|
1089
|
+
*
|
|
1090
|
+
* @param handler - Callback function receiving langfuse enabled status
|
|
1091
|
+
* @returns Cleanup function to unsubscribe
|
|
1092
|
+
*/
|
|
1093
|
+
onLangfuseConfigChange(handler: (enabled: boolean) => void): () => void;
|
|
1094
|
+
/**
|
|
1095
|
+
* Submits feedback for an assistant message.
|
|
1096
|
+
* Sends feedback to the server, which forwards it to Langfuse.
|
|
1097
|
+
*
|
|
1098
|
+
* @param messageId - The client-side message ID
|
|
1099
|
+
* @param traceId - The Langfuse trace ID (runId from RUN_FINISHED)
|
|
1100
|
+
* @param feedback - 'upvote' for positive, 'downvote' for negative, null to remove
|
|
1101
|
+
*/
|
|
1102
|
+
submitFeedback(messageId: string, traceId: string, feedback: FeedbackValue): void;
|
|
1061
1103
|
}
|
|
1062
1104
|
|
|
1063
1105
|
/**
|
|
@@ -1078,6 +1120,10 @@ interface UseChatManagementOptions {
|
|
|
1078
1120
|
repository: ChatRepository;
|
|
1079
1121
|
/** Reference to the UseAIClient (can be null during initialization) */
|
|
1080
1122
|
clientRef: React.MutableRefObject<UseAIClient | null>;
|
|
1123
|
+
/** Current messages state (owned by provider) */
|
|
1124
|
+
messages: Message[];
|
|
1125
|
+
/** Setter for messages state (owned by provider) */
|
|
1126
|
+
setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
|
|
1081
1127
|
/** Callback to send a message (from UseAIProvider) */
|
|
1082
1128
|
onSendMessage?: (message: string, attachments?: FileAttachment[]) => Promise<void>;
|
|
1083
1129
|
/** Callback to open/close the chat panel */
|
|
@@ -1092,8 +1138,6 @@ interface UseChatManagementReturn {
|
|
|
1092
1138
|
currentChatId: string | null;
|
|
1093
1139
|
/** Chat loaded for viewing but not yet active for AI responses */
|
|
1094
1140
|
pendingChatId: string | null;
|
|
1095
|
-
/** Current messages in the chat */
|
|
1096
|
-
messages: Message[];
|
|
1097
1141
|
/** The displayed chat ID (pending or current) */
|
|
1098
1142
|
displayedChatId: string | null;
|
|
1099
1143
|
/** Creates a new chat and switches to it */
|
|
@@ -1111,7 +1155,7 @@ interface UseChatManagementReturn {
|
|
|
1111
1155
|
/** Saves a user message to storage and reloads messages */
|
|
1112
1156
|
saveUserMessage: (chatId: string, content: PersistedMessageContent) => Promise<boolean>;
|
|
1113
1157
|
/** Saves an AI response to storage and optionally reloads messages */
|
|
1114
|
-
saveAIResponse: (content: string, displayMode?: 'default' | 'error') => Promise<void>;
|
|
1158
|
+
saveAIResponse: (content: string, displayMode?: 'default' | 'error', traceId?: string) => Promise<void>;
|
|
1115
1159
|
/** Reloads messages from storage for the given chat ID */
|
|
1116
1160
|
reloadMessages: (chatId: string) => Promise<void>;
|
|
1117
1161
|
/**
|
|
@@ -1142,7 +1186,6 @@ interface UseChatManagementReturn {
|
|
|
1142
1186
|
* const {
|
|
1143
1187
|
* currentChatId,
|
|
1144
1188
|
* pendingChatId,
|
|
1145
|
-
* messages,
|
|
1146
1189
|
* createNewChat,
|
|
1147
1190
|
* loadChat,
|
|
1148
1191
|
* deleteChat,
|
|
@@ -1154,10 +1197,12 @@ interface UseChatManagementReturn {
|
|
|
1154
1197
|
* } = useChatManagement({
|
|
1155
1198
|
* repository: chatRepository,
|
|
1156
1199
|
* clientRef,
|
|
1200
|
+
* messages,
|
|
1201
|
+
* setMessages,
|
|
1157
1202
|
* });
|
|
1158
1203
|
* ```
|
|
1159
1204
|
*/
|
|
1160
|
-
declare function useChatManagement({ repository, clientRef, onSendMessage, setOpen, connected, loading, }: UseChatManagementOptions): UseChatManagementReturn;
|
|
1205
|
+
declare function useChatManagement({ repository, clientRef, messages, setMessages, onSendMessage, setOpen, connected, loading, }: UseChatManagementOptions): UseChatManagementReturn;
|
|
1161
1206
|
|
|
1162
1207
|
/**
|
|
1163
1208
|
* Chat management context (from useChatManagement hook).
|
|
@@ -2080,6 +2125,43 @@ interface UsePromptStateReturn {
|
|
|
2080
2125
|
*/
|
|
2081
2126
|
declare function usePromptState({ systemPrompt, clientRef, connected, }: UsePromptStateOptions): UsePromptStateReturn;
|
|
2082
2127
|
|
|
2128
|
+
interface UseFeedbackOptions {
|
|
2129
|
+
/** Reference to the UseAIClient */
|
|
2130
|
+
clientRef: React.MutableRefObject<UseAIClient | null>;
|
|
2131
|
+
/** Chat repository for persisting feedback */
|
|
2132
|
+
repository: ChatRepository;
|
|
2133
|
+
/** Callback to get the currently displayed chat ID */
|
|
2134
|
+
getDisplayedChatId: () => string | null;
|
|
2135
|
+
/** Setter for messages state (for optimistic UI updates) */
|
|
2136
|
+
setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
|
|
2137
|
+
}
|
|
2138
|
+
interface UseFeedbackReturn {
|
|
2139
|
+
/** Whether Langfuse feedback is enabled on the server */
|
|
2140
|
+
enabled: boolean;
|
|
2141
|
+
/** Submits feedback for a message (updates storage and sends to server) */
|
|
2142
|
+
submitFeedback: (messageId: string, traceId: string, feedback: FeedbackValue) => void;
|
|
2143
|
+
}
|
|
2144
|
+
/**
|
|
2145
|
+
* Hook for managing user feedback on AI messages.
|
|
2146
|
+
*
|
|
2147
|
+
* Responsibilities:
|
|
2148
|
+
* - Tracks whether Langfuse feedback is enabled on the server
|
|
2149
|
+
* - Captures traceId from RUN_FINISHED events
|
|
2150
|
+
* - Persists feedback to chat storage
|
|
2151
|
+
* - Sends feedback to server (Langfuse)
|
|
2152
|
+
*
|
|
2153
|
+
* @example
|
|
2154
|
+
* ```typescript
|
|
2155
|
+
* const { enabled, getTraceId, clearTraceId, submitFeedback } = useFeedback({
|
|
2156
|
+
* clientRef,
|
|
2157
|
+
* repository,
|
|
2158
|
+
* getDisplayedChatId: () => displayedChatId,
|
|
2159
|
+
* setMessages,
|
|
2160
|
+
* });
|
|
2161
|
+
* ```
|
|
2162
|
+
*/
|
|
2163
|
+
declare function useFeedback({ clientRef, repository, getDisplayedChatId, setMessages, }: UseFeedbackOptions): UseFeedbackReturn;
|
|
2164
|
+
|
|
2083
2165
|
/**
|
|
2084
2166
|
* Creates stable tool references that maintain fresh closures.
|
|
2085
2167
|
*
|
|
@@ -2088,7 +2170,7 @@ declare function usePromptState({ systemPrompt, clientRef, connected, }: UseProm
|
|
|
2088
2170
|
*
|
|
2089
2171
|
* 1. Tool object references remain stable as long as tool names don't change
|
|
2090
2172
|
* 2. Handler calls are proxied through refs to always use the latest closure
|
|
2091
|
-
* 3. Metadata (description, schema,
|
|
2173
|
+
* 3. Metadata (description, schema, annotations) updates in-place
|
|
2092
2174
|
*
|
|
2093
2175
|
* @param tools - The tools definition from the user (potentially unstable references)
|
|
2094
2176
|
* @returns Stabilized tools definition that won't cause effect re-runs
|
|
@@ -2162,4 +2244,4 @@ interface UseDropdownStateOptions {
|
|
|
2162
2244
|
*/
|
|
2163
2245
|
declare function useDropdownState(options?: UseDropdownStateOptions): UseDropdownStateReturn;
|
|
2164
2246
|
|
|
2165
|
-
export { type AgentContextValue, type Chat, type ChatContextValue, type ChatMetadata, type ChatPanelProps, type ChatRepository, CloseButton, type CommandContextValue, type CommandRepository, type CreateChatOptions, type CreateCommandOptions, DEFAULT_MAX_FILE_SIZE, type DefinedTool, type DropZoneProps, EmbedFileUploadBackend, type FileAttachment, type FileProcessingState, type FileProcessingStatus, type FileTransformer, type FileTransformerContext, type FileTransformerMap, type FileUploadBackend, type FileUploadConfig, type FloatingButtonProps, type InlineSaveProps, type ListChatsOptions, type ListCommandsOptions, LocalStorageChatRepository, LocalStorageCommandRepository, type Message, type PersistedContentPart, type PersistedFileContent, type PersistedFileMetadata, type PersistedMessage, type PersistedMessageContent, type PersistedTextContent, type ProcessAttachmentsConfig, type PromptsContextValue, type RegisterToolsOptions, type SavedCommand, type SendMessageOptions, type ToolOptions, type ToolRegistryContextValue, type ToolsDefinition, type TriggerWorkflowOptions, UseAIChat, UseAIChatPanel, type UseAIChatPanelProps, type UseAIChatPanelStrings, type UseAIChatPanelTheme, type UseAIChatProps, UseAIClient, type UseAIConfig, type UseAIContextValue, UseAIFloatingButton, UseAIFloatingChatWrapper, type UseAIOptions, UseAIProvider, type UseAIProviderProps, type UseAIResult, type UseAIStrings, type UseAITheme, type UseAIWorkflowResult, type UseAgentSelectionOptions, type UseAgentSelectionReturn, type UseChatManagementOptions, type UseChatManagementReturn, type UseCommandManagementOptions, type UseCommandManagementReturn, type UseDropdownStateOptions, type UseDropdownStateReturn, type UseFileUploadOptions, type UseFileUploadReturn, type UsePromptStateOptions, type UsePromptStateReturn, type UseSlashCommandsOptions, type UseSlashCommandsReturn, type UseToolRegistryReturn, type WorkflowProgress, clearTransformationCache, convertToolsToDefinitions, defaultStrings, defaultTheme, defineTool, executeDefinedTool, findTransformer, generateChatId, generateCommandId, generateMessageId, matchesMimeType, processAttachments, useAI, useAIContext, useAIWorkflow, useAgentSelection, useChatManagement, useCommandManagement, useDropdownState, useFileUpload, usePromptState, useSlashCommands, useStableTools, useStrings, useTheme, useToolRegistry, validateCommandName };
|
|
2247
|
+
export { type AgentContextValue, type Chat, type ChatContextValue, type ChatMetadata, type ChatPanelProps, type ChatRepository, CloseButton, type CommandContextValue, type CommandRepository, type CreateChatOptions, type CreateCommandOptions, DEFAULT_MAX_FILE_SIZE, type DefinedTool, type DropZoneProps, EmbedFileUploadBackend, type FileAttachment, type FileProcessingState, type FileProcessingStatus, type FileTransformer, type FileTransformerContext, type FileTransformerMap, type FileUploadBackend, type FileUploadConfig, type FloatingButtonProps, type InlineSaveProps, type ListChatsOptions, type ListCommandsOptions, LocalStorageChatRepository, LocalStorageCommandRepository, type Message, type PersistedContentPart, type PersistedFileContent, type PersistedFileMetadata, type PersistedMessage, type PersistedMessageContent, type PersistedTextContent, type ProcessAttachmentsConfig, type PromptsContextValue, type RegisterToolsOptions, type SavedCommand, type SendMessageOptions, type ToolOptions, type ToolRegistryContextValue, type ToolsDefinition, type TriggerWorkflowOptions, UseAIChat, UseAIChatPanel, type UseAIChatPanelProps, type UseAIChatPanelStrings, type UseAIChatPanelTheme, type UseAIChatProps, UseAIClient, type UseAIConfig, type UseAIContextValue, UseAIFloatingButton, UseAIFloatingChatWrapper, type UseAIOptions, UseAIProvider, type UseAIProviderProps, type UseAIResult, type UseAIStrings, type UseAITheme, type UseAIWorkflowResult, type UseAgentSelectionOptions, type UseAgentSelectionReturn, type UseChatManagementOptions, type UseChatManagementReturn, type UseCommandManagementOptions, type UseCommandManagementReturn, type UseDropdownStateOptions, type UseDropdownStateReturn, type UseFeedbackOptions, type UseFeedbackReturn, type UseFileUploadOptions, type UseFileUploadReturn, type UsePromptStateOptions, type UsePromptStateReturn, type UseSlashCommandsOptions, type UseSlashCommandsReturn, type UseToolRegistryReturn, type WorkflowProgress, clearTransformationCache, convertToolsToDefinitions, defaultStrings, defaultTheme, defineTool, executeDefinedTool, findTransformer, generateChatId, generateCommandId, generateMessageId, matchesMimeType, processAttachments, useAI, useAIContext, useAIWorkflow, useAgentSelection, useChatManagement, useCommandManagement, useDropdownState, useFeedback, useFileUpload, usePromptState, useSlashCommands, useStableTools, useStrings, useTheme, useToolRegistry, validateCommandName };
|