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
60cc9986
Commit
60cc9986
authored
Jun 27, 2023
by
crazywoola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add delete api to service
parent
6e3ffc25
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
0 deletions
+21
-0
conversation.py
api/controllers/service_api/app/conversation.py
+20
-0
conversation_service.py
api/services/conversation_service.py
+1
-0
No files found.
api/controllers/service_api/app/conversation.py
View file @
60cc9986
...
@@ -48,6 +48,25 @@ class ConversationApi(AppApiResource):
...
@@ -48,6 +48,25 @@ class ConversationApi(AppApiResource):
except
services
.
errors
.
conversation
.
LastConversationNotExistsError
:
except
services
.
errors
.
conversation
.
LastConversationNotExistsError
:
raise
NotFound
(
"Last Conversation Not Exists."
)
raise
NotFound
(
"Last Conversation Not Exists."
)
class
ConversationDetailApi
(
AppApiResource
):
@
marshal_with
(
conversation_fields
)
def
delete
(
self
,
app_model
,
end_user
,
c_id
):
if
app_model
.
mode
!=
'chat'
:
raise
NotChatAppError
()
conversation_id
=
str
(
c_id
)
parser
=
reqparse
.
RequestParser
()
parser
.
add_argument
(
'user'
,
type
=
str
,
location
=
'args'
)
args
=
parser
.
parse_args
()
if
end_user
is
None
and
args
[
'user'
]
is
not
None
:
end_user
=
create_or_update_end_user_for_user_id
(
app_model
,
args
[
'user'
])
try
:
return
ConversationService
.
delete
(
app_model
,
conversation_id
,
end_user
)
except
services
.
errors
.
conversation
.
ConversationNotExistsError
:
raise
NotFound
(
"Conversation Not Exists."
)
class
ConversationRenameApi
(
AppApiResource
):
class
ConversationRenameApi
(
AppApiResource
):
...
@@ -74,3 +93,4 @@ class ConversationRenameApi(AppApiResource):
...
@@ -74,3 +93,4 @@ class ConversationRenameApi(AppApiResource):
api
.
add_resource
(
ConversationRenameApi
,
'/conversations/<uuid:c_id>/name'
,
endpoint
=
'conversation_name'
)
api
.
add_resource
(
ConversationRenameApi
,
'/conversations/<uuid:c_id>/name'
,
endpoint
=
'conversation_name'
)
api
.
add_resource
(
ConversationApi
,
'/conversations'
)
api
.
add_resource
(
ConversationApi
,
'/conversations'
)
api
.
add_resource
(
ConversationApi
,
'/conversations/<uuid:c_id>'
)
api/services/conversation_service.py
View file @
60cc9986
...
@@ -79,6 +79,7 @@ class ConversationService:
...
@@ -79,6 +79,7 @@ class ConversationService:
Conversation
.
from_source
==
(
'api'
if
isinstance
(
user
,
EndUser
)
else
'console'
),
Conversation
.
from_source
==
(
'api'
if
isinstance
(
user
,
EndUser
)
else
'console'
),
Conversation
.
from_end_user_id
==
(
user
.
id
if
isinstance
(
user
,
EndUser
)
else
None
),
Conversation
.
from_end_user_id
==
(
user
.
id
if
isinstance
(
user
,
EndUser
)
else
None
),
Conversation
.
from_account_id
==
(
user
.
id
if
isinstance
(
user
,
Account
)
else
None
),
Conversation
.
from_account_id
==
(
user
.
id
if
isinstance
(
user
,
Account
)
else
None
),
Conversation
.
is_deleted
==
False
)
.
first
()
)
.
first
()
if
not
conversation
:
if
not
conversation
:
...
...
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