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
a9ee1830
Unverified
Commit
a9ee1830
authored
Nov 04, 2023
by
crazywoola
Committed by
GitHub
Nov 04, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: service suggested api (#1452)
parent
b4861d2b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
message.py
api/controllers/service_api/app/message.py
+10
-8
template_chat.zh.mdx
web/app/components/develop/template/template_chat.zh.mdx
+2
-2
No files found.
api/controllers/service_api/app/message.py
View file @
a9ee1830
...
@@ -11,7 +11,7 @@ from controllers.service_api.wraps import AppApiResource
...
@@ -11,7 +11,7 @@ from controllers.service_api.wraps import AppApiResource
from
libs.helper
import
TimestampField
,
uuid_value
from
libs.helper
import
TimestampField
,
uuid_value
from
services.message_service
import
MessageService
from
services.message_service
import
MessageService
from
extensions.ext_database
import
db
from
extensions.ext_database
import
db
from
models.model
import
Account
,
Message
from
models.model
import
Message
,
EndUser
class
MessageListApi
(
AppApiResource
):
class
MessageListApi
(
AppApiResource
):
...
@@ -103,24 +103,26 @@ class MessageSuggestedApi(AppApiResource):
...
@@ -103,24 +103,26 @@ class MessageSuggestedApi(AppApiResource):
message_id
=
str
(
message_id
)
message_id
=
str
(
message_id
)
if
app_model
.
mode
!=
'chat'
:
if
app_model
.
mode
!=
'chat'
:
raise
NotChatAppError
()
raise
NotChatAppError
()
try
:
try
:
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
,
)
.
first
()
)
.
first
()
if
end_user
is
None
and
message
.
from_account_id
is
not
None
:
if
end_user
is
None
and
message
.
from_end_user_id
is
not
None
:
user
=
db
.
session
.
get
(
Account
,
message
.
from_account_id
)
user
=
db
.
session
.
query
(
EndUser
)
\
elif
end_user
is
None
and
message
.
from_end_user_id
is
not
None
:
.
filter
(
user
=
create_or_update_end_user_for_user_id
(
app_model
,
message
.
from_end_user_id
)
EndUser
.
tenant_id
==
app_model
.
tenant_id
,
EndUser
.
id
==
message
.
from_end_user_id
,
EndUser
.
type
==
'service_api'
)
.
first
()
else
:
else
:
user
=
end_user
user
=
end_user
questions
=
MessageService
.
get_suggested_questions_after_answer
(
questions
=
MessageService
.
get_suggested_questions_after_answer
(
app_model
=
app_model
,
app_model
=
app_model
,
user
=
user
,
user
=
user
,
message_id
=
message_id
message_id
=
message_id
,
check_enabled
=
False
)
)
except
services
.
errors
.
message
.
MessageNotExistsError
:
except
services
.
errors
.
message
.
MessageNotExistsError
:
raise
NotFound
(
"Message Not Exists."
)
raise
NotFound
(
"Message Not Exists."
)
...
...
web/app/components/develop/template/template_chat.zh.mdx
View file @
a9ee1830
...
@@ -196,10 +196,10 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
...
@@ -196,10 +196,10 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'
</Col>
</Col>
<Col sticky>
<Col sticky>
<CodeGroup title="Request" tag="GET" label="/messages/{message_id}/suggested" targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--header 'Content-Type: application/json'`}>
<CodeGroup title="Request" tag="GET" label="/messages/{message_id}/suggested" targetCode={`curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggested
'
\\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--header 'Content-Type: application/json'`}>
```bash {{ title: 'cURL' }}
```bash {{ title: 'cURL' }}
curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggeste' \
curl --location --request GET '${props.appDetail.api_base_url}/messages/{message_id}/suggeste
d
' \
--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \
--header 'Content-Type: application/json' \
--header 'Content-Type: application/json' \
```
```
...
...
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