mirror of
https://github.com/langgenius/dify.git
synced 2026-02-24 01:45:13 +00:00
Compare commits
2 Commits
7b3b3dbe52
...
8141e3af99
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8141e3af99 | ||
|
|
b108de6607 |
@@ -10,7 +10,7 @@ import services
|
|||||||
from controllers.common.fields import Parameters as ParametersResponse
|
from controllers.common.fields import Parameters as ParametersResponse
|
||||||
from controllers.common.fields import Site as SiteResponse
|
from controllers.common.fields import Site as SiteResponse
|
||||||
from controllers.common.schema import get_or_create_model
|
from controllers.common.schema import get_or_create_model
|
||||||
from controllers.console import api, console_ns
|
from controllers.console import console_ns
|
||||||
from controllers.console.app.error import (
|
from controllers.console.app.error import (
|
||||||
AppUnavailableError,
|
AppUnavailableError,
|
||||||
AudioTooLargeError,
|
AudioTooLargeError,
|
||||||
@@ -469,7 +469,7 @@ class TrialSitApi(Resource):
|
|||||||
"""Resource for trial app sites."""
|
"""Resource for trial app sites."""
|
||||||
|
|
||||||
@trial_feature_enable
|
@trial_feature_enable
|
||||||
@get_app_model_with_trial
|
@get_app_model_with_trial(None)
|
||||||
def get(self, app_model):
|
def get(self, app_model):
|
||||||
"""Retrieve app site info.
|
"""Retrieve app site info.
|
||||||
|
|
||||||
@@ -491,7 +491,7 @@ class TrialAppParameterApi(Resource):
|
|||||||
"""Resource for app variables."""
|
"""Resource for app variables."""
|
||||||
|
|
||||||
@trial_feature_enable
|
@trial_feature_enable
|
||||||
@get_app_model_with_trial
|
@get_app_model_with_trial(None)
|
||||||
def get(self, app_model):
|
def get(self, app_model):
|
||||||
"""Retrieve app parameters."""
|
"""Retrieve app parameters."""
|
||||||
|
|
||||||
@@ -520,7 +520,7 @@ class TrialAppParameterApi(Resource):
|
|||||||
|
|
||||||
class AppApi(Resource):
|
class AppApi(Resource):
|
||||||
@trial_feature_enable
|
@trial_feature_enable
|
||||||
@get_app_model_with_trial
|
@get_app_model_with_trial(None)
|
||||||
@marshal_with(app_detail_with_site_model)
|
@marshal_with(app_detail_with_site_model)
|
||||||
def get(self, app_model):
|
def get(self, app_model):
|
||||||
"""Get app detail"""
|
"""Get app detail"""
|
||||||
@@ -533,7 +533,7 @@ class AppApi(Resource):
|
|||||||
|
|
||||||
class AppWorkflowApi(Resource):
|
class AppWorkflowApi(Resource):
|
||||||
@trial_feature_enable
|
@trial_feature_enable
|
||||||
@get_app_model_with_trial
|
@get_app_model_with_trial(None)
|
||||||
@marshal_with(workflow_model)
|
@marshal_with(workflow_model)
|
||||||
def get(self, app_model):
|
def get(self, app_model):
|
||||||
"""Get workflow detail"""
|
"""Get workflow detail"""
|
||||||
@@ -552,7 +552,7 @@ class AppWorkflowApi(Resource):
|
|||||||
|
|
||||||
class DatasetListApi(Resource):
|
class DatasetListApi(Resource):
|
||||||
@trial_feature_enable
|
@trial_feature_enable
|
||||||
@get_app_model_with_trial
|
@get_app_model_with_trial(None)
|
||||||
def get(self, app_model):
|
def get(self, app_model):
|
||||||
page = request.args.get("page", default=1, type=int)
|
page = request.args.get("page", default=1, type=int)
|
||||||
limit = request.args.get("limit", default=20, type=int)
|
limit = request.args.get("limit", default=20, type=int)
|
||||||
@@ -570,27 +570,31 @@ class DatasetListApi(Resource):
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
api.add_resource(TrialChatApi, "/trial-apps/<uuid:app_id>/chat-messages", endpoint="trial_app_chat_completion")
|
console_ns.add_resource(TrialChatApi, "/trial-apps/<uuid:app_id>/chat-messages", endpoint="trial_app_chat_completion")
|
||||||
|
|
||||||
api.add_resource(
|
console_ns.add_resource(
|
||||||
TrialMessageSuggestedQuestionApi,
|
TrialMessageSuggestedQuestionApi,
|
||||||
"/trial-apps/<uuid:app_id>/messages/<uuid:message_id>/suggested-questions",
|
"/trial-apps/<uuid:app_id>/messages/<uuid:message_id>/suggested-questions",
|
||||||
endpoint="trial_app_suggested_question",
|
endpoint="trial_app_suggested_question",
|
||||||
)
|
)
|
||||||
|
|
||||||
api.add_resource(TrialChatAudioApi, "/trial-apps/<uuid:app_id>/audio-to-text", endpoint="trial_app_audio")
|
console_ns.add_resource(TrialChatAudioApi, "/trial-apps/<uuid:app_id>/audio-to-text", endpoint="trial_app_audio")
|
||||||
api.add_resource(TrialChatTextApi, "/trial-apps/<uuid:app_id>/text-to-audio", endpoint="trial_app_text")
|
console_ns.add_resource(TrialChatTextApi, "/trial-apps/<uuid:app_id>/text-to-audio", endpoint="trial_app_text")
|
||||||
|
|
||||||
api.add_resource(TrialCompletionApi, "/trial-apps/<uuid:app_id>/completion-messages", endpoint="trial_app_completion")
|
console_ns.add_resource(
|
||||||
|
TrialCompletionApi, "/trial-apps/<uuid:app_id>/completion-messages", endpoint="trial_app_completion"
|
||||||
|
)
|
||||||
|
|
||||||
api.add_resource(TrialSitApi, "/trial-apps/<uuid:app_id>/site")
|
console_ns.add_resource(TrialSitApi, "/trial-apps/<uuid:app_id>/site")
|
||||||
|
|
||||||
api.add_resource(TrialAppParameterApi, "/trial-apps/<uuid:app_id>/parameters", endpoint="trial_app_parameters")
|
console_ns.add_resource(TrialAppParameterApi, "/trial-apps/<uuid:app_id>/parameters", endpoint="trial_app_parameters")
|
||||||
|
|
||||||
api.add_resource(AppApi, "/trial-apps/<uuid:app_id>", endpoint="trial_app")
|
console_ns.add_resource(AppApi, "/trial-apps/<uuid:app_id>", endpoint="trial_app")
|
||||||
|
|
||||||
api.add_resource(TrialAppWorkflowRunApi, "/trial-apps/<uuid:app_id>/workflows/run", endpoint="trial_app_workflow_run")
|
console_ns.add_resource(
|
||||||
api.add_resource(TrialAppWorkflowTaskStopApi, "/trial-apps/<uuid:app_id>/workflows/tasks/<string:task_id>/stop")
|
TrialAppWorkflowRunApi, "/trial-apps/<uuid:app_id>/workflows/run", endpoint="trial_app_workflow_run"
|
||||||
|
)
|
||||||
|
console_ns.add_resource(TrialAppWorkflowTaskStopApi, "/trial-apps/<uuid:app_id>/workflows/tasks/<string:task_id>/stop")
|
||||||
|
|
||||||
api.add_resource(AppWorkflowApi, "/trial-apps/<uuid:app_id>/workflows", endpoint="trial_app_workflow")
|
console_ns.add_resource(AppWorkflowApi, "/trial-apps/<uuid:app_id>/workflows", endpoint="trial_app_workflow")
|
||||||
api.add_resource(DatasetListApi, "/trial-apps/<uuid:app_id>/datasets", endpoint="trial_app_datasets")
|
console_ns.add_resource(DatasetListApi, "/trial-apps/<uuid:app_id>/datasets", endpoint="trial_app_datasets")
|
||||||
|
|||||||
@@ -105,9 +105,9 @@ def trial_app_required(view: Callable[Concatenate[App, P], R] | None = None):
|
|||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def trial_feature_enable(view: Callable[..., R]) -> Callable[..., R]:
|
def trial_feature_enable(view: Callable[P, R]):
|
||||||
@wraps(view)
|
@wraps(view)
|
||||||
def decorated(*args, **kwargs):
|
def decorated(*args: P.args, **kwargs: P.kwargs):
|
||||||
features = FeatureService.get_system_features()
|
features = FeatureService.get_system_features()
|
||||||
if not features.enable_trial_app:
|
if not features.enable_trial_app:
|
||||||
abort(403, "Trial app feature is not enabled.")
|
abort(403, "Trial app feature is not enabled.")
|
||||||
@@ -116,9 +116,9 @@ def trial_feature_enable(view: Callable[..., R]) -> Callable[..., R]:
|
|||||||
return decorated
|
return decorated
|
||||||
|
|
||||||
|
|
||||||
def explore_banner_enabled(view: Callable[..., R]) -> Callable[..., R]:
|
def explore_banner_enabled(view: Callable[P, R]):
|
||||||
@wraps(view)
|
@wraps(view)
|
||||||
def decorated(*args, **kwargs):
|
def decorated(*args: P.args, **kwargs: P.kwargs):
|
||||||
features = FeatureService.get_system_features()
|
features = FeatureService.get_system_features()
|
||||||
if not features.enable_explore_banner:
|
if not features.enable_explore_banner:
|
||||||
abort(403, "Explore banner feature is not enabled.")
|
abort(403, "Explore banner feature is not enabled.")
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type {
|
import type {
|
||||||
|
CommonNodeType,
|
||||||
Node,
|
Node,
|
||||||
OnSelectBlock,
|
OnSelectBlock,
|
||||||
} from '@/app/components/workflow/types'
|
} from '@/app/components/workflow/types'
|
||||||
@@ -16,6 +17,7 @@ import {
|
|||||||
useNodesInteractions,
|
useNodesInteractions,
|
||||||
} from '@/app/components/workflow/hooks'
|
} from '@/app/components/workflow/hooks'
|
||||||
import { useHooksStore } from '@/app/components/workflow/hooks-store'
|
import { useHooksStore } from '@/app/components/workflow/hooks-store'
|
||||||
|
import useNodes from '@/app/components/workflow/store/workflow/use-nodes'
|
||||||
import { BlockEnum, isTriggerNode } from '@/app/components/workflow/types'
|
import { BlockEnum, isTriggerNode } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
import { FlowType } from '@/types/common'
|
import { FlowType } from '@/types/common'
|
||||||
@@ -38,12 +40,17 @@ const ChangeBlock = ({
|
|||||||
} = useAvailableBlocks(nodeData.type, nodeData.isInIteration || nodeData.isInLoop)
|
} = useAvailableBlocks(nodeData.type, nodeData.isInIteration || nodeData.isInLoop)
|
||||||
const isChatMode = useIsChatMode()
|
const isChatMode = useIsChatMode()
|
||||||
const flowType = useHooksStore(s => s.configsMap?.flowType)
|
const flowType = useHooksStore(s => s.configsMap?.flowType)
|
||||||
const showStartTab = flowType !== FlowType.ragPipeline && !isChatMode
|
const nodes = useNodes()
|
||||||
|
const hasStartNode = useMemo(() => {
|
||||||
|
return nodes.some(n => (n.data as CommonNodeType | undefined)?.type === BlockEnum.Start)
|
||||||
|
}, [nodes])
|
||||||
|
const showStartTab = flowType !== FlowType.ragPipeline && (!isChatMode || nodeData.type === BlockEnum.Start || !hasStartNode)
|
||||||
const ignoreNodeIds = useMemo(() => {
|
const ignoreNodeIds = useMemo(() => {
|
||||||
if (isTriggerNode(nodeData.type as BlockEnum))
|
if (isTriggerNode(nodeData.type as BlockEnum) || nodeData.type === BlockEnum.Start)
|
||||||
return [nodeId]
|
return [nodeId]
|
||||||
return undefined
|
return undefined
|
||||||
}, [nodeData.type, nodeId])
|
}, [nodeData.type, nodeId])
|
||||||
|
const allowStartNodeSelection = !hasStartNode
|
||||||
|
|
||||||
const availableNodes = useMemo(() => {
|
const availableNodes = useMemo(() => {
|
||||||
if (availablePrevBlocks.length && availableNextBlocks.length)
|
if (availablePrevBlocks.length && availableNextBlocks.length)
|
||||||
@@ -80,6 +87,7 @@ const ChangeBlock = ({
|
|||||||
showStartTab={showStartTab}
|
showStartTab={showStartTab}
|
||||||
ignoreNodeIds={ignoreNodeIds}
|
ignoreNodeIds={ignoreNodeIds}
|
||||||
forceEnableStartTab={nodeData.type === BlockEnum.Start}
|
forceEnableStartTab={nodeData.type === BlockEnum.Start}
|
||||||
|
allowUserInputSelection={allowStartNodeSelection}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user