Kaynağa Gözat

机器人权限

CzRger 2 ay önce
ebeveyn
işleme
e6da378e85

+ 57 - 52
web/app/components/app/configuration/index.tsx

@@ -77,6 +77,7 @@ import {
   correctToolProvider,
 } from '@/utils'
 import PluginDependency from '@/app/components/workflow/plugin-dependency'
+import { useAppDetailContext } from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main'
 
 type PublishConfig = {
   modelConfig: ModelConfig
@@ -824,7 +825,7 @@ const Configuration: FC = () => {
     )
     setAppSiderbarExpand('collapse')
   }
-
+  const { detail, isCreate, isEdit, isOperation } = useAppDetailContext()
   if (isLoading) {
     return <div className='flex h-full items-center justify-center'>
       <Loading type='area' />
@@ -922,57 +923,61 @@ const Configuration: FC = () => {
                       )}
                     </div>
                   </div>
-                  <div className='flex items-center'>
-                    {/* Agent Setting */}
-                    {isAgent && (
-                      <AgentSettingButton
-                        isChatModel={modelConfig.mode === ModelModeType.chat}
-                        agentConfig={modelConfig.agentConfig}
-
-                        isFunctionCall={isFunctionCall}
-                        onAgentSettingChange={(config) => {
-                          const nextConfig = produce(modelConfig, (draft: ModelConfig) => {
-                            draft.agentConfig = config
-                          })
-                          setModelConfig(nextConfig)
-                        }}
-                      />
-                    )}
-                    {/* Model and Parameters */}
-                    {!debugWithMultipleModel && (
-                      <>
-                        <ModelParameterModal
-                          isAdvancedMode={isAdvancedMode}
-                          mode={mode}
-                          provider={modelConfig.provider}
-                          completionParams={completionParams}
-                          modelId={modelConfig.model_id}
-                          setModel={setModel as any}
-                          onCompletionParamsChange={(newParams: FormValue) => {
-                            setCompletionParams(newParams)
-                          }}
-                          debugWithMultipleModel={debugWithMultipleModel}
-                          onDebugWithMultipleModelChange={handleDebugWithMultipleModelChange}
-                        />
-                        <Divider type='vertical' className='mx-2 h-[14px]' />
-                      </>
-                    )}
-                    {isMobile && (
-                      <Button className='mr-2 !h-8 !text-[13px] font-medium' onClick={showDebugPanel}>
-                        <span className='mr-1'>{t('appDebug.operation.debugConfig')}</span>
-                        <CodeBracketIcon className="h-4 w-4 text-text-tertiary" />
-                      </Button>
-                    )}
-                    <AppPublisher {...{
-                      publishDisabled: cannotPublish,
-                      publishedAt: (latestPublishedAt || 0) * 1000,
-                      debugWithMultipleModel,
-                      multipleModelConfigs,
-                      onPublish,
-                      publishedConfig: publishedConfig!,
-                      resetAppConfig: () => syncToPublishedConfig(publishedConfig!),
-                    }} />
-                  </div>
+                  {
+                    isEdit && (
+                      <div className='flex items-center'>
+                        {/* Agent Setting */}
+                        {isAgent && (
+                          <AgentSettingButton
+                            isChatModel={modelConfig.mode === ModelModeType.chat}
+                            agentConfig={modelConfig.agentConfig}
+
+                            isFunctionCall={isFunctionCall}
+                            onAgentSettingChange={(config) => {
+                              const nextConfig = produce(modelConfig, (draft: ModelConfig) => {
+                                draft.agentConfig = config
+                              })
+                              setModelConfig(nextConfig)
+                            }}
+                          />
+                        )}
+                        {/* Model and Parameters */}
+                        {!debugWithMultipleModel && (
+                          <>
+                            <ModelParameterModal
+                              isAdvancedMode={isAdvancedMode}
+                              mode={mode}
+                              provider={modelConfig.provider}
+                              completionParams={completionParams}
+                              modelId={modelConfig.model_id}
+                              setModel={setModel as any}
+                              onCompletionParamsChange={(newParams: FormValue) => {
+                                setCompletionParams(newParams)
+                              }}
+                              debugWithMultipleModel={debugWithMultipleModel}
+                              onDebugWithMultipleModelChange={handleDebugWithMultipleModelChange}
+                            />
+                            <Divider type='vertical' className='mx-2 h-[14px]' />
+                          </>
+                        )}
+                        {isMobile && (
+                          <Button className='mr-2 !h-8 !text-[13px] font-medium' onClick={showDebugPanel}>
+                            <span className='mr-1'>{t('appDebug.operation.debugConfig')}</span>
+                            <CodeBracketIcon className="h-4 w-4 text-text-tertiary" />
+                          </Button>
+                        )}
+                        <AppPublisher {...{
+                          publishDisabled: cannotPublish,
+                          publishedAt: (latestPublishedAt || 0) * 1000,
+                          debugWithMultipleModel,
+                          multipleModelConfigs,
+                          onPublish,
+                          publishedConfig: publishedConfig!,
+                          resetAppConfig: () => syncToPublishedConfig(publishedConfig!),
+                        }} />
+                      </div>
+                    )
+                  }
                 </div>
               </div>
               <div className={`flex h-full w-full shrink-0 flex-col sm:w-1/2 ${debugWithMultipleModel && 'max-w-[560px]'}`}>

+ 0 - 2
web/app/components/workflow/hooks/use-workflow.ts

@@ -60,7 +60,6 @@ import { CUSTOM_ITERATION_START_NODE } from '@/app/components/workflow/nodes/ite
 import { CUSTOM_LOOP_START_NODE } from '@/app/components/workflow/nodes/loop-start/constants'
 import { useWorkflowConfig } from '@/service/use-workflow'
 import { canFindTool } from '@/utils'
-import { useAppDetailContext } from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/layout-main'
 
 export const useIsChatMode = () => {
   const appDetail = useAppStore(s => s.appDetail)
@@ -473,7 +472,6 @@ export const useFetchToolsData = () => {
 }
 
 export const useWorkflowInit = () => {
-  const { detail, isCreate, isEdit, isOperation } = useAppDetailContext()
   const workflowStore = useWorkflowStore()
   const {
     nodes: nodesTemplate,