Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
f8e3ad69
Commit
f8e3ad69
authored
Mar 12, 2024
by
jyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support mutil documents retry
parent
2790cf4c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
18 deletions
+29
-18
datasets_document.py
api/controllers/console/datasets/datasets_document.py
+29
-18
No files found.
api/controllers/console/datasets/datasets_document.py
View file @
f8e3ad69
import
logging
from
datetime
import
datetime
from
flask
import
request
...
...
@@ -883,35 +884,44 @@ class DocumentRecoverApi(DocumentResource):
return
{
'result'
:
'success'
},
204
class
DocumentRetryApi
(
DocumentResource
):
@
setup_required
@
login_required
@
account_initialization_required
def
post
(
self
,
dataset_id
,
document_id
):
def
post
(
self
,
dataset_id
):
"""retry document."""
parser
=
reqparse
.
RequestParser
()
parser
.
add_argument
(
'document_ids'
,
type
=
list
,
required
=
True
,
nullable
=
False
,
location
=
'json'
)
args
=
parser
.
parse_args
()
dataset_id
=
str
(
dataset_id
)
document_id
=
str
(
document_id
)
dataset
=
DatasetService
.
get_dataset
(
dataset_id
)
if
not
dataset
:
raise
NotFound
(
'Dataset not found.'
)
for
document_id
in
args
[
'document_ids'
]:
try
:
document_id
=
str
(
document_id
)
dataset
=
DatasetService
.
get_dataset
(
dataset_id
)
if
not
dataset
:
raise
NotFound
(
'Dataset not found.'
)
document
=
DocumentService
.
get_document
(
dataset
.
id
,
document_id
)
document
=
DocumentService
.
get_document
(
dataset
.
id
,
document_id
)
# 404 if document not found
if
document
is
None
:
raise
NotFound
(
"Document Not Exists."
)
# 404 if document not found
if
document
is
None
:
raise
NotFound
(
"Document Not Exists."
)
# 403 if document is archived
if
DocumentService
.
check_archived
(
document
):
raise
ArchivedDocumentImmutableError
()
# 403 if document is archived
if
DocumentService
.
check_archived
(
document
):
raise
ArchivedDocumentImmutableError
()
# 400 if document is completed
if
document
.
indexing_status
==
'completed'
:
raise
DocumentAlreadyFinishedError
()
# 400 if document is completed
if
document
.
indexing_status
==
'completed'
:
raise
DocumentAlreadyFinishedError
()
# retry document
DocumentService
.
retry_document
(
document
)
# retry document
DocumentService
.
retry_document
(
document
)
except
Exception
as
e
:
logging
.
error
(
f
"Document {document_id} retry failed: {str(e)}"
)
continue
return
{
'result'
:
'success'
},
204
...
...
@@ -941,3 +951,4 @@ api.add_resource(DocumentStatusApi,
'/datasets/<uuid:dataset_id>/documents/<uuid:document_id>/status/<string:action>'
)
api
.
add_resource
(
DocumentPauseApi
,
'/datasets/<uuid:dataset_id>/documents/<uuid:document_id>/processing/pause'
)
api
.
add_resource
(
DocumentRecoverApi
,
'/datasets/<uuid:dataset_id>/documents/<uuid:document_id>/processing/resume'
)
api
.
add_resource
(
DocumentRetryApi
,
'/datasets/<uuid:dataset_id>/retry'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment