@quidgest/chatbot 0.6.0 → 0.6.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.
@@ -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.toLowerCase().includes('**execution plan**')
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('\n')
45
- const titleLine = lines.find((line) => line.toLowerCase().includes('**execution plan**'))
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('\n')
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.toLowerCase().includes('**execution plan**')
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: #2d2d2d;
26
- color: white;
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 class="generating-text">
4
- {{ texts.generatingResponse }}
5
- </span>
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 dots = [1, 2, 3]
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
- onChunk: (chunk: string) => void,
62
- onStatus?: (payload: { event: string; data: { id: string; html: string } }) => void,
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
- onChunk(data)
76
+ onMessage(data)
76
77
  },
77
78
  onToolStatus: (payload) => {
78
- onStatus?.(payload)
79
+ onToolStatus?.(payload)
79
80
  },
80
- onDone: () => (isLoading.value = false)
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
- onChunk: (chunk: string) => void,
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) => onChunk(data),
122
+ onMessage: (data) => onMessage(data),
109
123
  onFieldMetadata: (metadata) => onMetaData(metadata),
110
124
  onDone: () => (isLoading.value = false)
111
125
  }
@@ -153,6 +167,7 @@ export function useChatApi(apiEndpoint: string) {
153
167
  clearChatData,
154
168
  getJobResultData,
155
169
  sendPrompt,
170
+ cancelExecution,
156
171
  handleFeedback
157
172
  }
158
173
  }