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.

3.1 KB
Raw Blame
import type {
  AppDetailSiteResponse,
  AppDetailWithSite,
  AppModelConfigResponse,
} from '@dify/contracts/api/console/apps/types.gen'
import type { TrialAppDetailResponse } from '@dify/contracts/api/console/trial-apps/types.gen'
import { zTrialAppDetailResponse } from '@dify/contracts/api/console/trial-apps/zod.gen'

export function createAppModelConfigFixture(
  overrides: Partial<AppModelConfigResponse> = {},
): AppModelConfigResponse {
  return {
    agent_mode: { enabled: false },
    annotation_reply: { enabled: false },
    chat_prompt_config: {},
    completion_prompt_config: {},
    created_at: 1,
    created_by: null,
    dataset_configs: { retrieval_model: 'single' },
    dataset_query_variable: null,
    external_data_tools: [],
    file_upload: {},
    model: {},
    more_like_this: { enabled: false },
    opening_statement: null,
    pre_prompt: null,
    prompt_type: 'simple',
    retriever_resource: { enabled: false },
    sensitive_word_avoidance: { enabled: false },
    speech_to_text: { enabled: false },
    suggested_questions: [],
    suggested_questions_after_answer: { enabled: false },
    text_to_speech: { enabled: false },
    updated_at: 1,
    updated_by: null,
    user_input_form: [],
    ...overrides,
  }
}

export function createAppSiteFixture(
  overrides: Partial<AppDetailSiteResponse> = {},
): AppDetailSiteResponse {
  return {
    access_token: 'site-token',
    app_base_url: 'https://apps.example.test',
    chat_color_theme: null,
    chat_color_theme_inverted: false,
    code: 'site-token',
    copyright: null,
    created_at: 1,
    created_by: null,
    custom_disclaimer: '',
    customize_domain: null,
    customize_token_strategy: 'not_allow',
    default_language: 'en-US',
    description: null,
    icon: null,
    icon_background: null,
    icon_type: null,
    icon_url: null,
    input_placeholder: null,
    privacy_policy: null,
    prompt_public: false,
    show_workflow_steps: false,
    title: 'App',
    updated_at: 1,
    updated_by: null,
    use_icon_as_answer_icon: false,
    ...overrides,
  }
}

export function createAppDetailFixture(
  overrides: Partial<AppDetailWithSite> = {},
): AppDetailWithSite {
  return {
    access_mode: null,
    api_base_url: 'https://api.example.test/v1',
    app_id: null,
    bound_agent_id: null,
    created_at: 1,
    created_by: null,
    deleted_tools: [],
    description: '',
    enable_api: true,
    enable_site: true,
    icon: null,
    icon_background: null,
    icon_type: null,
    icon_url: null,
    id: 'app-1',
    maintainer: null,
    max_active_requests: null,
    mode: 'chat',
    model_config: null,
    name: 'App',
    permission_keys: [],
    site: null,
    tags: [],
    tracing: null,
    updated_at: 1,
    updated_by: null,
    use_icon_as_answer_icon: false,
    workflow: null,
    ...overrides,
  }
}

export function createTrialAppDetailFixture(overrides: Partial<TrialAppDetailResponse> = {}) {
  return zTrialAppDetailResponse.parse({
    ...createAppDetailFixture(),
    site: createAppSiteFixture(),
    model_config: createAppModelConfigFixture({
      model: { provider: 'openai', name: 'gpt-4', mode: 'chat' },
    }),
    ...overrides,
  })
}