@quidgest/chatbot 0.5.3-dev.0 → 0.5.3
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/components/ChatBot/ChatBot.vue.d.ts +0 -2
- package/dist/components/ChatBot/types.d.ts +4 -3
- package/dist/components/ChatBotInput/ChatBotInput.vue.d.ts +3 -3
- package/dist/components/ChatBotInput/index.d.ts +2 -2
- package/dist/components/ChatBotInput/types.d.ts +4 -4
- package/dist/components/ChatBotMessage/ChatBotMessage.vue.d.ts +1 -3
- package/dist/components/ChatBotMessage/__tests__/ChatBotMessage.spec.d.ts +1 -0
- package/dist/components/ChatBotMessage/types.d.ts +3 -2
- package/dist/components/FieldPreview/FieldPreview.vue.d.ts +0 -2
- package/dist/composables/useChatApi.d.ts +1 -1
- package/dist/composables/useChatMessages.d.ts +2 -2
- package/dist/composables/useTexts.d.ts +1 -4
- package/dist/index.js +25 -25
- package/dist/index.mjs +2308 -1661
- package/dist/style.css +1 -1
- package/package.json +3 -2
- package/src/assets/styles/preview-file.scss +70 -0
- package/src/assets/styles/styles.scss +9 -33
- package/src/components/ChatBot/ChatBot.vue +70 -71
- package/src/components/ChatBot/types.ts +4 -3
- package/src/components/ChatBotInput/ChatBotInput.vue +81 -74
- package/src/components/ChatBotInput/__tests__/ChatBotInput.spec.ts +29 -42
- package/src/components/ChatBotInput/__tests__/__snapshots__/ChatBotInput.spec.ts.snap +5 -5
- package/src/components/ChatBotInput/index.ts +2 -2
- package/src/components/ChatBotInput/types.ts +4 -4
- package/src/components/ChatBotMessage/ChatBotMessage.vue +34 -8
- package/src/components/ChatBotMessage/__tests__/ChatBotMessage.spec.ts +256 -0
- package/src/components/ChatBotMessage/__tests__/ChatBotMessageButtons.spec.ts +4 -4
- package/src/components/ChatBotMessage/__tests__/__snapshots__/ChatBotMessage.spec.ts.snap +35 -0
- package/src/components/ChatBotMessage/types.ts +4 -3
- package/src/components/ChatToolBar/ChatToolBar.vue +1 -2
- package/src/components/ChatToolBar/__tests__/ChatToolBar.spec.ts +18 -38
- package/src/components/FieldPreview/FieldPreview.vue +9 -31
- package/src/components/FieldPreview/__tests__/__snapshots__/FieldPreview.spec.ts.snap +11 -5
- package/src/components/FieldPreview/field-preview.scss +0 -4
- package/src/components/MarkdownRender/MarkdownRender.vue +0 -1
- package/src/composables/__tests__/useChatMessages.spec.ts +1 -14
- package/src/composables/useChatApi.ts +53 -57
- package/src/composables/useChatMessages.ts +4 -8
- package/src/composables/useTexts.ts +2 -5
- package/src/test/setup.ts +0 -5
|
@@ -56,62 +56,6 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
56
56
|
})
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
async function sendPrompt(
|
|
60
|
-
formData: FormData,
|
|
61
|
-
onChunk: (chunk: string) => void,
|
|
62
|
-
onError?: (error: Error) => void
|
|
63
|
-
) {
|
|
64
|
-
isLoading.value = true
|
|
65
|
-
try {
|
|
66
|
-
return await useSSE(
|
|
67
|
-
{
|
|
68
|
-
method: 'POST',
|
|
69
|
-
url: `${apiEndpoint}/prompt/submit`,
|
|
70
|
-
data: formData
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
onMessage: (data) => {
|
|
74
|
-
onChunk(data)
|
|
75
|
-
},
|
|
76
|
-
onDone: () => (isLoading.value = false)
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
} catch (error) {
|
|
80
|
-
isLoading.value = false
|
|
81
|
-
onError?.(error as Error)
|
|
82
|
-
console.error('Error in sendPrompt:', error)
|
|
83
|
-
throw error
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async function getJobResultData(
|
|
88
|
-
jobId: string,
|
|
89
|
-
onChunk: (chunk: string) => void,
|
|
90
|
-
onMetaData: (metadata: Record<string, unknown>) => void,
|
|
91
|
-
onRequestError?: (error: Error) => void
|
|
92
|
-
) {
|
|
93
|
-
isLoading.value = true
|
|
94
|
-
try {
|
|
95
|
-
return await useSSE(
|
|
96
|
-
{
|
|
97
|
-
method: 'POST',
|
|
98
|
-
url: `${apiEndpoint}/get-job-result`,
|
|
99
|
-
data: {
|
|
100
|
-
jobId
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
onMessage: (data) => onChunk(data),
|
|
105
|
-
onFieldMetadata: (metadata) => onMetaData(metadata),
|
|
106
|
-
onDone: () => (isLoading.value = false)
|
|
107
|
-
}
|
|
108
|
-
)
|
|
109
|
-
} catch (error) {
|
|
110
|
-
lastError.value = error as Error
|
|
111
|
-
onRequestError?.(error as Error)
|
|
112
|
-
isLoading.value = false
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
59
|
async function clearChatData(
|
|
116
60
|
username: string,
|
|
117
61
|
project: string,
|
|
@@ -130,6 +74,58 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
130
74
|
})
|
|
131
75
|
}
|
|
132
76
|
|
|
77
|
+
async function sendPrompt(
|
|
78
|
+
formData: FormData,
|
|
79
|
+
onChunk: (chunk: string) => void,
|
|
80
|
+
onError?: (error: Error) => void
|
|
81
|
+
) {
|
|
82
|
+
isLoading.value = true
|
|
83
|
+
return await useSSE(
|
|
84
|
+
{
|
|
85
|
+
method: 'POST',
|
|
86
|
+
url: `${apiEndpoint}/prompt/submit`,
|
|
87
|
+
data: formData
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
onMessage: (data) => {
|
|
91
|
+
onChunk(data)
|
|
92
|
+
},
|
|
93
|
+
onError: (error) => {
|
|
94
|
+
lastError.value = error
|
|
95
|
+
onError?.(error)
|
|
96
|
+
console.error('Error in sendPrompt:', error)
|
|
97
|
+
},
|
|
98
|
+
onDone: () => (isLoading.value = false)
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async function getFieldSuggestionData(
|
|
104
|
+
jobId: string,
|
|
105
|
+
onChunk: (chunk: string) => void,
|
|
106
|
+
onMetaData: (metadata: Record<string, unknown>) => void
|
|
107
|
+
) {
|
|
108
|
+
isLoading.value = true
|
|
109
|
+
return await useSSE(
|
|
110
|
+
{
|
|
111
|
+
method: 'POST',
|
|
112
|
+
url: `${apiEndpoint}/get-job-result`,
|
|
113
|
+
data: {
|
|
114
|
+
jobId
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
onMessage: (data) => onChunk(data),
|
|
119
|
+
onFieldMetadata: (metadata) => onMetaData(metadata),
|
|
120
|
+
onError: (error) => {
|
|
121
|
+
lastError.value = error
|
|
122
|
+
console.error('Error in getFieldSuggestionData:', error)
|
|
123
|
+
},
|
|
124
|
+
onDone: () => (isLoading.value = false)
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
133
129
|
async function handleFeedback(feedback: number, comment: string, sessionID: string) {
|
|
134
130
|
return await baseRequest<{ success: boolean }>({
|
|
135
131
|
method: 'POST',
|
|
@@ -147,7 +143,7 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
147
143
|
lastError,
|
|
148
144
|
getChatData,
|
|
149
145
|
clearChatData,
|
|
150
|
-
|
|
146
|
+
getFieldSuggestionData,
|
|
151
147
|
sendPrompt,
|
|
152
148
|
handleFeedback
|
|
153
149
|
}
|
|
@@ -3,6 +3,7 @@ import { v4 as uuidv4 } from 'uuid'
|
|
|
3
3
|
|
|
4
4
|
import type { Ref } from 'vue'
|
|
5
5
|
import type { ChatMessage, ChatBotMessageSender } from '@/components/ChatBot/types'
|
|
6
|
+
import type { ChatBotFile } from '@/components/ChatBotInput'
|
|
6
7
|
|
|
7
8
|
const messages: Ref<ChatMessage[]> = ref([])
|
|
8
9
|
const nextMessageId = ref(1)
|
|
@@ -11,7 +12,7 @@ export function useChatMessages() {
|
|
|
11
12
|
function addChatMessage(
|
|
12
13
|
message: string,
|
|
13
14
|
sender?: ChatBotMessageSender,
|
|
14
|
-
|
|
15
|
+
file?: ChatBotFile,
|
|
15
16
|
sessionID?: string,
|
|
16
17
|
isWelcomeMessage?: boolean
|
|
17
18
|
) {
|
|
@@ -21,7 +22,7 @@ export function useChatMessages() {
|
|
|
21
22
|
date: new Date(),
|
|
22
23
|
sender: sender || 'bot',
|
|
23
24
|
sessionID: sessionID || uuidv4(),
|
|
24
|
-
|
|
25
|
+
file: file,
|
|
25
26
|
isWelcomeMessage,
|
|
26
27
|
fields: []
|
|
27
28
|
}
|
|
@@ -40,10 +41,6 @@ export function useChatMessages() {
|
|
|
40
41
|
nextMessageId.value = 1
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
function deleteMessageById(messageId: number) {
|
|
44
|
-
messages.value = messages.value.filter((m) => m.id !== messageId)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
44
|
function getMessages() {
|
|
48
45
|
return messages.value
|
|
49
46
|
}
|
|
@@ -54,7 +51,6 @@ export function useChatMessages() {
|
|
|
54
51
|
addChatMessage,
|
|
55
52
|
getLastMessage,
|
|
56
53
|
clearMessages,
|
|
57
|
-
getMessages
|
|
58
|
-
deleteMessageById
|
|
54
|
+
getMessages
|
|
59
55
|
}
|
|
60
56
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TODO: Implement localization
|
|
3
|
-
*/
|
|
4
1
|
export function useTexts() {
|
|
5
2
|
return {
|
|
6
3
|
copy: 'Copy',
|
|
@@ -27,9 +24,9 @@ export function useTexts() {
|
|
|
27
24
|
cancelButton: 'Cancel',
|
|
28
25
|
senderImage: 'Sender Image',
|
|
29
26
|
imagePreview: 'Image preview',
|
|
30
|
-
regenerateResponsePrompt: 'Regenerate a new response for field {0}',
|
|
31
27
|
regenerateResponse: 'Regenerate response',
|
|
32
28
|
generatingResponse: 'Generating',
|
|
33
|
-
suggestionsForField: 'Suggestions for field'
|
|
29
|
+
suggestionsForField: 'Suggestions for field:',
|
|
30
|
+
fileUpload: 'Upload File'
|
|
34
31
|
}
|
|
35
32
|
}
|
package/src/test/setup.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { vi } from 'vitest'
|
|
|
2
2
|
import { config } from '@vue/test-utils'
|
|
3
3
|
|
|
4
4
|
import { createFramework } from '@quidgest/ui/framework'
|
|
5
|
-
import { QSelect } from '@quidgest/ui/components'
|
|
6
5
|
|
|
7
6
|
vi.mock('@quidgest/ui/components', async (importOriginal) => {
|
|
8
7
|
const original = await importOriginal<typeof import('@quidgest/ui/components')>()
|
|
@@ -35,7 +34,3 @@ config.global.plugins = [
|
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
]
|
|
38
|
-
|
|
39
|
-
config.global.components = {
|
|
40
|
-
QSelect
|
|
41
|
-
}
|