refactor: use Nuxt 4 directory structure
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
import { useIntervalFn } from '@vueuse/core'
|
import { useIntervalFn } from '@vueuse/core'
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import semverGt from 'semver/functions/gt'
|
import semverGt from 'semver/functions/gt'
|
||||||
import type VersionMeta from '~/public/version.json'
|
import type VersionMeta from '~~/public/version.json'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
@ -4,7 +4,7 @@
|
|||||||
type PartialProcessedSearchResult,
|
type PartialProcessedSearchResult,
|
||||||
type ProcessedSearchResult,
|
type ProcessedSearchResult,
|
||||||
type ResearchStep,
|
type ResearchStep,
|
||||||
} from '~/lib/deep-research'
|
} from '~~/lib/deep-research'
|
||||||
import {
|
import {
|
||||||
feedbackInjectionKey,
|
feedbackInjectionKey,
|
||||||
formInjectionKey,
|
formInjectionKey,
|
@ -3,7 +3,7 @@
|
|||||||
feedbackInjectionKey,
|
feedbackInjectionKey,
|
||||||
formInjectionKey,
|
formInjectionKey,
|
||||||
} from '~/constants/injection-keys'
|
} from '~/constants/injection-keys'
|
||||||
import { generateFeedback } from '~/lib/feedback'
|
import { generateFeedback } from '~~/lib/feedback'
|
||||||
|
|
||||||
export interface ResearchFeedbackResult {
|
export interface ResearchFeedbackResult {
|
||||||
assistantQuestion: string
|
assistantQuestion: string
|
||||||
@ -69,10 +69,10 @@
|
|||||||
// Incrementally update modelValue
|
// Incrementally update modelValue
|
||||||
for (let i = 0; i < questions.length; i += 1) {
|
for (let i = 0; i < questions.length; i += 1) {
|
||||||
if (feedback.value[i]) {
|
if (feedback.value[i]) {
|
||||||
feedback.value[i].assistantQuestion = questions[i]
|
feedback.value[i]!.assistantQuestion = questions[i]!
|
||||||
} else {
|
} else {
|
||||||
feedback.value.push({
|
feedback.value.push({
|
||||||
assistantQuestion: questions[i],
|
assistantQuestion: questions[i]!,
|
||||||
userAnswer: '',
|
userAnswer: '',
|
||||||
})
|
})
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { marked } from 'marked'
|
import { marked } from 'marked'
|
||||||
import { writeFinalReport } from '~/lib/deep-research'
|
import { writeFinalReport } from '~~/lib/deep-research'
|
||||||
import {
|
import {
|
||||||
feedbackInjectionKey,
|
feedbackInjectionKey,
|
||||||
formInjectionKey,
|
formInjectionKey,
|
@ -1,6 +1,6 @@
|
|||||||
import type { ResearchFeedbackResult } from '~/components/ResearchFeedback.vue'
|
import type { ResearchFeedbackResult } from '~/components/ResearchFeedback.vue'
|
||||||
import type { ResearchInputData } from '~/components/ResearchForm.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 formInjectionKey = Symbol() as InjectionKey<Ref<ResearchInputData>>
|
||||||
export const feedbackInjectionKey = Symbol() as InjectionKey<
|
export const feedbackInjectionKey = Symbol() as InjectionKey<
|
@ -51,19 +51,19 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type ResearchForm from '~/components/ResearchForm.vue'
|
import type ResearchForm from '@/components/ResearchForm.vue'
|
||||||
import type ResearchFeedback from '~/components/ResearchFeedback.vue'
|
import type ResearchFeedback from '@/components/ResearchFeedback.vue'
|
||||||
import type DeepResearch from '~/components/DeepResearch/DeepResearch.vue'
|
import type DeepResearch from '@/components/DeepResearch/DeepResearch.vue'
|
||||||
import type ResearchReport from '~/components/ResearchReport.vue'
|
import type ResearchReport from '@/components/ResearchReport.vue'
|
||||||
import type ConfigManager from '~/components/ConfigManager.vue'
|
import type ConfigManager from '@/components/ConfigManager.vue'
|
||||||
import type { ResearchInputData } from '~/components/ResearchForm.vue'
|
import type { ResearchInputData } from '@/components/ResearchForm.vue'
|
||||||
import type { ResearchFeedbackResult } from '~/components/ResearchFeedback.vue'
|
import type { ResearchFeedbackResult } from '@/components/ResearchFeedback.vue'
|
||||||
import type { ResearchResult } from '~/lib/deep-research'
|
import type { ResearchResult } from '~~/lib/deep-research'
|
||||||
import {
|
import {
|
||||||
feedbackInjectionKey,
|
feedbackInjectionKey,
|
||||||
formInjectionKey,
|
formInjectionKey,
|
||||||
researchResultInjectionKey,
|
researchResultInjectionKey,
|
||||||
} from '~/constants/injection-keys'
|
} from '@/constants/injection-keys'
|
||||||
|
|
||||||
const version = useRuntimeConfig().public.version
|
const version = useRuntimeConfig().public.version
|
||||||
|
|
||||||
@ -82,7 +82,6 @@
|
|||||||
const feedback = ref<ResearchFeedbackResult[]>([])
|
const feedback = ref<ResearchFeedbackResult[]>([])
|
||||||
const researchResult = ref<ResearchResult>({
|
const researchResult = ref<ResearchResult>({
|
||||||
learnings: [],
|
learnings: [],
|
||||||
visitedUrls: [],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
provide(formInjectionKey, form)
|
provide(formInjectionKey, form)
|
@ -1,5 +1,5 @@
|
|||||||
import { skipHydrate } from 'pinia'
|
import { skipHydrate } from 'pinia'
|
||||||
import type { Locale } from '~/components/LangSwitcher.vue'
|
import type { Locale } from '@/components/LangSwitcher.vue'
|
||||||
|
|
||||||
export type ConfigAiProvider =
|
export type ConfigAiProvider =
|
||||||
| 'openai-compatible'
|
| 'openai-compatible'
|
@ -1,6 +1,6 @@
|
|||||||
import en from '~/i18n/en.json'
|
import en from '~~/i18n/en.json'
|
||||||
import zh from '~/i18n/zh.json'
|
import zh from '~~/i18n/zh.json'
|
||||||
import nl from '~/i18n/nl.json'
|
import nl from '~~/i18n/nl.json'
|
||||||
|
|
||||||
export default defineI18nConfig(() => ({
|
export default defineI18nConfig(() => ({
|
||||||
legacy: false,
|
legacy: false,
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
import { streamText } from 'ai'
|
import { streamText } from 'ai'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
import { parseStreamingJson, type DeepPartial } from '~/utils/json'
|
import { parseStreamingJson, type DeepPartial } from '~~/utils/json'
|
||||||
|
|
||||||
import { trimPrompt } from './ai/providers'
|
import { trimPrompt } from './ai/providers'
|
||||||
import { languagePrompt, systemPrompt } from './prompt'
|
import { languagePrompt, systemPrompt } from './prompt'
|
||||||
import zodToJsonSchema from 'zod-to-json-schema'
|
import zodToJsonSchema from 'zod-to-json-schema'
|
||||||
import { useAiModel } from '~/composables/useAiProvider'
|
import { useAiModel } from '@/composables/useAiProvider'
|
||||||
import type { Locale } from '~/components/LangSwitcher.vue'
|
import type { Locale } from '@/components/LangSwitcher.vue'
|
||||||
import type { DeepResearchNode } from '~/components/DeepResearch/DeepResearch.vue'
|
import type { DeepResearchNode } from '@/components/DeepResearch/DeepResearch.vue'
|
||||||
|
import { throwAiError } from '~~/utils/errors'
|
||||||
|
|
||||||
export type ResearchResult = {
|
export type ResearchResult = {
|
||||||
learnings: ProcessedSearchResult['learnings']
|
learnings: ProcessedSearchResult['learnings']
|
||||||
@ -185,7 +186,7 @@ function processSearchResult({
|
|||||||
`<contents>${contents
|
`<contents>${contents
|
||||||
.map(
|
.map(
|
||||||
(content, index) =>
|
(content, index) =>
|
||||||
`<content url="${results[index].url}">\n${content}\n</content>`,
|
`<content url="${results[index]!.url}">\n${content}\n</content>`,
|
||||||
)
|
)
|
||||||
.join('\n')}</contents>`,
|
.join('\n')}</contents>`,
|
||||||
`You MUST respond in JSON matching this JSON schema: ${jsonSchema}`,
|
`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++) {
|
for (let i = 0; i < searchQueries.length; i++) {
|
||||||
onProgress({
|
onProgress({
|
||||||
type: 'generating_query',
|
type: 'generating_query',
|
||||||
result: searchQueries[i],
|
result: searchQueries[i]!,
|
||||||
nodeId: searchQueries[i].nodeId,
|
nodeId: searchQueries[i]!.nodeId,
|
||||||
parentNodeId: nodeId,
|
parentNodeId: nodeId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import { zodToJsonSchema } from 'zod-to-json-schema'
|
|||||||
|
|
||||||
import { languagePrompt, systemPrompt } from './prompt'
|
import { languagePrompt, systemPrompt } from './prompt'
|
||||||
import { useAiModel } from '~/composables/useAiProvider'
|
import { useAiModel } from '~/composables/useAiProvider'
|
||||||
|
import { parseStreamingJson, type DeepPartial } from '~~/utils/json'
|
||||||
|
import { throwAiError } from '~~/utils/errors'
|
||||||
|
|
||||||
type PartialFeedback = DeepPartial<z.infer<typeof feedbackTypeSchema>>
|
type PartialFeedback = DeepPartial<z.infer<typeof feedbackTypeSchema>>
|
||||||
|
|
||||||
|
@ -62,5 +62,8 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
css: ['~/assets/css/main.css'],
|
css: ['~/assets/css/main.css'],
|
||||||
compatibilityDate: '2024-11-01',
|
compatibilityDate: '2024-11-01',
|
||||||
|
future: {
|
||||||
|
compatibilityVersion: 4,
|
||||||
|
},
|
||||||
devtools: { enabled: true },
|
devtools: { enabled: true },
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user