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
d26b7363
Unverified
Commit
d26b7363
authored
Feb 28, 2024
by
Yeuoly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: rename api
parent
d85ced8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
__init__.py
api/controllers/inner_api/__init__.py
+1
-1
service.py
api/controllers/inner_api/service.py
+33
-0
conversation_service.py
api/services/conversation_service.py
+11
-0
No files found.
api/controllers/inner_api/__init__.py
View file @
d26b7363
...
...
@@ -4,4 +4,4 @@ from libs.external_api import ExternalApi
bp
=
Blueprint
(
'inner_api'
,
__name__
,
url_prefix
=
'/inner/api'
)
api
=
ExternalApi
(
bp
)
from
.
import
authorization
,
model_runtime
,
app
\ No newline at end of file
from
.
import
authorization
,
model_runtime
,
app
,
service
\ No newline at end of file
api/controllers/inner_api/service.py
0 → 100644
View file @
d26b7363
import
json
from
collections.abc
import
Generator
from
typing
import
Union
from
flask
import
Response
from
flask.helpers
import
stream_with_context
from
flask_restful
import
Resource
,
reqparse
from
werkzeug.exceptions
import
InternalServerError
from
controllers.console.setup
import
setup_required
from
controllers.inner_api
import
api
from
controllers.inner_api.wraps
import
inner_api_only
from
services.conversation_service
import
ConversationService
class
EnterpriseRenameApi
(
Resource
):
"""Model invoke API for enterprise edition"""
@
setup_required
@
inner_api_only
def
post
(
self
):
request_parser
=
reqparse
.
RequestParser
()
request_parser
.
add_argument
(
"tenant_id"
,
type
=
str
,
required
=
True
,
nullable
=
False
,
location
=
"json"
)
request_parser
.
add_argument
(
"query"
,
type
=
str
,
required
=
True
,
nullable
=
False
,
location
=
"json"
)
args
=
request_parser
.
parse_args
()
return
ConversationService
.
auto_generate_name_string
(
tenant_id
=
args
[
"tenant_id"
],
query
=
args
[
"query"
]
)
api
.
add_resource
(
EnterpriseRenameApi
,
"/service/rename"
)
api/services/conversation_service.py
View file @
d26b7363
...
...
@@ -102,6 +102,17 @@ class ConversationService:
db
.
session
.
commit
()
return
conversation
@
classmethod
def
auto_generate_name_string
(
cls
,
tenant_id
:
str
,
query
:
str
):
try
:
return
{
'name'
:
LLMGenerator
.
generate_conversation_name
(
tenant_id
,
query
)
}
except
:
return
{
'name'
:
''
}
@
classmethod
def
get_conversation
(
cls
,
app_model
:
App
,
conversation_id
:
str
,
user
:
Optional
[
Union
[
Account
,
EndUser
]]):
...
...
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