@quidgest/chatbot 0.6.0 → 0.6.2
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/ChatBotMessage/ChatBotMessage.vue.d.ts +2 -0
- package/dist/components/ChatBotMessage/ChatBotMessageButtons.vue.d.ts +2 -0
- package/dist/components/ChatBotMessage/types.d.ts +16 -1
- package/dist/components/PulseDots/PulseDots.vue.d.ts +16 -1
- package/dist/composables/useChatApi.d.ts +7 -4
- package/dist/index.js +22 -29
- package/dist/index.mjs +1707 -1578
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/src/assets/styles/styles.scss +4 -4
- package/src/components/ChatBot/ChatBot.vue +170 -56
- package/src/components/ChatBot/__tests__/ChatBot.spec.ts +20 -0
- package/src/components/ChatBotMessage/ChatBotMessage.vue +29 -9
- package/src/components/ChatBotMessage/ChatBotMessageButtons.vue +36 -1
- package/src/components/ChatBotMessage/__tests__/ChatBotMessageButtons.spec.ts +74 -0
- package/src/components/ChatBotMessage/__tests__/__snapshots__/ChatBotMessage.spec.ts.snap +2 -0
- package/src/components/ChatBotMessage/__tests__/__snapshots__/ChatBotMessageButtons.spec.ts.snap +1 -0
- package/src/components/ChatBotMessage/types.ts +19 -1
- package/src/components/MarkdownRender/MarkdownRender.vue +41 -7
- package/src/components/MarkdownRender/markdown-render.scss +22 -2
- package/src/components/PulseDots/PulseDots.vue +11 -4
- package/src/composables/useChatApi.ts +29 -12
|
@@ -66,6 +66,21 @@ export type ChatBotMessageProps = {
|
|
|
66
66
|
* Flag to indicate if this is the last message
|
|
67
67
|
*/
|
|
68
68
|
isLastMessage?: boolean
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Flag to indicate if message is currently streaming
|
|
72
|
+
*/
|
|
73
|
+
isStreaming?: boolean
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Flag to show cancel execution button
|
|
77
|
+
*/
|
|
78
|
+
showCancelExecution?: boolean
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Flag to disable cancel execution button
|
|
82
|
+
*/
|
|
83
|
+
cancelExecutionDisabled?: boolean
|
|
69
84
|
}
|
|
70
85
|
|
|
71
86
|
export type ChatBotMessageButtonsProps = {
|
|
@@ -73,6 +88,9 @@ export type ChatBotMessageButtonsProps = {
|
|
|
73
88
|
showButtons: boolean
|
|
74
89
|
dateFormat: string
|
|
75
90
|
date?: Date
|
|
76
|
-
isExecutionPlan?: boolean
|
|
77
91
|
isLastMessage?: boolean
|
|
92
|
+
isExecutionPlan?: boolean
|
|
93
|
+
isStreaming?: boolean
|
|
94
|
+
showCancelExecution?: boolean
|
|
95
|
+
cancelExecutionDisabled?: boolean
|
|
78
96
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
v-if="!isExecutionPlan"
|
|
3
|
+
v-if="!isExecutionPlan && !isExecutionProgress"
|
|
4
4
|
class="markdown-renderer"
|
|
5
5
|
v-html="renderedContent"></div>
|
|
6
6
|
<div
|
|
7
|
-
v-else
|
|
7
|
+
v-else-if="isExecutionPlan"
|
|
8
8
|
class="markdown-renderer">
|
|
9
9
|
<div v-html="executionPlanTitle"></div>
|
|
10
10
|
<div
|
|
@@ -12,6 +12,15 @@
|
|
|
12
12
|
class="markdown-renderer__execution-plan-content"
|
|
13
13
|
v-html="executionPlanContent"></div>
|
|
14
14
|
</div>
|
|
15
|
+
<div
|
|
16
|
+
v-else-if="isExecutionProgress"
|
|
17
|
+
class="markdown-renderer">
|
|
18
|
+
<div v-html="executionProgressTitle"></div>
|
|
19
|
+
<div
|
|
20
|
+
v-if="executionProgressContent"
|
|
21
|
+
class="markdown-renderer__execution-progress-content"
|
|
22
|
+
v-html="executionProgressContent"></div>
|
|
23
|
+
</div>
|
|
15
24
|
</template>
|
|
16
25
|
|
|
17
26
|
<script setup lang="ts">
|
|
@@ -35,14 +44,14 @@
|
|
|
35
44
|
const renderedContent = computed(() => md.value.render(props.source))
|
|
36
45
|
|
|
37
46
|
const isExecutionPlan = computed(() => {
|
|
38
|
-
return props.source.
|
|
47
|
+
return props.source.includes('data-type="execution-plan"')
|
|
39
48
|
})
|
|
40
49
|
|
|
41
50
|
const executionPlanTitle = computed(() => {
|
|
42
51
|
if (!isExecutionPlan.value) return ''
|
|
43
52
|
|
|
44
|
-
const lines = props.source.split(
|
|
45
|
-
const titleLine = lines.find((line) => line.
|
|
53
|
+
const lines = props.source.split(/\n|<br>/)
|
|
54
|
+
const titleLine = lines.find((line) => line.includes('data-type="execution-plan"'))
|
|
46
55
|
|
|
47
56
|
return titleLine ? md.value.render(titleLine) : ''
|
|
48
57
|
})
|
|
@@ -50,9 +59,34 @@
|
|
|
50
59
|
const executionPlanContent = computed(() => {
|
|
51
60
|
if (!isExecutionPlan.value) return ''
|
|
52
61
|
|
|
53
|
-
const lines = props.source.split(
|
|
62
|
+
const lines = props.source.split(/\n|<br>/)
|
|
63
|
+
const titleIndex = lines.findIndex((line) => line.includes('data-type="execution-plan"'))
|
|
64
|
+
|
|
65
|
+
if (titleIndex === -1) return ''
|
|
66
|
+
|
|
67
|
+
const contentLines = lines.slice(titleIndex + 1).join('\n')
|
|
68
|
+
return md.value.render(contentLines)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
const isExecutionProgress = computed(() => {
|
|
72
|
+
return props.source.includes('data-type="execution-progress"')
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const executionProgressTitle = computed(() => {
|
|
76
|
+
if (!isExecutionProgress.value) return ''
|
|
77
|
+
|
|
78
|
+
const lines = props.source.split(/\n|<br>/)
|
|
79
|
+
const titleLine = lines.find((line) => line.includes('data-type="execution-progress"'))
|
|
80
|
+
|
|
81
|
+
return titleLine ? md.value.render(titleLine) : ''
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
const executionProgressContent = computed(() => {
|
|
85
|
+
if (!isExecutionProgress.value) return ''
|
|
86
|
+
|
|
87
|
+
const lines = props.source.split(/\n|<br>/)
|
|
54
88
|
const titleIndex = lines.findIndex((line) =>
|
|
55
|
-
line.
|
|
89
|
+
line.includes('data-type="execution-progress"')
|
|
56
90
|
)
|
|
57
91
|
|
|
58
92
|
if (titleIndex === -1) return ''
|
|
@@ -22,8 +22,28 @@
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
&__execution-plan-content {
|
|
25
|
-
background-color:
|
|
26
|
-
color:
|
|
25
|
+
background-color: var(--gray-dark);
|
|
26
|
+
color: var(--q-theme-on-neutral-dark);
|
|
27
|
+
padding: 0.75rem 1rem;
|
|
28
|
+
border-radius: 6px;
|
|
29
|
+
margin-top: 0.5rem;
|
|
30
|
+
|
|
31
|
+
ul,
|
|
32
|
+
ol {
|
|
33
|
+
margin: 0;
|
|
34
|
+
padding-left: 1.5rem;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
p {
|
|
38
|
+
margin: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
hr {
|
|
42
|
+
border-color: var(--q-theme-on-neutral-dark);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&__execution-progress-content {
|
|
27
47
|
padding: 0.75rem 1rem;
|
|
28
48
|
border-radius: 6px;
|
|
29
49
|
margin-top: 0.5rem;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="pulsing-dots">
|
|
3
|
-
<span
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
<span
|
|
4
|
+
class="generating-text"
|
|
5
|
+
v-html="displayText"></span>
|
|
6
6
|
<div class="dots-container">
|
|
7
7
|
<span
|
|
8
8
|
v-for="(_, index) in dots"
|
|
@@ -16,9 +16,16 @@
|
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
18
|
<script setup lang="ts">
|
|
19
|
+
import { computed } from 'vue'
|
|
19
20
|
import { useTexts } from '@/composables/useTexts'
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
+
const props = defineProps<{
|
|
23
|
+
/** Text to display above the pulsing dots; if omitted, a default is used. */
|
|
24
|
+
text?: string
|
|
25
|
+
}>()
|
|
22
26
|
|
|
27
|
+
const dots = [1, 2, 3]
|
|
23
28
|
const texts = useTexts()
|
|
29
|
+
|
|
30
|
+
const displayText = computed(() => props.text || texts.generatingResponse)
|
|
24
31
|
</script>
|
|
@@ -58,9 +58,10 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
58
58
|
|
|
59
59
|
async function sendPrompt(
|
|
60
60
|
formData: FormData,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
onError?: (error: Error) => void
|
|
61
|
+
onMessage: (chunk: string) => void,
|
|
62
|
+
onToolStatus?: (payload: { event: string; data: { id: string; html: string } }) => void,
|
|
63
|
+
onError?: (error: Error) => void,
|
|
64
|
+
onDone?: () => void
|
|
64
65
|
) {
|
|
65
66
|
isLoading.value = true
|
|
66
67
|
try {
|
|
@@ -72,12 +73,15 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
72
73
|
},
|
|
73
74
|
{
|
|
74
75
|
onMessage: (data) => {
|
|
75
|
-
|
|
76
|
+
onMessage(data)
|
|
76
77
|
},
|
|
77
78
|
onToolStatus: (payload) => {
|
|
78
|
-
|
|
79
|
+
onToolStatus?.(payload)
|
|
79
80
|
},
|
|
80
|
-
onDone: () =>
|
|
81
|
+
onDone: () => {
|
|
82
|
+
isLoading.value = false
|
|
83
|
+
onDone?.()
|
|
84
|
+
}
|
|
81
85
|
}
|
|
82
86
|
)
|
|
83
87
|
} catch (error) {
|
|
@@ -88,9 +92,19 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
async function cancelExecution(sessionId: string) {
|
|
96
|
+
return await baseRequest<{ success: boolean }>({
|
|
97
|
+
method: 'POST',
|
|
98
|
+
url: `/prompt/cancel-execution`,
|
|
99
|
+
data: {
|
|
100
|
+
sessionId
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
91
105
|
async function getJobResultData(
|
|
92
106
|
jobId: string,
|
|
93
|
-
|
|
107
|
+
onMessage: (chunk: string) => void,
|
|
94
108
|
onMetaData: (metadata: Record<string, unknown>) => void,
|
|
95
109
|
onRequestError?: (error: Error) => void
|
|
96
110
|
) {
|
|
@@ -105,7 +119,7 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
105
119
|
}
|
|
106
120
|
},
|
|
107
121
|
{
|
|
108
|
-
onMessage: (data) =>
|
|
122
|
+
onMessage: (data) => onMessage(data),
|
|
109
123
|
onFieldMetadata: (metadata) => onMetaData(metadata),
|
|
110
124
|
onDone: () => (isLoading.value = false)
|
|
111
125
|
}
|
|
@@ -119,8 +133,9 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
119
133
|
async function clearChatData(
|
|
120
134
|
username: string,
|
|
121
135
|
project: string,
|
|
122
|
-
|
|
123
|
-
formId: string
|
|
136
|
+
agentId: string,
|
|
137
|
+
formId: string,
|
|
138
|
+
sessionId?: string
|
|
124
139
|
) {
|
|
125
140
|
return await baseRequest<{ success: boolean }>({
|
|
126
141
|
method: 'POST',
|
|
@@ -128,8 +143,9 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
128
143
|
data: {
|
|
129
144
|
username,
|
|
130
145
|
project,
|
|
131
|
-
|
|
132
|
-
formId
|
|
146
|
+
agentId,
|
|
147
|
+
formId,
|
|
148
|
+
sessionId
|
|
133
149
|
}
|
|
134
150
|
})
|
|
135
151
|
}
|
|
@@ -153,6 +169,7 @@ export function useChatApi(apiEndpoint: string) {
|
|
|
153
169
|
clearChatData,
|
|
154
170
|
getJobResultData,
|
|
155
171
|
sendPrompt,
|
|
172
|
+
cancelExecution,
|
|
156
173
|
handleFeedback
|
|
157
174
|
}
|
|
158
175
|
}
|