dataset.api 3.5 KB
syntax = "v1"

// 后台接口
@server(
    prefix: v1
    group: dataset
    middleware: LogRequest
    jwt: SystemAuth
)
service Core {
    @doc  "知识库-详情"
    @handler chatDatasetGet
    get /chat/dataset/:id (ChatDatasetGetRequest) returns (ChatDatasetGetResponse)
    @doc  "知识库-保存"
    @handler chatDatasetSave
    post /chat/dataset (ChatDatasetSaveRequest) returns (ChatDatasetSaveResponse)
    @doc  "知识库-删除"
    @handler chatDatasetDelete
    delete /chat/dataset/:id (ChatDatasetDeleteRequest) returns (ChatDatasetDeleteResponse)
    @doc  "知识库-更新"
    @handler chatDatasetUpdate
    put /chat/dataset/:id (ChatDatasetUpdateRequest) returns (ChatDatasetUpdateResponse)
    @doc  "知识库-重命名"
    @handler chatDatasetRename
    post /chat/dataset/rename (ChatDatasetRenameRequest) returns (ChatDatasetRenameResponse)
    @doc  "知识库-搜索"
    @handler chatDatasetSearch
    post /chat/dataset/search (ChatDatasetSearchRequest) returns (ChatDatasetSearchResponse)
    @doc  "知识库-添加文件"
    @handler chatDatasetAddFiles
    post /chat/dataset/add_files (ChatDatasetAddFilesRequest) returns (ChatDatasetAddFilesResponse)
    @doc  "知识库-移除文件"
    @handler chatDatasetRemvoeFiles
    post /chat/dataset/remove_files (ChatDatasetAddFilesRequest) returns (ChatDatasetAddFilesResponse)
}

type (
    ChatDatasetGetRequest {
        Id int64 `path:"id"`
    }
    ChatDatasetGetResponse {
        ChatDataset ChatDatasetItem    `json:"dataset"`
        Documents   []ChatDocumentItem `json:"documents"`
    }

    ChatDatasetSaveRequest {
        Name        string   `json:"name"`      // 名称
        DocumentIds []int64  `json:"documentIds"` // 文档ID列表
    }
    ChatDatasetSaveResponse {
        ChatDataset ChatDatasetItem `json:"dataset"`
    }

    ChatDatasetDeleteRequest {
        Id int64 `path:"id"`
    }
    ChatDatasetDeleteResponse {}

    ChatDatasetUpdateRequest {
        Id int64 `path:"id"`
        ChatDataset ChatDatasetItem `json:"dataset"`
    }
    ChatDatasetUpdateResponse {}

    ChatDatasetSearchRequest {
        Page     int    `json:"page,optional"`
        Size     int    `json:"size,optional"`
        Name     string `json:"name,optional"`      // 文件名匹配
        Status   int    `json:"status,optional,option=0|1|2"`// 1:启用 2:禁用
    }
    ChatDatasetSearchResponse{
        List []ChatDatasetItem  `json:"list"`
        Total int64             `json:"total"`
    }
    ChatDatasetItem {
        Id        int64   `json:"id,optional,omitempty"`
        Name      *string `json:"name,optional,omitempty"`  // 名称
        Desc      *string `json:"desc,optional,omitempty"`  // 描述
        Status    *int    `json:"status,optional,omitempty"`// 状态 1:启用 2:禁用
        CreatedAt int64   `json:"createdAt,optional,omitempty"`  // 创建时间
        UpdatedAt int64   `json:"updatedAt,optional,omitempty"`  // 更新时间
        FileNumber *int    `json:"fileNumber,optional,omitempty"`  // 文件数量
    }
)

// 知识库重命名
type(
    ChatDatasetRenameRequest{
        Id   int64  `json:"id"`   // 文档ID
        Name string `json:"name"` // 新名称
    }
    ChatDatasetRenameResponse{
        ChatDataset ChatDatasetItem `json:"dataset"`
    }
)

// 知识库添加新文档
type(
    ChatDatasetAddFilesRequest{
        Id   int64  `json:"id"`   // 文档ID
        DocumentIds []int64  `json:"documentIds"` // 文档ID列表
    }
    ChatDatasetAddFilesResponse{

    }
)