@aleph-alpha/chat-kit 1.4.0 → 1.5.1

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/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  export { type ChatConfig, type ChatMessage, type ChatResponse, type ConversationSummary, type HttpClient, type RawConversation, type RawConversationList, type StreamEvent, } from './services';
2
2
  export { useMessageHandler, useMarkdownParser, provideChatKitLabels, useChatKitLabels, defaultChatKitLabels, CHAT_KIT_LABELS, } from './handlers';
3
3
  export type { ChatKitLabels } from './handlers';
4
- export { useChat, useConversationSessions, useConversations, } from './composables';
5
- export type { ChatActions, ChatState, ConversationSession, CreateConversationInput, MessageHandler, MutationOptions, UseChatReturn, UseConversationSessionsReturn, UseConversationsOptions, UseConversationsReturn, } from './composables';
4
+ export * from './composables';
6
5
  export { CkAgentMessage, CkConversation, CkConversationLayout, CkCopyMessageActionButton, CkFeedbackButton, CkHistory, CkHistoryItem, CkHistoryWrapper, CkInput, CkMarkdownRenderer, CkMessageActionButton, CkPromptActionButton, CkPromptStopButton, CkPromptInput, CkPromptInputDisclaimer, CkSendIcon, CkStopIcon, CkUserMessage, } from './components';
7
6
  export type { CkConversationLayoutProps, CkConversationProps, CkFeedbackButtonProps, CkFeedbackValue, CkHistoryEmits, CkHistoryItemEmits, CkHistoryItemProps, CkHistoryProps, CkHistoryWrapperProps, CkMarkdownElementClasses, CkMarkdownRendererProps, CkUserMessageProps, } from './components';
8
7
  export type { BaseMessage, Conversation, ConversationTree, MessageContent, MessageContentStatus, MessageReasoningContent, MessageRole, MessageStatus, MessageTextContent, MessageToolContent, TreeMessage, } from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AASpB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EACL,OAAO,EACP,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,aAAa,EACb,6BAA6B,EAC7B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAGvB,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,GACZ,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AASpB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,cAAc,eAAe,CAAC;AAG9B,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,GACZ,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { u } from "./useMessageHandler-ZRC-gIOJ.js";
2
2
  import { C, d, p, u as u2, a } from "./useChatKitLabels-ftC52m7f.js";
3
- import { u as u3, a as a2, b } from "./useConversationSessions-GLZV_Ctr.js";
4
- import { _, a as a3, b as b2, C as C2, c, d as d2, e, f, g, h, i, j, k, l, m, n, o, p as p2 } from "./CkInput.vue_vue_type_script_setup_true_lang-C5C09u0z.js";
3
+ import { c, d as d2, u as u3, a as a2, b, e } from "./index-BbTgIoYa.js";
4
+ import { _, a as a3, b as b2, C as C2, c as c2, d as d3, e as e2, f, g, h, i, j, k, l, m, n, o, p as p2 } from "./CkInput.vue_vue_type_script_setup_true_lang-C5C09u0z.js";
5
5
  export {
6
6
  C as CHAT_KIT_LABELS,
7
7
  _ as CkAgentMessage,
8
8
  a3 as CkConversation,
9
9
  b2 as CkConversationLayout,
10
10
  C2 as CkCopyMessageActionButton,
11
- c as CkFeedbackButton,
12
- d2 as CkHistory,
13
- e as CkHistoryItem,
11
+ c2 as CkFeedbackButton,
12
+ d3 as CkHistory,
13
+ e2 as CkHistoryItem,
14
14
  f as CkHistoryWrapper,
15
15
  g as CkInput,
16
16
  h as CkMarkdownRenderer,
@@ -22,12 +22,15 @@ export {
22
22
  n as CkSendIcon,
23
23
  o as CkStopIcon,
24
24
  p2 as CkUserMessage,
25
+ c as createDocumentUploadProvider,
25
26
  d as defaultChatKitLabels,
27
+ d2 as defaultDocumentUploadConfig,
26
28
  p as provideChatKitLabels,
27
29
  u3 as useChat,
28
30
  u2 as useChatKitLabels,
29
31
  a2 as useConversationSessions,
30
32
  b as useConversations,
33
+ e as useDocumentUploadWithDefaultConfig,
31
34
  a as useMarkdownParser,
32
35
  u as useMessageHandler
33
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aleph-alpha/chat-kit",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "Chat kit package for building chat interfaces with Vue",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,213 @@
1
+ import {
2
+ defaultDocumentUploadConfig,
3
+ createDocumentUploadProvider,
4
+ } from './index';
5
+ import type { DocumentUploadConfig } from './types';
6
+
7
+ vi.mock('./useFileUploadWrapper', () => ({
8
+ createDocumentUploadProvider: vi.fn((config: DocumentUploadConfig) => ({
9
+ useDocumentUpload: vi.fn(() => ({
10
+ upload: {},
11
+ storeId: { value: '' },
12
+ fileInput: { value: null },
13
+ uploadFiles: vi.fn(),
14
+ unassignedFiles: { value: [] },
15
+ assignFilesToMessage: vi.fn(),
16
+ getFilesForMessage: vi.fn(() => []),
17
+ stampResponseId: vi.fn(),
18
+ purgeCompletedFiles: vi.fn(),
19
+ handleFilesSelected: vi.fn(),
20
+ })),
21
+ _config: config,
22
+ })),
23
+ }));
24
+
25
+ describe('fileUpload index', () => {
26
+ describe('defaultDocumentUploadConfig', () => {
27
+ it('uses the correct base URL', () => {
28
+ expect(defaultDocumentUploadConfig.baseUrl).toBe('/file-upload');
29
+ });
30
+
31
+ it('uses the correct userId', () => {
32
+ expect(defaultDocumentUploadConfig.userId).toBe('chat-user');
33
+ });
34
+
35
+ it('uses the correct workflowId', () => {
36
+ expect(defaultDocumentUploadConfig.workflowId).toBe('my-doc-ai');
37
+ });
38
+
39
+ it('configures searchStoreConfig with a dense model', () => {
40
+ const { searchStoreConfig } = defaultDocumentUploadConfig;
41
+ expect(searchStoreConfig.models).toHaveLength(1);
42
+ expect(searchStoreConfig.models[0]).toEqual({
43
+ type: 'dense',
44
+ dimension: 1024,
45
+ distance: 'cosine',
46
+ modality: 'text',
47
+ embedding_model: 'baai/bge-m3',
48
+ });
49
+ });
50
+
51
+ it('configures searchStoreConfig with rrf fusion strategy', () => {
52
+ expect(
53
+ defaultDocumentUploadConfig.searchStoreConfig.fusion_strategy,
54
+ ).toEqual({
55
+ type: 'rrf',
56
+ });
57
+ });
58
+
59
+ it('configures workflowConfig with the correct workflow name', () => {
60
+ const { workflowConfig } = defaultDocumentUploadConfig;
61
+ expect(workflowConfig.name).toBe('my-doc-ai');
62
+ expect(workflowConfig.workflow_name).toBe('DocumentAI');
63
+ });
64
+
65
+ it('configures workflowConfig definition', () => {
66
+ const { workflowConfig } = defaultDocumentUploadConfig;
67
+ expect(workflowConfig.definition).toEqual({
68
+ workflow_name: 'DocumentAI',
69
+ });
70
+ });
71
+
72
+ it('configures initialization parameters', () => {
73
+ const params = defaultDocumentUploadConfig.workflowConfig
74
+ .parameters as Record<string, unknown>;
75
+ expect(params.initialization).toEqual({
76
+ store: { batch_size: 10, pages_per_part: 25 },
77
+ });
78
+ });
79
+
80
+ it('configures all document extraction readers', () => {
81
+ const params = defaultDocumentUploadConfig.workflowConfig
82
+ .parameters as Record<string, unknown>;
83
+ const extraction = params.document_extraction as Record<string, unknown>;
84
+
85
+ expect(extraction.pdf_reader).toEqual({ kind: 'pypdf', batch_size: 10 });
86
+ expect(extraction.docx_reader).toEqual({
87
+ kind: 'docx',
88
+ batch_size: 10,
89
+ split_by_sections: false,
90
+ });
91
+ expect(extraction.pptx_reader).toEqual({
92
+ kind: 'pptx',
93
+ batch_size: 10,
94
+ include_notes: true,
95
+ });
96
+ expect(extraction.xlsx_reader).toEqual({
97
+ kind: 'xlsx',
98
+ batch_size: 10,
99
+ max_rows: 10000,
100
+ max_cols: 100,
101
+ include_empty_sheets: false,
102
+ });
103
+ expect(extraction.markdown_reader).toEqual({
104
+ kind: 'markdown',
105
+ batch_size: 10,
106
+ });
107
+ expect(extraction.plaintext_reader).toEqual({
108
+ kind: 'plaintext',
109
+ batch_size: 10,
110
+ max_content_size: 500000,
111
+ min_space_ratio: 0.02,
112
+ });
113
+ });
114
+
115
+ it('configures chunk extraction parameters', () => {
116
+ const params = defaultDocumentUploadConfig.workflowConfig
117
+ .parameters as Record<string, unknown>;
118
+ const chunkExtraction = params.chunk_extraction as Record<
119
+ string,
120
+ unknown
121
+ >;
122
+ expect(chunkExtraction.chunker).toEqual({
123
+ kind: 'naive',
124
+ batch_size: 1,
125
+ include_image_descriptions: false,
126
+ chunk_size: 200,
127
+ });
128
+ });
129
+
130
+ it('configures workflowConfig schema', () => {
131
+ const { workflowConfig } = defaultDocumentUploadConfig;
132
+ expect(workflowConfig.schema).toEqual({
133
+ type: 'object',
134
+ properties: {
135
+ source: {
136
+ description: 'Source path, connector URI, or list thereof',
137
+ anyOf: [
138
+ { type: 'string' },
139
+ { type: 'array', items: { type: 'string' } },
140
+ ],
141
+ },
142
+ },
143
+ additionalProperties: true,
144
+ });
145
+ });
146
+ });
147
+
148
+ describe('createDocumentUploadProvider', () => {
149
+ it('is re-exported from useFileUploadWrapper', () => {
150
+ expect(createDocumentUploadProvider).toBeDefined();
151
+ expect(typeof createDocumentUploadProvider).toBe('function');
152
+ });
153
+
154
+ it('returns a provider with useDocumentUpload', () => {
155
+ const provider = createDocumentUploadProvider(
156
+ defaultDocumentUploadConfig,
157
+ );
158
+ expect(provider).toHaveProperty('useDocumentUpload');
159
+ expect(typeof provider.useDocumentUpload).toBe('function');
160
+ });
161
+
162
+ it('passes the config to createDocumentUploadProvider', () => {
163
+ const customConfig: DocumentUploadConfig = {
164
+ baseUrl: '/custom-url',
165
+ userId: 'custom-user',
166
+ workflowId: 'custom-workflow',
167
+ searchStoreConfig: {
168
+ models: [
169
+ {
170
+ type: 'dense',
171
+ dimension: 512,
172
+ distance: 'euclidean',
173
+ modality: 'text',
174
+ embedding_model: 'custom-model',
175
+ },
176
+ ],
177
+ fusion_strategy: { type: 'custom' },
178
+ },
179
+ workflowConfig: { name: 'custom' },
180
+ };
181
+
182
+ const provider = createDocumentUploadProvider(
183
+ customConfig,
184
+ ) as unknown as {
185
+ useDocumentUpload: () => unknown;
186
+ _config: DocumentUploadConfig;
187
+ };
188
+ expect(provider._config).toBe(customConfig);
189
+ });
190
+ });
191
+
192
+ describe('useDocumentUploadWithDefaultConfig', () => {
193
+ it('is exported and callable', async () => {
194
+ const { useDocumentUploadWithDefaultConfig } = await import('./index');
195
+ expect(useDocumentUploadWithDefaultConfig).toBeDefined();
196
+ expect(typeof useDocumentUploadWithDefaultConfig).toBe('function');
197
+ });
198
+ });
199
+
200
+ describe('type exports', () => {
201
+ it('exports DocumentUploadConfig type', async () => {
202
+ const module = await import('./index');
203
+ expect('defaultDocumentUploadConfig' in module).toBe(true);
204
+ });
205
+
206
+ it('exports DocumentUploadProvider type via createDocumentUploadProvider', () => {
207
+ const provider = createDocumentUploadProvider(
208
+ defaultDocumentUploadConfig,
209
+ );
210
+ expect(provider).toBeDefined();
211
+ });
212
+ });
213
+ });
@@ -0,0 +1,83 @@
1
+ import type { DocumentUploadConfig, DocumentUploadProvider } from './types';
2
+ import { createDocumentUploadProvider } from './useFileUploadWrapper';
3
+
4
+ const WORKFLOW_ID = 'my-doc-ai';
5
+
6
+ export const defaultDocumentUploadConfig: DocumentUploadConfig = {
7
+ baseUrl: '/file-upload',
8
+ userId: 'chat-user',
9
+ workflowId: WORKFLOW_ID,
10
+ searchStoreConfig: {
11
+ models: [
12
+ {
13
+ type: 'dense',
14
+ dimension: 1024,
15
+ distance: 'cosine',
16
+ modality: 'text',
17
+ embedding_model: 'baai/bge-m3',
18
+ },
19
+ ],
20
+ fusion_strategy: { type: 'rrf' },
21
+ },
22
+ workflowConfig: {
23
+ name: WORKFLOW_ID,
24
+ workflow_name: 'DocumentAI',
25
+ definition: { workflow_name: 'DocumentAI' },
26
+ parameters: {
27
+ initialization: {
28
+ store: { batch_size: 10, pages_per_part: 25 },
29
+ },
30
+ document_extraction: {
31
+ pdf_reader: { kind: 'pypdf', batch_size: 10 },
32
+ docx_reader: {
33
+ kind: 'docx',
34
+ batch_size: 10,
35
+ split_by_sections: false,
36
+ },
37
+ pptx_reader: { kind: 'pptx', batch_size: 10, include_notes: true },
38
+ xlsx_reader: {
39
+ kind: 'xlsx',
40
+ batch_size: 10,
41
+ max_rows: 10000,
42
+ max_cols: 100,
43
+ include_empty_sheets: false,
44
+ },
45
+ markdown_reader: { kind: 'markdown', batch_size: 10 },
46
+ plaintext_reader: {
47
+ kind: 'plaintext',
48
+ batch_size: 10,
49
+ max_content_size: 500000,
50
+ min_space_ratio: 0.02,
51
+ },
52
+ },
53
+ chunk_extraction: {
54
+ chunker: {
55
+ kind: 'naive',
56
+ batch_size: 1,
57
+ include_image_descriptions: false,
58
+ chunk_size: 200,
59
+ },
60
+ },
61
+ },
62
+ schema: {
63
+ type: 'object',
64
+ properties: {
65
+ source: {
66
+ description: 'Source path, connector URI, or list thereof',
67
+ anyOf: [
68
+ { type: 'string' },
69
+ { type: 'array', items: { type: 'string' } },
70
+ ],
71
+ },
72
+ },
73
+ additionalProperties: true,
74
+ },
75
+ },
76
+ };
77
+
78
+ const { useDocumentUpload: useDocumentUploadWithDefaultConfig } =
79
+ createDocumentUploadProvider(defaultDocumentUploadConfig);
80
+
81
+ export { useDocumentUploadWithDefaultConfig, createDocumentUploadProvider };
82
+
83
+ export type { DocumentUploadConfig, DocumentUploadProvider };