mirror of
https://github.com/langgenius/dify.git
synced 2026-01-19 11:45:05 +08:00
refactor(app): add InvokeFrom.to_creator_user_role and use it in dataset retrieval
Tests: not run (not requested).
This commit is contained in:
@ -9,6 +9,7 @@ from core.app.app_config.entities import EasyUIBasedAppConfig, WorkflowUIBasedAp
|
||||
from core.entities.provider_configuration import ProviderModelBundle
|
||||
from core.file import File, FileUploadConfig
|
||||
from core.model_runtime.entities.model_entities import AIModelEntity
|
||||
from models.enums import CreatorUserRole
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from core.ops.ops_trace_manager import TraceQueueManager
|
||||
@ -79,6 +80,11 @@ class InvokeFrom(StrEnum):
|
||||
|
||||
return "dev"
|
||||
|
||||
def to_creator_user_role(self) -> CreatorUserRole:
|
||||
if self in {InvokeFrom.EXPLORE, InvokeFrom.DEBUGGER}:
|
||||
return CreatorUserRole.ACCOUNT
|
||||
return CreatorUserRole.END_USER
|
||||
|
||||
|
||||
class ModelConfigWithCredentialsEntity(BaseModel):
|
||||
"""
|
||||
|
||||
@ -177,11 +177,7 @@ class DatasetRetrieval:
|
||||
)
|
||||
|
||||
all_documents = []
|
||||
creator_user_role = (
|
||||
CreatorUserRole.ACCOUNT
|
||||
if invoke_from in {InvokeFrom.EXPLORE, InvokeFrom.DEBUGGER}
|
||||
else CreatorUserRole.END_USER
|
||||
)
|
||||
creator_user_role = invoke_from.to_creator_user_role()
|
||||
if retrieve_config.retrieve_strategy == DatasetRetrieveConfigEntity.RetrieveStrategy.SINGLE:
|
||||
all_documents = self.single_retrieve(
|
||||
app_id,
|
||||
|
||||
Reference in New Issue
Block a user