@@ -12,42 +12,12 @@ import {
1212 updateKnowledgeBaseOperation ,
1313} from '@/lib/knowledge/application/knowledge-bases'
1414import { knowledgeOperations } from '@/lib/knowledge/application/operations'
15- import type { KnowledgeBaseWithCounts } from '@/lib/ knowledge/types '
15+ import { toV2KnowledgeBase } from '@/app/api/v2/ knowledge/utils '
1616import { v2Error } from '@/app/api/v2/lib/response'
1717
1818export const dynamic = 'force-dynamic'
1919export const revalidate = 0
2020
21- function toV2KnowledgeBase ( knowledgeBase : KnowledgeBaseWithCounts , folderPath : string ) {
22- return {
23- id : knowledgeBase . id ,
24- name : knowledgeBase . name ,
25- description : knowledgeBase . description ,
26- tokenCount : knowledgeBase . tokenCount ,
27- embeddingModel : knowledgeBase . embeddingModel ,
28- embeddingDimension : knowledgeBase . embeddingDimension ,
29- chunkingConfig : {
30- maxSize : knowledgeBase . chunkingConfig . maxSize ,
31- minSize : knowledgeBase . chunkingConfig . minSize ,
32- overlap : knowledgeBase . chunkingConfig . overlap ,
33- strategy : knowledgeBase . chunkingConfig . strategy ,
34- strategyOptions : knowledgeBase . chunkingConfig . strategyOptions
35- ? {
36- pattern : knowledgeBase . chunkingConfig . strategyOptions . pattern ,
37- separators : knowledgeBase . chunkingConfig . strategyOptions . separators ,
38- recipe : knowledgeBase . chunkingConfig . strategyOptions . recipe ,
39- strictBoundaries : knowledgeBase . chunkingConfig . strategyOptions . strictBoundaries ,
40- }
41- : undefined ,
42- } ,
43- docCount : knowledgeBase . docCount ,
44- connectorTypes : knowledgeBase . connectorTypes ,
45- createdAt : knowledgeBase . createdAt . toISOString ( ) ,
46- updatedAt : knowledgeBase . updatedAt . toISOString ( ) ,
47- folderPath,
48- }
49- }
50-
5121/** GET /api/v2/knowledge/[id] — Get knowledge base details. */
5222export const GET = defineV2JsonRoute ( {
5323 contract : v2GetKnowledgeBaseContract ,
@@ -60,8 +30,8 @@ export const GET = defineV2JsonRoute({
6030 assertedWorkspaceId : query . workspaceId ,
6131 } ) ,
6232 useCase : readKnowledgeBase ,
63- present : ( { knowledgeBase, folderPath } ) => ( {
64- data : { knowledgeBase : toV2KnowledgeBase ( knowledgeBase , folderPath ) } ,
33+ present : async ( { knowledgeBase, folderPath } ) => ( {
34+ data : { knowledgeBase : await toV2KnowledgeBase ( knowledgeBase , folderPath ) } ,
6535 } ) ,
6636} )
6737
@@ -85,8 +55,8 @@ export const PUT = defineV2JsonRoute({
8555 source : 'api' ,
8656 } ) ,
8757 useCase : updateKnowledgeBaseOperation ,
88- present : ( { knowledgeBase, folderPath } ) => ( {
89- data : { knowledgeBase : toV2KnowledgeBase ( knowledgeBase , folderPath ) } ,
58+ present : async ( { knowledgeBase, folderPath } ) => ( {
59+ data : { knowledgeBase : await toV2KnowledgeBase ( knowledgeBase , folderPath ) } ,
9060 } ) ,
9161} )
9262
0 commit comments