refactor: use Nuxt 4 directory structure

This commit is contained in:
AnotiaWang
2025-02-28 16:16:02 +08:00
parent 7a87ed5def
commit c45d75fad2
31 changed files with 33 additions and 28 deletions

View File

@ -2,7 +2,7 @@
import { useIntervalFn } from '@vueuse/core'
// @ts-expect-error
import semverGt from 'semver/functions/gt'
import type VersionMeta from '~/public/version.json'
import type VersionMeta from '~~/public/version.json'
const { t } = useI18n()
const toast = useToast()

View File

@ -4,7 +4,7 @@
type PartialProcessedSearchResult,
type ProcessedSearchResult,
type ResearchStep,
} from '~/lib/deep-research'
} from '~~/lib/deep-research'
import {
feedbackInjectionKey,
formInjectionKey,

View File

@ -3,7 +3,7 @@
feedbackInjectionKey,
formInjectionKey,
} from '~/constants/injection-keys'
import { generateFeedback } from '~/lib/feedback'
import { generateFeedback } from '~~/lib/feedback'
export interface ResearchFeedbackResult {
assistantQuestion: string
@ -69,10 +69,10 @@
// Incrementally update modelValue
for (let i = 0; i < questions.length; i += 1) {
if (feedback.value[i]) {
feedback.value[i].assistantQuestion = questions[i]
feedback.value[i]!.assistantQuestion = questions[i]!
} else {
feedback.value.push({
assistantQuestion: questions[i],
assistantQuestion: questions[i]!,
userAnswer: '',
})
}

View File

@ -1,6 +1,6 @@
<script setup lang="ts">
import { marked } from 'marked'
import { writeFinalReport } from '~/lib/deep-research'
import { writeFinalReport } from '~~/lib/deep-research'
import {
feedbackInjectionKey,
formInjectionKey,

View File

@ -1,6 +1,6 @@
import type { ResearchFeedbackResult } from '~/components/ResearchFeedback.vue'
import type { ResearchInputData } from '~/components/ResearchForm.vue'
import type { ResearchResult } from '~/lib/deep-research'
import type { ResearchResult } from '~~/lib/deep-research'
export const formInjectionKey = Symbol() as InjectionKey<Ref<ResearchInputData>>
export const feedbackInjectionKey = Symbol() as InjectionKey<

View File

@ -51,19 +51,19 @@
</template>
<script setup lang="ts">
import type ResearchForm from '~/components/ResearchForm.vue'
import type ResearchFeedback from '~/components/ResearchFeedback.vue'
import type DeepResearch from '~/components/DeepResearch/DeepResearch.vue'
import type ResearchReport from '~/components/ResearchReport.vue'
import type ConfigManager from '~/components/ConfigManager.vue'
import type { ResearchInputData } from '~/components/ResearchForm.vue'
import type { ResearchFeedbackResult } from '~/components/ResearchFeedback.vue'
import type { ResearchResult } from '~/lib/deep-research'
import type ResearchForm from '@/components/ResearchForm.vue'
import type ResearchFeedback from '@/components/ResearchFeedback.vue'
import type DeepResearch from '@/components/DeepResearch/DeepResearch.vue'
import type ResearchReport from '@/components/ResearchReport.vue'
import type ConfigManager from '@/components/ConfigManager.vue'
import type { ResearchInputData } from '@/components/ResearchForm.vue'
import type { ResearchFeedbackResult } from '@/components/ResearchFeedback.vue'
import type { ResearchResult } from '~~/lib/deep-research'
import {
feedbackInjectionKey,
formInjectionKey,
researchResultInjectionKey,
} from '~/constants/injection-keys'
} from '@/constants/injection-keys'
const version = useRuntimeConfig().public.version
@ -82,7 +82,6 @@
const feedback = ref<ResearchFeedbackResult[]>([])
const researchResult = ref<ResearchResult>({
learnings: [],
visitedUrls: [],
})
provide(formInjectionKey, form)

View File

@ -1,5 +1,5 @@
import { skipHydrate } from 'pinia'
import type { Locale } from '~/components/LangSwitcher.vue'
import type { Locale } from '@/components/LangSwitcher.vue'
export type ConfigAiProvider =
| 'openai-compatible'

View File

@ -1,6 +1,6 @@
import en from '~/i18n/en.json'
import zh from '~/i18n/zh.json'
import nl from '~/i18n/nl.json'
import en from '~~/i18n/en.json'
import zh from '~~/i18n/zh.json'
import nl from '~~/i18n/nl.json'
export default defineI18nConfig(() => ({
legacy: false,

View File

@ -1,13 +1,14 @@
import { streamText } from 'ai'
import { z } from 'zod'
import { parseStreamingJson, type DeepPartial } from '~/utils/json'
import { parseStreamingJson, type DeepPartial } from '~~/utils/json'
import { trimPrompt } from './ai/providers'
import { languagePrompt, systemPrompt } from './prompt'
import zodToJsonSchema from 'zod-to-json-schema'
import { useAiModel } from '~/composables/useAiProvider'
import type { Locale } from '~/components/LangSwitcher.vue'
import type { DeepResearchNode } from '~/components/DeepResearch/DeepResearch.vue'
import { useAiModel } from '@/composables/useAiProvider'
import type { Locale } from '@/components/LangSwitcher.vue'
import type { DeepResearchNode } from '@/components/DeepResearch/DeepResearch.vue'
import { throwAiError } from '~~/utils/errors'
export type ResearchResult = {
learnings: ProcessedSearchResult['learnings']
@ -185,7 +186,7 @@ function processSearchResult({
`<contents>${contents
.map(
(content, index) =>
`<content url="${results[index].url}">\n${content}\n</content>`,
`<content url="${results[index]!.url}">\n${content}\n</content>`,
)
.join('\n')}</contents>`,
`You MUST respond in JSON matching this JSON schema: ${jsonSchema}`,
@ -316,8 +317,8 @@ export async function deepResearch({
for (let i = 0; i < searchQueries.length; i++) {
onProgress({
type: 'generating_query',
result: searchQueries[i],
nodeId: searchQueries[i].nodeId,
result: searchQueries[i]!,
nodeId: searchQueries[i]!.nodeId,
parentNodeId: nodeId,
})
}

View File

@ -4,6 +4,8 @@ import { zodToJsonSchema } from 'zod-to-json-schema'
import { languagePrompt, systemPrompt } from './prompt'
import { useAiModel } from '~/composables/useAiProvider'
import { parseStreamingJson, type DeepPartial } from '~~/utils/json'
import { throwAiError } from '~~/utils/errors'
type PartialFeedback = DeepPartial<z.infer<typeof feedbackTypeSchema>>

View File

@ -62,5 +62,8 @@ export default defineNuxtConfig({
css: ['~/assets/css/main.css'],
compatibilityDate: '2024-11-01',
future: {
compatibilityVersion: 4,
},
devtools: { enabled: true },
})