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
23e02d8e
Unverified
Commit
23e02d8e
authored
Jan 23, 2024
by
takatost
Committed by
GitHub
Jan 23, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: remove universal chat app (#2140)
parent
86286e1a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1 addition
and
123 deletions
+1
-123
commands.py
api/commands.py
+0
-61
app.py
api/controllers/console/app/app.py
+1
-0
audio.py
api/controllers/console/universal_chat/audio.py
+0
-62
chat.py
api/controllers/console/universal_chat/chat.py
+0
-0
No files found.
api/commands.py
View file @
23e02d8e
...
@@ -775,66 +775,6 @@ def add_annotation_question_field_value():
...
@@ -775,66 +775,6 @@ def add_annotation_question_field_value():
click
.
echo
(
click
.
echo
(
click
.
style
(
f
'Congratulations! add annotation question value successful. Deal count {message_annotation_deal_count}'
,
fg
=
'green'
))
click
.
style
(
f
'Congratulations! add annotation question value successful. Deal count {message_annotation_deal_count}'
,
fg
=
'green'
))
@
click
.
command
(
'migrate-universal-chat-to-installed-app'
,
help
=
'Migrate universal chat to installed app.'
)
@
click
.
option
(
"--batch-size"
,
default
=
500
,
help
=
"Number of records to migrate in each batch."
)
def
migrate_universal_chat_to_installed_app
(
batch_size
):
total_records
=
db
.
session
.
query
(
App
)
.
filter
(
App
.
is_universal
==
True
)
.
count
()
if
total_records
==
0
:
click
.
secho
(
"No data to migrate."
,
fg
=
'green'
)
return
num_batches
=
(
total_records
+
batch_size
-
1
)
//
batch_size
with
tqdm
(
total
=
total_records
,
desc
=
"Migrating Data"
)
as
pbar
:
for
i
in
range
(
num_batches
):
offset
=
i
*
batch_size
limit
=
min
(
batch_size
,
total_records
-
offset
)
click
.
secho
(
f
"Fetching batch {i + 1}/{num_batches} from source database..."
,
fg
=
'green'
)
data_batch
:
list
[
App
]
=
db
.
session
.
query
(
App
)
\
.
filter
(
App
.
is_universal
==
True
)
\
.
order_by
(
App
.
created_at
)
\
.
offset
(
offset
)
.
limit
(
limit
)
.
all
()
if
not
data_batch
:
click
.
secho
(
"No more data to migrate."
,
fg
=
'green'
)
break
try
:
click
.
secho
(
f
"Migrating {len(data_batch)} records..."
,
fg
=
'green'
)
for
data
in
data_batch
:
# check if the app is already installed
installed_app
=
db
.
session
.
query
(
InstalledApp
)
.
filter
(
InstalledApp
.
app_id
==
data
.
id
)
.
first
()
if
installed_app
:
continue
# insert installed app
installed_app
=
InstalledApp
(
app_id
=
data
.
id
,
tenant_id
=
data
.
tenant_id
,
position
=
0
,
app_owner_tenant_id
=
data
.
tenant_id
,
is_pinned
=
True
,
last_used_at
=
datetime
.
datetime
.
utcnow
(),
)
db
.
session
.
add
(
installed_app
)
db
.
session
.
commit
()
except
Exception
as
e
:
click
.
secho
(
f
"Error while migrating data: {e}, app_id: {data.id}"
,
fg
=
'red'
)
continue
click
.
secho
(
f
"Successfully migrated batch {i + 1}/{num_batches}."
,
fg
=
'green'
)
pbar
.
update
(
len
(
data_batch
))
def
register_commands
(
app
):
def
register_commands
(
app
):
app
.
cli
.
add_command
(
reset_password
)
app
.
cli
.
add_command
(
reset_password
)
...
@@ -851,4 +791,3 @@ def register_commands(app):
...
@@ -851,4 +791,3 @@ def register_commands(app):
app
.
cli
.
add_command
(
migrate_default_input_to_dataset_query_variable
)
app
.
cli
.
add_command
(
migrate_default_input_to_dataset_query_variable
)
app
.
cli
.
add_command
(
add_qdrant_full_text_index
)
app
.
cli
.
add_command
(
add_qdrant_full_text_index
)
app
.
cli
.
add_command
(
add_annotation_question_field_value
)
app
.
cli
.
add_command
(
add_annotation_question_field_value
)
app
.
cli
.
add_command
(
migrate_universal_chat_to_installed_app
)
api/controllers/console/app/app.py
View file @
23e02d8e
...
@@ -49,6 +49,7 @@ class AppListApi(Resource):
...
@@ -49,6 +49,7 @@ class AppListApi(Resource):
filters
=
[
filters
=
[
App
.
tenant_id
==
current_user
.
current_tenant_id
,
App
.
tenant_id
==
current_user
.
current_tenant_id
,
App
.
is_universal
==
False
]
]
if
args
[
'mode'
]
==
'completion'
:
if
args
[
'mode'
]
==
'completion'
:
...
...
api/controllers/console/universal_chat/audio.py
deleted
100644 → 0
View file @
86286e1a
# -*- coding:utf-8 -*-
import
logging
import
services
from
controllers.console
import
api
from
controllers.console.app.error
import
(
AppUnavailableError
,
AudioTooLargeError
,
CompletionRequestError
,
NoAudioUploadedError
,
ProviderModelCurrentlyNotSupportError
,
ProviderNotInitializeError
,
ProviderNotSupportSpeechToTextError
,
ProviderQuotaExceededError
,
UnsupportedAudioTypeError
)
from
controllers.console.universal_chat.wraps
import
UniversalChatResource
from
core.errors.error
import
ModelCurrentlyNotSupportError
,
ProviderTokenNotInitError
,
QuotaExceededError
from
core.model_runtime.errors.invoke
import
InvokeError
from
flask
import
request
from
models.model
import
AppModelConfig
from
services.audio_service
import
AudioService
from
services.errors.audio
import
(
AudioTooLargeServiceError
,
NoAudioUploadedServiceError
,
ProviderNotSupportSpeechToTextServiceError
,
UnsupportedAudioTypeServiceError
)
from
werkzeug.exceptions
import
InternalServerError
class
UniversalChatAudioApi
(
UniversalChatResource
):
def
post
(
self
,
universal_app
):
app_model
=
universal_app
app_model_config
:
AppModelConfig
=
app_model
.
app_model_config
if
not
app_model_config
.
speech_to_text_dict
[
'enabled'
]:
raise
AppUnavailableError
()
file
=
request
.
files
[
'file'
]
try
:
response
=
AudioService
.
transcript
(
tenant_id
=
app_model
.
tenant_id
,
file
=
file
,
)
return
response
except
services
.
errors
.
app_model_config
.
AppModelConfigBrokenError
:
logging
.
exception
(
"App model config broken."
)
raise
AppUnavailableError
()
except
NoAudioUploadedServiceError
:
raise
NoAudioUploadedError
()
except
AudioTooLargeServiceError
as
e
:
raise
AudioTooLargeError
(
str
(
e
))
except
UnsupportedAudioTypeServiceError
:
raise
UnsupportedAudioTypeError
()
except
ProviderNotSupportSpeechToTextServiceError
:
raise
ProviderNotSupportSpeechToTextError
()
except
ProviderTokenNotInitError
:
raise
ProviderNotInitializeError
()
except
QuotaExceededError
:
raise
ProviderQuotaExceededError
()
except
ModelCurrentlyNotSupportError
:
raise
ProviderModelCurrentlyNotSupportError
()
except
InvokeError
as
e
:
raise
CompletionRequestError
(
e
.
description
)
except
ValueError
as
e
:
raise
e
except
Exception
as
e
:
logging
.
exception
(
"internal server error."
)
raise
InternalServerError
()
api/controllers/console/universal_chat/chat.py
deleted
100644 → 0
View file @
86286e1a
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