Skip to content

Commit c45d75f

Browse files
committed
refactor: use Nuxt 4 directory structure
1 parent 7a87ed5 commit c45d75f

31 files changed

+33
-28
lines changed

app.config.ts app/app.config.ts

File renamed without changes.

app.vue app/app.vue

File renamed without changes.
File renamed without changes.

components/AutoUpdateToast.vue app/components/AutoUpdateToast.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { useIntervalFn } from '@vueuse/core'
33
// @ts-expect-error
44
import semverGt from 'semver/functions/gt'
5-
import type VersionMeta from '~/public/version.json'
5+
import type VersionMeta from '~~/public/version.json'
66
77
const { t } = useI18n()
88
const toast = useToast()
File renamed without changes.
File renamed without changes.

components/DeepResearch/DeepResearch.vue app/components/DeepResearch/DeepResearch.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
type PartialProcessedSearchResult,
55
type ProcessedSearchResult,
66
type ResearchStep,
7-
} from '~/lib/deep-research'
7+
} from '~~/lib/deep-research'
88
import {
99
feedbackInjectionKey,
1010
formInjectionKey,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

components/ResearchFeedback.vue app/components/ResearchFeedback.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
feedbackInjectionKey,
44
formInjectionKey,
55
} from '~/constants/injection-keys'
6-
import { generateFeedback } from '~/lib/feedback'
6+
import { generateFeedback } from '~~/lib/feedback'
77
88
export interface ResearchFeedbackResult {
99
assistantQuestion: string
@@ -69,10 +69,10 @@
6969
// Incrementally update modelValue
7070
for (let i = 0; i < questions.length; i += 1) {
7171
if (feedback.value[i]) {
72-
feedback.value[i].assistantQuestion = questions[i]
72+
feedback.value[i]!.assistantQuestion = questions[i]!
7373
} else {
7474
feedback.value.push({
75-
assistantQuestion: questions[i],
75+
assistantQuestion: questions[i]!,
7676
userAnswer: '',
7777
})
7878
}
File renamed without changes.

components/ResearchReport.vue app/components/ResearchReport.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { marked } from 'marked'
3-
import { writeFinalReport } from '~/lib/deep-research'
3+
import { writeFinalReport } from '~~/lib/deep-research'
44
import {
55
feedbackInjectionKey,
66
formInjectionKey,
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

constants/injection-keys.ts app/constants/injection-keys.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ResearchFeedbackResult } from '~/components/ResearchFeedback.vue'
22
import type { ResearchInputData } from '~/components/ResearchForm.vue'
3-
import type { ResearchResult } from '~/lib/deep-research'
3+
import type { ResearchResult } from '~~/lib/deep-research'
44

55
export const formInjectionKey = Symbol() as InjectionKey<Ref<ResearchInputData>>
66
export const feedbackInjectionKey = Symbol() as InjectionKey<
File renamed without changes.

pages/index.vue app/pages/index.vue

+9-10
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@
5151
</template>
5252

5353
<script setup lang="ts">
54-
import type ResearchForm from '~/components/ResearchForm.vue'
55-
import type ResearchFeedback from '~/components/ResearchFeedback.vue'
56-
import type DeepResearch from '~/components/DeepResearch/DeepResearch.vue'
57-
import type ResearchReport from '~/components/ResearchReport.vue'
58-
import type ConfigManager from '~/components/ConfigManager.vue'
59-
import type { ResearchInputData } from '~/components/ResearchForm.vue'
60-
import type { ResearchFeedbackResult } from '~/components/ResearchFeedback.vue'
61-
import type { ResearchResult } from '~/lib/deep-research'
54+
import type ResearchForm from '@/components/ResearchForm.vue'
55+
import type ResearchFeedback from '@/components/ResearchFeedback.vue'
56+
import type DeepResearch from '@/components/DeepResearch/DeepResearch.vue'
57+
import type ResearchReport from '@/components/ResearchReport.vue'
58+
import type ConfigManager from '@/components/ConfigManager.vue'
59+
import type { ResearchInputData } from '@/components/ResearchForm.vue'
60+
import type { ResearchFeedbackResult } from '@/components/ResearchFeedback.vue'
61+
import type { ResearchResult } from '~~/lib/deep-research'
6262
import {
6363
feedbackInjectionKey,
6464
formInjectionKey,
6565
researchResultInjectionKey,
66-
} from '~/constants/injection-keys'
66+
} from '@/constants/injection-keys'
6767
6868
const version = useRuntimeConfig().public.version
6969
@@ -82,7 +82,6 @@
8282
const feedback = ref<ResearchFeedbackResult[]>([])
8383
const researchResult = ref<ResearchResult>({
8484
learnings: [],
85-
visitedUrls: [],
8685
})
8786
8887
provide(formInjectionKey, form)

stores/config.ts app/stores/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { skipHydrate } from 'pinia'
2-
import type { Locale } from '~/components/LangSwitcher.vue'
2+
import type { Locale } from '@/components/LangSwitcher.vue'
33

44
export type ConfigAiProvider =
55
| 'openai-compatible'
File renamed without changes.
File renamed without changes.

i18n.config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import en from '~/i18n/en.json'
2-
import zh from '~/i18n/zh.json'
3-
import nl from '~/i18n/nl.json'
1+
import en from '~~/i18n/en.json'
2+
import zh from '~~/i18n/zh.json'
3+
import nl from '~~/i18n/nl.json'
44

55
export default defineI18nConfig(() => ({
66
legacy: false,

lib/deep-research.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { streamText } from 'ai'
22
import { z } from 'zod'
3-
import { parseStreamingJson, type DeepPartial } from '~/utils/json'
3+
import { parseStreamingJson, type DeepPartial } from '~~/utils/json'
44

55
import { trimPrompt } from './ai/providers'
66
import { languagePrompt, systemPrompt } from './prompt'
77
import zodToJsonSchema from 'zod-to-json-schema'
8-
import { useAiModel } from '~/composables/useAiProvider'
9-
import type { Locale } from '~/components/LangSwitcher.vue'
10-
import type { DeepResearchNode } from '~/components/DeepResearch/DeepResearch.vue'
8+
import { useAiModel } from '@/composables/useAiProvider'
9+
import type { Locale } from '@/components/LangSwitcher.vue'
10+
import type { DeepResearchNode } from '@/components/DeepResearch/DeepResearch.vue'
11+
import { throwAiError } from '~~/utils/errors'
1112

1213
export type ResearchResult = {
1314
learnings: ProcessedSearchResult['learnings']
@@ -185,7 +186,7 @@ function processSearchResult({
185186
`<contents>${contents
186187
.map(
187188
(content, index) =>
188-
`<content url="${results[index].url}">\n${content}\n</content>`,
189+
`<content url="${results[index]!.url}">\n${content}\n</content>`,
189190
)
190191
.join('\n')}</contents>`,
191192
`You MUST respond in JSON matching this JSON schema: ${jsonSchema}`,
@@ -316,8 +317,8 @@ export async function deepResearch({
316317
for (let i = 0; i < searchQueries.length; i++) {
317318
onProgress({
318319
type: 'generating_query',
319-
result: searchQueries[i],
320-
nodeId: searchQueries[i].nodeId,
320+
result: searchQueries[i]!,
321+
nodeId: searchQueries[i]!.nodeId,
321322
parentNodeId: nodeId,
322323
})
323324
}

lib/feedback.ts

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { zodToJsonSchema } from 'zod-to-json-schema'
44

55
import { languagePrompt, systemPrompt } from './prompt'
66
import { useAiModel } from '~/composables/useAiProvider'
7+
import { parseStreamingJson, type DeepPartial } from '~~/utils/json'
8+
import { throwAiError } from '~~/utils/errors'
79

810
type PartialFeedback = DeepPartial<z.infer<typeof feedbackTypeSchema>>
911

nuxt.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,8 @@ export default defineNuxtConfig({
6262

6363
css: ['~/assets/css/main.css'],
6464
compatibilityDate: '2024-11-01',
65+
future: {
66+
compatibilityVersion: 4,
67+
},
6568
devtools: { enabled: true },
6669
})

0 commit comments

Comments
 (0)