Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

872 B
Raw Blame
import { consoleClient } from '@/service/console'

type LogicalDocumentCitation = {
  documentId: string
  revision: number
}

export async function resolveLogicalDocumentCitation({
  documentAssetId,
  documentVersion,
  knowledgeSpaceId,
}: {
  documentAssetId: string
  documentVersion?: number
  knowledgeSpaceId: string
}): Promise<LogicalDocumentCitation | undefined> {
  if (documentVersion === undefined) return undefined

  const citation =
    await consoleClient.knowledgeFs.spaces.byControlSpaceId.documentReferences.resolve.get(
      {
        params: { control_space_id: knowledgeSpaceId },
        query: {
          document_asset_id: documentAssetId,
          document_asset_version: documentVersion,
        },
      },
      { context: { silent: true } },
    )

  return {
    documentId: citation.document_id,
    revision: citation.revision,
  }
}