| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- import { get, post } from '@/request/index'
- import { type Ref } from 'vue'
- import type { Result } from '@/request/Result'
- export interface SampleCenterKB {
- id: string
- name: string
- parent_table: string
- child_table: string
- document_count: number
- status: number
- created_at: string
- created_by: string
- metadata_schema: Array<{
- field_name_cn: string
- field_name_en: string
- field_type: string
- description: string
- }>
- }
- export interface SampleCenterKBDetail extends SampleCenterKB {
- description: string
- updated_at: string
- }
- export interface ImportTask {
- task_id: string
- task_no: string
- status: 'pending' | 'processing' | 'completed' | 'failed'
- progress?: {
- total: number
- processed: number
- succeeded: number
- failed: number
- }
- created_at?: string
- completed_at?: string
- }
- export interface ParentItem {
- index: number
- parent_id: string
- hierarchy?: string
- text: string
- metadata?: Record<string, any>
- doc_id?: string
- tag_list?: string[]
- permission?: {
- visible_roles?: string[]
- visible_users?: string[]
- }
- }
- export interface ChildItem extends ParentItem {
- parent_id: string
- }
- export function getSampleCenterKBList(
- params: {
- base_url: string
- app_id: string
- app_secret: string
- page?: number
- page_size?: number
- },
- loading?: Ref<boolean>,
- ): Promise<Result<{ total: number; items: SampleCenterKB[] }>> {
- return get('workspace/sample-center/knowledge-bases', params, loading)
- }
- export function getSampleCenterKBDetail(
- params: {
- kb_id: string
- base_url: string
- app_id: string
- app_secret: string
- },
- loading?: Ref<boolean>,
- ): Promise<Result<SampleCenterKBDetail>> {
- return get('workspace/sample-center/knowledge-bases/detail', params, loading)
- }
- export function submitBatchImport(
- data: {
- kb_id: string
- base_url: string
- app_id: string
- app_secret: string
- parents: ParentItem[]
- children?: ChildItem[]
- callback_url?: string
- },
- loading?: Ref<boolean>,
- ): Promise<Result<ImportTask>> {
- return post('workspace/sample-center/knowledge-bases/batch-import', data, loading)
- }
- export function getImportTaskStatus(
- params: {
- task_id: string
- base_url: string
- app_id: string
- app_secret: string
- },
- loading?: Ref<boolean>,
- ): Promise<Result<ImportTask>> {
- return get('workspace/sample-center/batch-import/task', params, loading)
- }
|