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
5a6cb699
Unverified
Commit
5a6cb699
authored
Jan 27, 2024
by
takatost
Committed by
GitHub
Jan 27, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: user handling in stop api (#2254)
parent
11a75ee7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
11 deletions
+24
-11
completion.py
api/controllers/service_api/app/completion.py
+24
-11
No files found.
api/controllers/service_api/app/completion.py
View file @
5a6cb699
...
@@ -13,7 +13,7 @@ from core.application_queue_manager import ApplicationQueueManager
...
@@ -13,7 +13,7 @@ from core.application_queue_manager import ApplicationQueueManager
from
core.entities.application_entities
import
InvokeFrom
from
core.entities.application_entities
import
InvokeFrom
from
core.errors.error
import
ModelCurrentlyNotSupportError
,
ProviderTokenNotInitError
,
QuotaExceededError
from
core.errors.error
import
ModelCurrentlyNotSupportError
,
ProviderTokenNotInitError
,
QuotaExceededError
from
core.model_runtime.errors.invoke
import
InvokeError
from
core.model_runtime.errors.invoke
import
InvokeError
from
flask
import
Response
,
stream_with_context
,
request
from
flask
import
Response
,
stream_with_context
from
flask_restful
import
reqparse
from
flask_restful
import
reqparse
from
libs.helper
import
uuid_value
from
libs.helper
import
uuid_value
from
services.completion_service
import
CompletionService
from
services.completion_service
import
CompletionService
...
@@ -75,18 +75,22 @@ class CompletionApi(AppApiResource):
...
@@ -75,18 +75,22 @@ class CompletionApi(AppApiResource):
class
CompletionStopApi
(
AppApiResource
):
class
CompletionStopApi
(
AppApiResource
):
def
post
(
self
,
app_model
,
_
,
task_id
):
def
post
(
self
,
app_model
,
end_user
,
task_id
):
if
app_model
.
mode
!=
'completion'
:
if
app_model
.
mode
!=
'completion'
:
raise
AppUnavailableError
()
raise
AppUnavailableError
()
parser
=
reqparse
.
RequestParser
()
if
end_user
is
None
:
parser
.
add_argument
(
'user'
,
required
=
True
,
nullable
=
False
,
type
=
str
,
location
=
'json'
)
parser
=
reqparse
.
RequestParser
()
parser
.
add_argument
(
'user'
,
required
=
True
,
nullable
=
False
,
type
=
str
,
location
=
'json'
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
user
=
args
.
get
(
'user'
)
if
user
is
not
None
:
end_user
=
create_or_update_end_user_for_user_id
(
app_model
,
user
)
else
:
raise
ValueError
(
"arg user muse be input."
)
end_user_id
=
args
.
get
(
'user'
)
ApplicationQueueManager
.
set_stop_flag
(
task_id
,
InvokeFrom
.
SERVICE_API
,
end_user
.
id
)
ApplicationQueueManager
.
set_stop_flag
(
task_id
,
InvokeFrom
.
SERVICE_API
,
end_user_id
)
return
{
'result'
:
'success'
},
200
return
{
'result'
:
'success'
},
200
...
@@ -146,13 +150,22 @@ class ChatApi(AppApiResource):
...
@@ -146,13 +150,22 @@ class ChatApi(AppApiResource):
class
ChatStopApi
(
AppApiResource
):
class
ChatStopApi
(
AppApiResource
):
def
post
(
self
,
app_model
,
_
,
task_id
):
def
post
(
self
,
app_model
,
end_user
,
task_id
):
if
app_model
.
mode
!=
'chat'
:
if
app_model
.
mode
!=
'chat'
:
raise
NotChatAppError
()
raise
NotChatAppError
()
end_user_id
=
request
.
get_json
()
.
get
(
'user'
)
if
end_user
is
None
:
parser
=
reqparse
.
RequestParser
()
parser
.
add_argument
(
'user'
,
required
=
True
,
nullable
=
False
,
type
=
str
,
location
=
'json'
)
args
=
parser
.
parse_args
()
user
=
args
.
get
(
'user'
)
if
user
is
not
None
:
end_user
=
create_or_update_end_user_for_user_id
(
app_model
,
user
)
else
:
raise
ValueError
(
"arg user muse be input."
)
ApplicationQueueManager
.
set_stop_flag
(
task_id
,
InvokeFrom
.
SERVICE_API
,
end_user
_
id
)
ApplicationQueueManager
.
set_stop_flag
(
task_id
,
InvokeFrom
.
SERVICE_API
,
end_user
.
id
)
return
{
'result'
:
'success'
},
200
return
{
'result'
:
'success'
},
200
...
...
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