更新
This commit is contained in:
@@ -219,6 +219,32 @@ func (c *Client) UploadDocument(ctx context.Context, datasetId string, filePaths
|
||||
return gerror.New("upload document from file not implemented yet, use UploadDocumentFromText instead")
|
||||
}
|
||||
|
||||
// ParseDocumentsReq 解析文档请求
|
||||
type ParseDocumentsReq struct {
|
||||
DocumentIds []string `json:"document_ids"` // 要解析的文档ID列表
|
||||
}
|
||||
|
||||
// ParseDocuments 解析文档(上传后必须调用此接口才会开始解析)
|
||||
func (c *Client) ParseDocuments(ctx context.Context, datasetId string, documentIds []string) error {
|
||||
if datasetId == "" {
|
||||
return gerror.New("datasetId不能为空")
|
||||
}
|
||||
if len(documentIds) == 0 {
|
||||
return gerror.New("documentIds不能为空")
|
||||
}
|
||||
|
||||
req := ParseDocumentsReq{DocumentIds: documentIds}
|
||||
var res CommonResponse
|
||||
path := "/api/v1/datasets/" + datasetId + "/chunks"
|
||||
if err := c.request(ctx, "POST", path, req, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
if !res.IsSuccess() {
|
||||
return gerror.Newf("解析文档失败: %s", res.Message)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteDocument 删除文档
|
||||
func (c *Client) DeleteDocument(ctx context.Context, datasetId string, ids []string) (err error) {
|
||||
req := DeleteDocumentsReq{Ids: ids}
|
||||
|
||||
Reference in New Issue
Block a user