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
cfffa76c
Commit
cfffa76c
authored
Feb 27, 2024
by
Garfield Dai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update billing for datasets creation.
parent
9730b243
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
1 deletion
+19
-1
file.py
api/controllers/console/datasets/file.py
+2
-1
wraps.py
api/controllers/console/wraps.py
+8
-0
document.py
api/controllers/service_api/dataset/document.py
+2
-0
wraps.py
api/controllers/service_api/wraps.py
+3
-0
feature_service.py
api/services/feature_service.py
+4
-0
No files found.
api/controllers/console/datasets/file.py
View file @
cfffa76c
...
...
@@ -11,7 +11,7 @@ from controllers.console.datasets.error import (
UnsupportedFileTypeError
,
)
from
controllers.console.setup
import
setup_required
from
controllers.console.wraps
import
account_initialization_required
from
controllers.console.wraps
import
account_initialization_required
,
cloud_edition_billing_resource_check
from
fields.file_fields
import
file_fields
,
upload_config_fields
from
libs.login
import
login_required
from
services.file_service
import
ALLOWED_EXTENSIONS
,
UNSTRUSTURED_ALLOWED_EXTENSIONS
,
FileService
...
...
@@ -39,6 +39,7 @@ class FileApi(Resource):
@
login_required
@
account_initialization_required
@
marshal_with
(
file_fields
)
@
cloud_edition_billing_resource_check
(
resource
=
'documents'
)
def
post
(
self
):
# get file from request
...
...
api/controllers/console/wraps.py
View file @
cfffa76c
...
...
@@ -56,6 +56,7 @@ def cloud_edition_billing_resource_check(resource: str,
members
=
features
.
members
apps
=
features
.
apps
vector_space
=
features
.
vector_space
documents_upload_quota
=
features
.
documents_upload_quota
annotation_quota_limit
=
features
.
annotation_quota_limit
if
resource
==
'members'
and
0
<
members
.
limit
<=
members
.
size
:
...
...
@@ -64,6 +65,13 @@ def cloud_edition_billing_resource_check(resource: str,
abort
(
403
,
error_msg
)
elif
resource
==
'vector_space'
and
0
<
vector_space
.
limit
<=
vector_space
.
size
:
abort
(
403
,
error_msg
)
elif
resource
==
'documents'
and
0
<
documents_upload_quota
.
limit
<=
documents_upload_quota
.
size
:
# The api of file upload is used in the multiple places, so we need to check the source of the request from datasets
source
=
request
.
args
.
get
(
'source'
)
if
source
==
'datasets'
:
abort
(
403
,
error_msg
)
else
:
return
view
(
*
args
,
**
kwargs
)
elif
resource
==
'workspace_custom'
and
not
features
.
can_replace_logo
:
abort
(
403
,
error_msg
)
elif
resource
==
'annotation'
and
0
<
annotation_quota_limit
.
limit
<
annotation_quota_limit
.
size
:
...
...
api/controllers/service_api/dataset/document.py
View file @
cfffa76c
...
...
@@ -28,6 +28,7 @@ class DocumentAddByTextApi(DatasetApiResource):
"""Resource for documents."""
@
cloud_edition_billing_resource_check
(
'vector_space'
,
'dataset'
)
@
cloud_edition_billing_resource_check
(
'documents'
,
'dataset'
)
def
post
(
self
,
tenant_id
,
dataset_id
):
"""Create document by text."""
parser
=
reqparse
.
RequestParser
()
...
...
@@ -153,6 +154,7 @@ class DocumentUpdateByTextApi(DatasetApiResource):
class
DocumentAddByFileApi
(
DatasetApiResource
):
"""Resource for documents."""
@
cloud_edition_billing_resource_check
(
'vector_space'
,
'dataset'
)
@
cloud_edition_billing_resource_check
(
'documents'
,
'dataset'
)
def
post
(
self
,
tenant_id
,
dataset_id
):
"""Create document by upload file."""
args
=
{}
...
...
api/controllers/service_api/wraps.py
View file @
cfffa76c
...
...
@@ -52,6 +52,7 @@ def cloud_edition_billing_resource_check(resource: str,
members
=
features
.
members
apps
=
features
.
apps
vector_space
=
features
.
vector_space
documents_upload_quota
=
features
.
documents_upload_quota
if
resource
==
'members'
and
0
<
members
.
limit
<=
members
.
size
:
raise
Unauthorized
(
error_msg
)
...
...
@@ -59,6 +60,8 @@ def cloud_edition_billing_resource_check(resource: str,
raise
Unauthorized
(
error_msg
)
elif
resource
==
'vector_space'
and
0
<
vector_space
.
limit
<=
vector_space
.
size
:
raise
Unauthorized
(
error_msg
)
elif
resource
==
'documents'
and
0
<
documents_upload_quota
.
limit
<=
documents_upload_quota
.
size
:
raise
Unauthorized
(
error_msg
)
else
:
return
view
(
*
args
,
**
kwargs
)
...
...
api/services/feature_service.py
View file @
cfffa76c
...
...
@@ -25,6 +25,7 @@ class FeatureModel(BaseModel):
apps
:
LimitationModel
=
LimitationModel
(
size
=
0
,
limit
=
10
)
vector_space
:
LimitationModel
=
LimitationModel
(
size
=
0
,
limit
=
5
)
annotation_quota_limit
:
LimitationModel
=
LimitationModel
(
size
=
0
,
limit
=
10
)
documents_upload_quota
:
LimitationModel
=
LimitationModel
(
size
=
0
,
limit
=
20
)
docs_processing
:
str
=
'standard'
can_replace_logo
:
bool
=
False
...
...
@@ -63,6 +64,9 @@ class FeatureService:
features
.
vector_space
.
size
=
billing_info
[
'vector_space'
][
'size'
]
features
.
vector_space
.
limit
=
billing_info
[
'vector_space'
][
'limit'
]
features
.
documents_upload_quota
.
size
=
billing_info
[
'documents_upload_quota'
][
'size'
]
features
.
documents_upload_quota
.
limit
=
billing_info
[
'documents_upload_quota'
][
'limit'
]
features
.
annotation_quota_limit
.
size
=
billing_info
[
'annotation_quota_limit'
][
'size'
]
features
.
annotation_quota_limit
.
limit
=
billing_info
[
'annotation_quota_limit'
][
'limit'
]
...
...
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