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
d3a2c0ed
Unverified
Commit
d3a2c0ed
authored
Dec 03, 2023
by
Yeuoly
Committed by
GitHub
Dec 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix wrong syntax of type definitions (#1678)
parent
8fbc374f
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
29 additions
and
29 deletions
+29
-29
completion.py
api/controllers/console/app/completion.py
+1
-1
message.py
api/controllers/console/app/message.py
+1
-1
completion.py
api/controllers/console/explore/completion.py
+1
-1
message.py
api/controllers/console/explore/message.py
+1
-1
chat.py
api/controllers/console/universal_chat/chat.py
+1
-1
completion.py
api/controllers/service_api/app/completion.py
+1
-1
message.py
api/controllers/web/message.py
+1
-1
agent_executor.py
api/core/agent/agent_executor.py
+1
-1
conversation_message_task.py
api/core/conversation_message_task.py
+6
-6
conversation_service.py
api/services/conversation_service.py
+4
-4
message_service.py
api/services/message_service.py
+5
-5
saved_message_service.py
api/services/saved_message_service.py
+3
-3
web_conversation_service.py
api/services/web_conversation_service.py
+3
-3
No files found.
api/controllers/console/app/completion.py
View file @
d3a2c0ed
...
@@ -161,7 +161,7 @@ class ChatMessageApi(Resource):
...
@@ -161,7 +161,7 @@ class ChatMessageApi(Resource):
raise
InternalServerError
()
raise
InternalServerError
()
def
compact_response
(
response
:
Union
[
dict
|
Generator
])
->
Response
:
def
compact_response
(
response
:
Union
[
dict
,
Generator
])
->
Response
:
if
isinstance
(
response
,
dict
):
if
isinstance
(
response
,
dict
):
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
else
:
else
:
...
...
api/controllers/console/app/message.py
View file @
d3a2c0ed
...
@@ -249,7 +249,7 @@ class MessageMoreLikeThisApi(Resource):
...
@@ -249,7 +249,7 @@ class MessageMoreLikeThisApi(Resource):
raise
InternalServerError
()
raise
InternalServerError
()
def
compact_response
(
response
:
Union
[
dict
|
Generator
])
->
Response
:
def
compact_response
(
response
:
Union
[
dict
,
Generator
])
->
Response
:
if
isinstance
(
response
,
dict
):
if
isinstance
(
response
,
dict
):
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
else
:
else
:
...
...
api/controllers/console/explore/completion.py
View file @
d3a2c0ed
...
@@ -154,7 +154,7 @@ class ChatStopApi(InstalledAppResource):
...
@@ -154,7 +154,7 @@ class ChatStopApi(InstalledAppResource):
return
{
'result'
:
'success'
},
200
return
{
'result'
:
'success'
},
200
def
compact_response
(
response
:
Union
[
dict
|
Generator
])
->
Response
:
def
compact_response
(
response
:
Union
[
dict
,
Generator
])
->
Response
:
if
isinstance
(
response
,
dict
):
if
isinstance
(
response
,
dict
):
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
else
:
else
:
...
...
api/controllers/console/explore/message.py
View file @
d3a2c0ed
...
@@ -105,7 +105,7 @@ class MessageMoreLikeThisApi(InstalledAppResource):
...
@@ -105,7 +105,7 @@ class MessageMoreLikeThisApi(InstalledAppResource):
raise
InternalServerError
()
raise
InternalServerError
()
def
compact_response
(
response
:
Union
[
dict
|
Generator
])
->
Response
:
def
compact_response
(
response
:
Union
[
dict
,
Generator
])
->
Response
:
if
isinstance
(
response
,
dict
):
if
isinstance
(
response
,
dict
):
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
else
:
else
:
...
...
api/controllers/console/universal_chat/chat.py
View file @
d3a2c0ed
...
@@ -104,7 +104,7 @@ class UniversalChatStopApi(UniversalChatResource):
...
@@ -104,7 +104,7 @@ class UniversalChatStopApi(UniversalChatResource):
return
{
'result'
:
'success'
},
200
return
{
'result'
:
'success'
},
200
def
compact_response
(
response
:
Union
[
dict
|
Generator
])
->
Response
:
def
compact_response
(
response
:
Union
[
dict
,
Generator
])
->
Response
:
if
isinstance
(
response
,
dict
):
if
isinstance
(
response
,
dict
):
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
else
:
else
:
...
...
api/controllers/service_api/app/completion.py
View file @
d3a2c0ed
...
@@ -150,7 +150,7 @@ class ChatStopApi(AppApiResource):
...
@@ -150,7 +150,7 @@ class ChatStopApi(AppApiResource):
return
{
'result'
:
'success'
},
200
return
{
'result'
:
'success'
},
200
def
compact_response
(
response
:
Union
[
dict
|
Generator
])
->
Response
:
def
compact_response
(
response
:
Union
[
dict
,
Generator
])
->
Response
:
if
isinstance
(
response
,
dict
):
if
isinstance
(
response
,
dict
):
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
else
:
else
:
...
...
api/controllers/web/message.py
View file @
d3a2c0ed
...
@@ -139,7 +139,7 @@ class MessageMoreLikeThisApi(WebApiResource):
...
@@ -139,7 +139,7 @@ class MessageMoreLikeThisApi(WebApiResource):
raise
InternalServerError
()
raise
InternalServerError
()
def
compact_response
(
response
:
Union
[
dict
|
Generator
])
->
Response
:
def
compact_response
(
response
:
Union
[
dict
,
Generator
])
->
Response
:
if
isinstance
(
response
,
dict
):
if
isinstance
(
response
,
dict
):
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
return
Response
(
response
=
json
.
dumps
(
response
),
status
=
200
,
mimetype
=
'application/json'
)
else
:
else
:
...
...
api/core/agent/agent_executor.py
View file @
d3a2c0ed
...
@@ -59,7 +59,7 @@ class AgentExecutor:
...
@@ -59,7 +59,7 @@ class AgentExecutor:
self
.
configuration
=
configuration
self
.
configuration
=
configuration
self
.
agent
=
self
.
_init_agent
()
self
.
agent
=
self
.
_init_agent
()
def
_init_agent
(
self
)
->
Union
[
BaseSingleActionAgent
|
BaseMultiActionAgent
]:
def
_init_agent
(
self
)
->
Union
[
BaseSingleActionAgent
,
BaseMultiActionAgent
]:
if
self
.
configuration
.
strategy
==
PlanningStrategy
.
REACT
:
if
self
.
configuration
.
strategy
==
PlanningStrategy
.
REACT
:
agent
=
AutoSummarizingStructuredChatAgent
.
from_llm_and_tools
(
agent
=
AutoSummarizingStructuredChatAgent
.
from_llm_and_tools
(
model_instance
=
self
.
configuration
.
model_instance
,
model_instance
=
self
.
configuration
.
model_instance
,
...
...
api/core/conversation_message_task.py
View file @
d3a2c0ed
...
@@ -321,7 +321,7 @@ class ConversationMessageTask:
...
@@ -321,7 +321,7 @@ class ConversationMessageTask:
class
PubHandler
:
class
PubHandler
:
def
__init__
(
self
,
user
:
Union
[
Account
|
EndUser
],
task_id
:
str
,
def
__init__
(
self
,
user
:
Union
[
Account
,
EndUser
],
task_id
:
str
,
message
:
Message
,
conversation
:
Conversation
,
message
:
Message
,
conversation
:
Conversation
,
chain_pub
:
bool
=
False
,
agent_thought_pub
:
bool
=
False
):
chain_pub
:
bool
=
False
,
agent_thought_pub
:
bool
=
False
):
self
.
_channel
=
PubHandler
.
generate_channel_name
(
user
,
task_id
)
self
.
_channel
=
PubHandler
.
generate_channel_name
(
user
,
task_id
)
...
@@ -334,7 +334,7 @@ class PubHandler:
...
@@ -334,7 +334,7 @@ class PubHandler:
self
.
_agent_thought_pub
=
agent_thought_pub
self
.
_agent_thought_pub
=
agent_thought_pub
@
classmethod
@
classmethod
def
generate_channel_name
(
cls
,
user
:
Union
[
Account
|
EndUser
],
task_id
:
str
):
def
generate_channel_name
(
cls
,
user
:
Union
[
Account
,
EndUser
],
task_id
:
str
):
if
not
user
:
if
not
user
:
raise
ValueError
(
"user is required"
)
raise
ValueError
(
"user is required"
)
...
@@ -342,7 +342,7 @@ class PubHandler:
...
@@ -342,7 +342,7 @@ class PubHandler:
return
"generate_result:{}-{}"
.
format
(
user_str
,
task_id
)
return
"generate_result:{}-{}"
.
format
(
user_str
,
task_id
)
@
classmethod
@
classmethod
def
generate_stopped_cache_key
(
cls
,
user
:
Union
[
Account
|
EndUser
],
task_id
:
str
):
def
generate_stopped_cache_key
(
cls
,
user
:
Union
[
Account
,
EndUser
],
task_id
:
str
):
user_str
=
'account-'
+
str
(
user
.
id
)
if
isinstance
(
user
,
Account
)
else
'end-user-'
+
str
(
user
.
id
)
user_str
=
'account-'
+
str
(
user
.
id
)
if
isinstance
(
user
,
Account
)
else
'end-user-'
+
str
(
user
.
id
)
return
"generate_result_stopped:{}-{}"
.
format
(
user_str
,
task_id
)
return
"generate_result_stopped:{}-{}"
.
format
(
user_str
,
task_id
)
...
@@ -454,7 +454,7 @@ class PubHandler:
...
@@ -454,7 +454,7 @@ class PubHandler:
redis_client
.
publish
(
self
.
_channel
,
json
.
dumps
(
content
))
redis_client
.
publish
(
self
.
_channel
,
json
.
dumps
(
content
))
@
classmethod
@
classmethod
def
pub_error
(
cls
,
user
:
Union
[
Account
|
EndUser
],
task_id
:
str
,
e
):
def
pub_error
(
cls
,
user
:
Union
[
Account
,
EndUser
],
task_id
:
str
,
e
):
content
=
{
content
=
{
'error'
:
type
(
e
)
.
__name__
,
'error'
:
type
(
e
)
.
__name__
,
'description'
:
e
.
description
if
getattr
(
e
,
'description'
,
None
)
is
not
None
else
str
(
e
)
'description'
:
e
.
description
if
getattr
(
e
,
'description'
,
None
)
is
not
None
else
str
(
e
)
...
@@ -467,7 +467,7 @@ class PubHandler:
...
@@ -467,7 +467,7 @@ class PubHandler:
return
redis_client
.
get
(
self
.
_stopped_cache_key
)
is
not
None
return
redis_client
.
get
(
self
.
_stopped_cache_key
)
is
not
None
@
classmethod
@
classmethod
def
ping
(
cls
,
user
:
Union
[
Account
|
EndUser
],
task_id
:
str
):
def
ping
(
cls
,
user
:
Union
[
Account
,
EndUser
],
task_id
:
str
):
content
=
{
content
=
{
'event'
:
'ping'
'event'
:
'ping'
}
}
...
@@ -476,7 +476,7 @@ class PubHandler:
...
@@ -476,7 +476,7 @@ class PubHandler:
redis_client
.
publish
(
channel
,
json
.
dumps
(
content
))
redis_client
.
publish
(
channel
,
json
.
dumps
(
content
))
@
classmethod
@
classmethod
def
stop
(
cls
,
user
:
Union
[
Account
|
EndUser
],
task_id
:
str
):
def
stop
(
cls
,
user
:
Union
[
Account
,
EndUser
],
task_id
:
str
):
stopped_cache_key
=
cls
.
generate_stopped_cache_key
(
user
,
task_id
)
stopped_cache_key
=
cls
.
generate_stopped_cache_key
(
user
,
task_id
)
redis_client
.
setex
(
stopped_cache_key
,
600
,
1
)
redis_client
.
setex
(
stopped_cache_key
,
600
,
1
)
...
...
api/services/conversation_service.py
View file @
d3a2c0ed
...
@@ -11,7 +11,7 @@ from services.errors.message import MessageNotExistsError
...
@@ -11,7 +11,7 @@ from services.errors.message import MessageNotExistsError
class
ConversationService
:
class
ConversationService
:
@
classmethod
@
classmethod
def
pagination_by_last_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
def
pagination_by_last_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
last_id
:
Optional
[
str
],
limit
:
int
,
last_id
:
Optional
[
str
],
limit
:
int
,
include_ids
:
Optional
[
list
]
=
None
,
exclude_ids
:
Optional
[
list
]
=
None
,
include_ids
:
Optional
[
list
]
=
None
,
exclude_ids
:
Optional
[
list
]
=
None
,
exclude_debug_conversation
:
bool
=
False
)
->
InfiniteScrollPagination
:
exclude_debug_conversation
:
bool
=
False
)
->
InfiniteScrollPagination
:
...
@@ -69,7 +69,7 @@ class ConversationService:
...
@@ -69,7 +69,7 @@ class ConversationService:
@
classmethod
@
classmethod
def
rename
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
def
rename
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
name
:
str
,
auto_generate
:
bool
):
user
:
Optional
[
Union
[
Account
,
EndUser
]],
name
:
str
,
auto_generate
:
bool
):
conversation
=
cls
.
get_conversation
(
app_model
,
conversation_id
,
user
)
conversation
=
cls
.
get_conversation
(
app_model
,
conversation_id
,
user
)
if
auto_generate
:
if
auto_generate
:
...
@@ -104,7 +104,7 @@ class ConversationService:
...
@@ -104,7 +104,7 @@ class ConversationService:
return
conversation
return
conversation
@
classmethod
@
classmethod
def
get_conversation
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
|
EndUser
]]):
def
get_conversation
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
,
EndUser
]]):
conversation
=
db
.
session
.
query
(
Conversation
)
\
conversation
=
db
.
session
.
query
(
Conversation
)
\
.
filter
(
.
filter
(
Conversation
.
id
==
conversation_id
,
Conversation
.
id
==
conversation_id
,
...
@@ -121,7 +121,7 @@ class ConversationService:
...
@@ -121,7 +121,7 @@ class ConversationService:
return
conversation
return
conversation
@
classmethod
@
classmethod
def
delete
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
|
EndUser
]]):
def
delete
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
,
EndUser
]]):
conversation
=
cls
.
get_conversation
(
app_model
,
conversation_id
,
user
)
conversation
=
cls
.
get_conversation
(
app_model
,
conversation_id
,
user
)
conversation
.
is_deleted
=
True
conversation
.
is_deleted
=
True
...
...
api/services/message_service.py
View file @
d3a2c0ed
...
@@ -16,7 +16,7 @@ from services.errors.message import FirstMessageNotExistsError, MessageNotExists
...
@@ -16,7 +16,7 @@ from services.errors.message import FirstMessageNotExistsError, MessageNotExists
class
MessageService
:
class
MessageService
:
@
classmethod
@
classmethod
def
pagination_by_first_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
def
pagination_by_first_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
conversation_id
:
str
,
first_id
:
Optional
[
str
],
limit
:
int
)
->
InfiniteScrollPagination
:
conversation_id
:
str
,
first_id
:
Optional
[
str
],
limit
:
int
)
->
InfiniteScrollPagination
:
if
not
user
:
if
not
user
:
return
InfiniteScrollPagination
(
data
=
[],
limit
=
limit
,
has_more
=
False
)
return
InfiniteScrollPagination
(
data
=
[],
limit
=
limit
,
has_more
=
False
)
...
@@ -68,7 +68,7 @@ class MessageService:
...
@@ -68,7 +68,7 @@ class MessageService:
)
)
@
classmethod
@
classmethod
def
pagination_by_last_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
def
pagination_by_last_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
last_id
:
Optional
[
str
],
limit
:
int
,
conversation_id
:
Optional
[
str
]
=
None
,
last_id
:
Optional
[
str
],
limit
:
int
,
conversation_id
:
Optional
[
str
]
=
None
,
include_ids
:
Optional
[
list
]
=
None
)
->
InfiniteScrollPagination
:
include_ids
:
Optional
[
list
]
=
None
)
->
InfiniteScrollPagination
:
if
not
user
:
if
not
user
:
...
@@ -119,7 +119,7 @@ class MessageService:
...
@@ -119,7 +119,7 @@ class MessageService:
)
)
@
classmethod
@
classmethod
def
create_feedback
(
cls
,
app_model
:
App
,
message_id
:
str
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
def
create_feedback
(
cls
,
app_model
:
App
,
message_id
:
str
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
rating
:
Optional
[
str
])
->
MessageFeedback
:
rating
:
Optional
[
str
])
->
MessageFeedback
:
if
not
user
:
if
not
user
:
raise
ValueError
(
'user cannot be None'
)
raise
ValueError
(
'user cannot be None'
)
...
@@ -155,7 +155,7 @@ class MessageService:
...
@@ -155,7 +155,7 @@ class MessageService:
return
feedback
return
feedback
@
classmethod
@
classmethod
def
get_message
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
message_id
:
str
):
def
get_message
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
message_id
:
str
):
message
=
db
.
session
.
query
(
Message
)
.
filter
(
message
=
db
.
session
.
query
(
Message
)
.
filter
(
Message
.
id
==
message_id
,
Message
.
id
==
message_id
,
Message
.
app_id
==
app_model
.
id
,
Message
.
app_id
==
app_model
.
id
,
...
@@ -170,7 +170,7 @@ class MessageService:
...
@@ -170,7 +170,7 @@ class MessageService:
return
message
return
message
@
classmethod
@
classmethod
def
get_suggested_questions_after_answer
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
def
get_suggested_questions_after_answer
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
message_id
:
str
,
check_enabled
:
bool
=
True
)
->
List
[
Message
]:
message_id
:
str
,
check_enabled
:
bool
=
True
)
->
List
[
Message
]:
if
not
user
:
if
not
user
:
raise
ValueError
(
'user cannot be None'
)
raise
ValueError
(
'user cannot be None'
)
...
...
api/services/saved_message_service.py
View file @
d3a2c0ed
...
@@ -10,7 +10,7 @@ from services.message_service import MessageService
...
@@ -10,7 +10,7 @@ from services.message_service import MessageService
class
SavedMessageService
:
class
SavedMessageService
:
@
classmethod
@
classmethod
def
pagination_by_last_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
def
pagination_by_last_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
last_id
:
Optional
[
str
],
limit
:
int
)
->
InfiniteScrollPagination
:
last_id
:
Optional
[
str
],
limit
:
int
)
->
InfiniteScrollPagination
:
saved_messages
=
db
.
session
.
query
(
SavedMessage
)
.
filter
(
saved_messages
=
db
.
session
.
query
(
SavedMessage
)
.
filter
(
SavedMessage
.
app_id
==
app_model
.
id
,
SavedMessage
.
app_id
==
app_model
.
id
,
...
@@ -28,7 +28,7 @@ class SavedMessageService:
...
@@ -28,7 +28,7 @@ class SavedMessageService:
)
)
@
classmethod
@
classmethod
def
save
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
message_id
:
str
):
def
save
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
message_id
:
str
):
saved_message
=
db
.
session
.
query
(
SavedMessage
)
.
filter
(
saved_message
=
db
.
session
.
query
(
SavedMessage
)
.
filter
(
SavedMessage
.
app_id
==
app_model
.
id
,
SavedMessage
.
app_id
==
app_model
.
id
,
SavedMessage
.
message_id
==
message_id
,
SavedMessage
.
message_id
==
message_id
,
...
@@ -56,7 +56,7 @@ class SavedMessageService:
...
@@ -56,7 +56,7 @@ class SavedMessageService:
db
.
session
.
commit
()
db
.
session
.
commit
()
@
classmethod
@
classmethod
def
delete
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
message_id
:
str
):
def
delete
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
message_id
:
str
):
saved_message
=
db
.
session
.
query
(
SavedMessage
)
.
filter
(
saved_message
=
db
.
session
.
query
(
SavedMessage
)
.
filter
(
SavedMessage
.
app_id
==
app_model
.
id
,
SavedMessage
.
app_id
==
app_model
.
id
,
SavedMessage
.
message_id
==
message_id
,
SavedMessage
.
message_id
==
message_id
,
...
...
api/services/web_conversation_service.py
View file @
d3a2c0ed
...
@@ -10,7 +10,7 @@ from services.conversation_service import ConversationService
...
@@ -10,7 +10,7 @@ from services.conversation_service import ConversationService
class
WebConversationService
:
class
WebConversationService
:
@
classmethod
@
classmethod
def
pagination_by_last_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
|
EndUser
]],
def
pagination_by_last_id
(
cls
,
app_model
:
App
,
user
:
Optional
[
Union
[
Account
,
EndUser
]],
last_id
:
Optional
[
str
],
limit
:
int
,
pinned
:
Optional
[
bool
]
=
None
,
last_id
:
Optional
[
str
],
limit
:
int
,
pinned
:
Optional
[
bool
]
=
None
,
exclude_debug_conversation
:
bool
=
False
)
->
InfiniteScrollPagination
:
exclude_debug_conversation
:
bool
=
False
)
->
InfiniteScrollPagination
:
include_ids
=
None
include_ids
=
None
...
@@ -38,7 +38,7 @@ class WebConversationService:
...
@@ -38,7 +38,7 @@ class WebConversationService:
)
)
@
classmethod
@
classmethod
def
pin
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
|
EndUser
]]):
def
pin
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
,
EndUser
]]):
pinned_conversation
=
db
.
session
.
query
(
PinnedConversation
)
.
filter
(
pinned_conversation
=
db
.
session
.
query
(
PinnedConversation
)
.
filter
(
PinnedConversation
.
app_id
==
app_model
.
id
,
PinnedConversation
.
app_id
==
app_model
.
id
,
PinnedConversation
.
conversation_id
==
conversation_id
,
PinnedConversation
.
conversation_id
==
conversation_id
,
...
@@ -66,7 +66,7 @@ class WebConversationService:
...
@@ -66,7 +66,7 @@ class WebConversationService:
db
.
session
.
commit
()
db
.
session
.
commit
()
@
classmethod
@
classmethod
def
unpin
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
|
EndUser
]]):
def
unpin
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
,
EndUser
]]):
pinned_conversation
=
db
.
session
.
query
(
PinnedConversation
)
.
filter
(
pinned_conversation
=
db
.
session
.
query
(
PinnedConversation
)
.
filter
(
PinnedConversation
.
app_id
==
app_model
.
id
,
PinnedConversation
.
app_id
==
app_model
.
id
,
PinnedConversation
.
conversation_id
==
conversation_id
,
PinnedConversation
.
conversation_id
==
conversation_id
,
...
...
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