mirror of https://github.com/langgenius/dify.git
feat: add knowledge pipeline creation feature
This commit is contained in:
parent
8e88765261
commit
c685663242
|
|
@ -9,6 +9,7 @@ from controllers.console.wraps import (
|
|||
account_initialization_required,
|
||||
enterprise_license_required,
|
||||
setup_required,
|
||||
knowledge_pipeline_publish_enabled,
|
||||
)
|
||||
from extensions.ext_database import db
|
||||
from libs.login import login_required
|
||||
|
|
@ -116,6 +117,7 @@ class PublishCustomizedPipelineTemplateApi(Resource):
|
|||
@login_required
|
||||
@account_initialization_required
|
||||
@enterprise_license_required
|
||||
@knowledge_pipeline_publish_enabled
|
||||
def post(self, pipeline_id: str):
|
||||
parser = reqparse.RequestParser()
|
||||
parser.add_argument(
|
||||
|
|
|
|||
|
|
@ -261,3 +261,13 @@ def is_allow_transfer_owner(view):
|
|||
abort(403)
|
||||
|
||||
return decorated
|
||||
|
||||
|
||||
def knowledge_pipeline_publish_enabled(view):
|
||||
@wraps(view)
|
||||
def decorated(*args, **kwargs):
|
||||
features = FeatureService.get_features(current_user.current_tenant_id)
|
||||
if features.knowledge_pipeline.publish_enabled:
|
||||
return view(*args, **kwargs)
|
||||
abort(403)
|
||||
return decorated
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@ class WebAppAuthModel(BaseModel):
|
|||
allow_email_code_login: bool = False
|
||||
allow_email_password_login: bool = False
|
||||
|
||||
class KnowledgePipeline(BaseModel):
|
||||
publish_enabled: bool = False
|
||||
|
||||
class PluginInstallationScope(StrEnum):
|
||||
NONE = "none"
|
||||
|
|
@ -126,6 +128,7 @@ class FeatureModel(BaseModel):
|
|||
is_allow_transfer_workspace: bool = True
|
||||
# pydantic configs
|
||||
model_config = ConfigDict(protected_namespaces=())
|
||||
knowledge_pipeline: KnowledgePipeline = KnowledgePipeline()
|
||||
|
||||
|
||||
class KnowledgeRateLimitModel(BaseModel):
|
||||
|
|
@ -265,6 +268,9 @@ class FeatureService:
|
|||
if "knowledge_rate_limit" in billing_info:
|
||||
features.knowledge_rate_limit = billing_info["knowledge_rate_limit"]["limit"]
|
||||
|
||||
if "knowledge_pipeline_publish_enabled" in billing_info:
|
||||
features.knowledge_pipeline.publish_enabled = billing_info["knowledge_pipeline_publish_enabled"]
|
||||
|
||||
@classmethod
|
||||
def _fulfill_params_from_enterprise(cls, features: SystemFeatureModel):
|
||||
enterprise_info = EnterpriseService.get_info()
|
||||
|
|
|
|||
Loading…
Reference in New Issue