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.

1.3 KB
Raw Blame
import type {
  AnnotationEnableStatus,
  EmbeddingModelConfig,
} from '@/app/components/app/annotation/type'
import { ANNOTATION_DEFAULT } from '@/config'
import { post } from './base'
import { consoleClient } from './console'

export const updateAnnotationStatus = (
  appId: string,
  action: AnnotationEnableStatus,
  embeddingModel?: EmbeddingModelConfig,
  score?: number,
) =>
  // Callers report request and job failures together.
  consoleClient.apps.byAppId.annotationReply.byAction.post(
    {
      params: { app_id: appId, action },
      body: {
        score_threshold: score ?? ANNOTATION_DEFAULT.score_threshold,
        // Disabling does not use the embedding model; the API still requires the fields.
        embedding_provider_name: embeddingModel?.embedding_provider_name ?? '',
        embedding_model_name: embeddingModel?.embedding_model_name ?? '',
      },
    },
    { context: { silent: true } },
  )

// Multipart uploads are not described by the generated contract yet.
export const annotationBatchImport = (
  appId: string,
  body: FormData,
  options?: { silent?: boolean },
) =>
  post<{ job_id: string; job_status: string }>(
    `/apps/${appId}/annotations/batch-import`,
    { body },
    { bodyStringify: false, deleteContentType: true, ...options },
  )