|
15 | 15 | }>()
|
16 | 16 |
|
17 | 17 | const { t, locale } = useI18n()
|
| 18 | + const reasoningContent = ref('') |
18 | 19 | const feedback = ref<ResearchFeedbackResult[]>([])
|
19 | 20 |
|
20 | 21 | const isLoading = ref(false)
|
|
39 | 40 | numQuestions,
|
40 | 41 | language: t('language', {}, { locale: locale.value }),
|
41 | 42 | })) {
|
42 |
| - const questions = f.questions!.filter((s) => typeof s === 'string') |
43 |
| - // Incrementally update modelValue |
44 |
| - for (let i = 0; i < questions.length; i += 1) { |
45 |
| - if (feedback.value[i]) { |
46 |
| - feedback.value[i].assistantQuestion = questions[i] |
47 |
| - } else { |
48 |
| - feedback.value.push({ |
49 |
| - assistantQuestion: questions[i], |
50 |
| - userAnswer: '', |
51 |
| - }) |
| 43 | + if (f.type === 'reasoning') { |
| 44 | + reasoningContent.value += f.delta |
| 45 | + } else if (f.type === 'error') { |
| 46 | + error.value = f.message |
| 47 | + } else if (f.type === 'object') { |
| 48 | + const questions = f.value.questions!.filter( |
| 49 | + (s) => typeof s === 'string', |
| 50 | + ) |
| 51 | + // Incrementally update modelValue |
| 52 | + for (let i = 0; i < questions.length; i += 1) { |
| 53 | + if (feedback.value[i]) { |
| 54 | + feedback.value[i].assistantQuestion = questions[i] |
| 55 | + } else { |
| 56 | + feedback.value.push({ |
| 57 | + assistantQuestion: questions[i], |
| 58 | + userAnswer: '', |
| 59 | + }) |
| 60 | + } |
52 | 61 | }
|
| 62 | + } else if (f.type === 'bad-end') { |
| 63 | + error.value = t('invalidStructuredOutput') |
53 | 64 | }
|
54 | 65 | }
|
55 | 66 | } catch (e: any) {
|
|
66 | 77 | function clear() {
|
67 | 78 | feedback.value = []
|
68 | 79 | error.value = ''
|
| 80 | + reasoningContent.value = '' |
69 | 81 | }
|
70 | 82 |
|
71 | 83 | defineExpose({
|
|
85 | 97 | </template>
|
86 | 98 |
|
87 | 99 | <div class="flex flex-col gap-2">
|
88 |
| - <div v-if="!feedback.length && !error"> |
| 100 | + <div v-if="!feedback.length && !reasoningContent && !error"> |
89 | 101 | {{ $t('modelFeedback.waiting') }}
|
90 | 102 | </div>
|
91 | 103 | <template v-else>
|
92 | 104 | <div v-if="error" class="text-red-500 whitespace-pre-wrap">
|
93 | 105 | {{ error }}
|
94 | 106 | </div>
|
| 107 | + |
| 108 | + <ReasoningAccordion v-model="reasoningContent" :loading="isLoading" /> |
| 109 | + |
95 | 110 | <div
|
96 | 111 | v-for="(feedback, index) in feedback"
|
97 | 112 | class="flex flex-col gap-2"
|
|
0 commit comments