Pārlūkot izejas kodu

Merge branch '1.1.3-master' into 1.1.3-zyx

zhouyuexiang 2 mēneši atpakaļ
vecāks
revīzija
65a36e6bf5

+ 2 - 3
api/controllers/console/app/app.py

@@ -349,7 +349,7 @@ class AppPermissionApi(Resource):
     @account_initialization_required
     @account_initialization_required
     def get(self, app_model):
     def get(self, app_model):
         app_service = AppService()
         app_service = AppService()
-        app_model = app_service.get_app(app_model)
+        app_model = app_service.get_app_by_id(app_model)
         if not app_model:
         if not app_model:
             raise NotFound("App not found.")
             raise NotFound("App not found.")
         read_permission_list = AppService.get_app_read_permission(app_model.id)
         read_permission_list = AppService.get_app_read_permission(app_model.id)
@@ -366,7 +366,7 @@ class AppPermissionApi(Resource):
     def post(self, app_model):
     def post(self, app_model):
         # add app permission
         # add app permission
         app_service = AppService()
         app_service = AppService()
-        app_model = app_service.get_app(app_model)
+        app_model = app_service.get_app_by_id(app_model)
 
 
         # 解析表单数据
         # 解析表单数据
         data = request.get_json()
         data = request.get_json()
@@ -374,7 +374,6 @@ class AppPermissionApi(Resource):
             raise NotFound("Invalid JSON")
             raise NotFound("Invalid JSON")
 
 
         edit_auth = data.get("edit_auth")
         edit_auth = data.get("edit_auth")
-        print("edit_auth" + str(edit_auth))
         if edit_auth is None:
         if edit_auth is None:
             return jsonify({"error": "Missing 'edit_auth' field"}), 400
             return jsonify({"error": "Missing 'edit_auth' field"}), 400
 
 

+ 4 - 4
api/services/app_service.py

@@ -201,6 +201,7 @@ class AppService:
         app.api_rph = args.get("api_rph", 0)
         app.api_rph = args.get("api_rph", 0)
         app.api_rpm = args.get("api_rpm", 0)
         app.api_rpm = args.get("api_rpm", 0)
         app.created_by = account.id
         app.created_by = account.id
+        app.dept_id =account.dept_id
         app.updated_by = account.id
         app.updated_by = account.id
 
 
         db.session.add(app)
         db.session.add(app)
@@ -223,8 +224,10 @@ class AppService:
         return app
         return app
 
 
     def get_app_by_id(self, app: App) -> App:
     def get_app_by_id(self, app: App) -> App:
+
         return app
         return app
 
 
+
     def get_app(self, app: App) -> App:
     def get_app(self, app: App) -> App:
         """
         """
         Get App
         Get App
@@ -252,7 +255,6 @@ class AppService:
                         provider_type=agent_tool_entity.provider_type,
                         provider_type=agent_tool_entity.provider_type,
                         identity_id=f"AGENT.{app.id}",
                         identity_id=f"AGENT.{app.id}",
                     )
                     )
-
                     # get decrypted parameters
                     # get decrypted parameters
                     if agent_tool_entity.tool_parameters:
                     if agent_tool_entity.tool_parameters:
                         parameters = manager.decrypt_tool_parameters(agent_tool_entity.tool_parameters or {})
                         parameters = manager.decrypt_tool_parameters(agent_tool_entity.tool_parameters or {})
@@ -267,12 +269,10 @@ class AppService:
 
 
             # override agent mode
             # override agent mode
             model_config.agent_mode = json.dumps(agent_mode)
             model_config.agent_mode = json.dumps(agent_mode)
-
             class ModifiedApp(App):
             class ModifiedApp(App):
                 """
                 """
                 Modified App class
                 Modified App class
                 """
                 """
-
                 def __init__(self, app):
                 def __init__(self, app):
                     self.__dict__.update(app.__dict__)
                     self.__dict__.update(app.__dict__)
 
 
@@ -281,7 +281,6 @@ class AppService:
                     return model_config
                     return model_config
 
 
             app = ModifiedApp(app)
             app = ModifiedApp(app)
-
         return app
         return app
 
 
     def update_app(self, app: App, args: dict) -> App:
     def update_app(self, app: App, args: dict) -> App:
@@ -454,6 +453,7 @@ class AppService:
         app.edit_auth = edit_auth
         app.edit_auth = edit_auth
         app.updated_by = current_user.id
         app.updated_by = current_user.id
         app.updated_at = datetime.now(UTC).replace(tzinfo=None)
         app.updated_at = datetime.now(UTC).replace(tzinfo=None)
+
         db.session.commit()
         db.session.commit()
 
 
         return app
         return app

+ 24 - 3
web/app/(commonLayout)/apps/Apps.tsx

@@ -41,6 +41,7 @@ const getKey = (
   keywords: string,
   keywords: string,
   dept: string,
   dept: string,
   authType: number,
   authType: number,
+  creator: string,
 ) => {
 ) => {
   if (!pageIndex || previousPageData.has_more) {
   if (!pageIndex || previousPageData.has_more) {
     const params: any = { url: 'apps', params: { page: pageIndex + 1, limit: 30, name: keywords, is_created_by_me: isCreatedByMe } }
     const params: any = { url: 'apps', params: { page: pageIndex + 1, limit: 30, name: keywords, is_created_by_me: isCreatedByMe } }
@@ -53,9 +54,11 @@ const getKey = (
     if (tags.length)
     if (tags.length)
       params.params.tag_ids = tags
       params.params.tag_ids = tags
     if (dept)
     if (dept)
-      params.params.creatorDept = dept
+      params.params.creator_dept = dept
     if (authType)
     if (authType)
-      params.params.authType = authType
+      params.params.auth_type = authType
+    if (creator)
+      params.params.creator = creator
     return params
     return params
   }
   }
   return null
   return null
@@ -95,8 +98,17 @@ const Apps = () => {
     { name: '授权编辑', value: '3' },
     { name: '授权编辑', value: '3' },
     { name: '授权可见', value: '4' },
     { name: '授权可见', value: '4' },
   ]
   ]
+  const [creator, setCreator] = useState('')
+  const [searchCreator, setSearchCreator] = useState('')
+  const { run: handleSearchCreator } = useDebounceFn(() => {
+    setSearchCreator(creator)
+  }, { wait: 500 })
+  const handleCreatorChange = (value: string) => {
+    setCreator(value)
+    handleSearchCreator()
+  }
   const { data, isLoading, setSize, mutate } = useSWRInfinite(
   const { data, isLoading, setSize, mutate } = useSWRInfinite(
-    (pageIndex: number, previousPageData: AppListResponse) => getKey(pageIndex, previousPageData, activeTab, isCreatedByMe, tagIDs, searchKeywords, dept, authType),
+    (pageIndex: number, previousPageData: AppListResponse) => getKey(pageIndex, previousPageData, activeTab, isCreatedByMe, tagIDs, searchKeywords, dept, authType, searchCreator),
     fetchAppList,
     fetchAppList,
     { revalidateFirstPage: true },
     { revalidateFirstPage: true },
   )
   )
@@ -168,6 +180,15 @@ const Apps = () => {
           options={options}
           options={options}
         />
         />
         <div className='flex items-center gap-2'>
         <div className='flex items-center gap-2'>
+          <Input
+            showLeftIcon
+            showClearIcon
+            wrapperClassName='w-[200px]'
+            value={creator}
+            onChange={e => handleCreatorChange(e.target.value)}
+            onClear={() => handleCreatorChange('')}
+            placeholder="请输入创建人"
+          />
           <SimpleSelect
           <SimpleSelect
             wrapperClassName="h-[32px] w-[200px]"
             wrapperClassName="h-[32px] w-[200px]"
             defaultValue={authType}
             defaultValue={authType}

+ 1 - 0
web/app/(commonLayout)/apps/hooks/useAppsQueryState.ts

@@ -4,6 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
 type AppsQuery = {
 type AppsQuery = {
   tagIDs?: string[]
   tagIDs?: string[]
   keywords?: string
   keywords?: string
+  creator?: string
   isCreatedByMe?: boolean
   isCreatedByMe?: boolean
 }
 }
 
 

+ 21 - 1
web/app/(commonLayout)/datasets/Container.tsx

@@ -68,6 +68,17 @@ const Container = () => {
     setKeywords(value)
     setKeywords(value)
     handleSearch()
     handleSearch()
   }
   }
+
+  const [creator, setCreator] = useState('')
+  const [searchCreator, setSearchCreator] = useState('')
+  const { run: handleSearchCreator } = useDebounceFn(() => {
+    setSearchCreator(creator)
+  }, { wait: 500 })
+  const handleCreatorChange = (value: string) => {
+    setCreator(value)
+    handleSearchCreator()
+  }
+
   const [tagFilterValue, setTagFilterValue] = useState<string[]>([])
   const [tagFilterValue, setTagFilterValue] = useState<string[]>([])
   const [tagIDs, setTagIDs] = useState<string[]>([])
   const [tagIDs, setTagIDs] = useState<string[]>([])
   const { run: handleTagsUpdate } = useDebounceFn(() => {
   const { run: handleTagsUpdate } = useDebounceFn(() => {
@@ -127,6 +138,15 @@ const Container = () => {
         />
         />
         {activeTab === 'dataset' && (
         {activeTab === 'dataset' && (
           <div className='flex items-center justify-center gap-2'>
           <div className='flex items-center justify-center gap-2'>
+            <Input
+              showLeftIcon
+              showClearIcon
+              wrapperClassName='w-[200px]'
+              value={creator}
+              onChange={e => handleCreatorChange(e.target.value)}
+              onClear={() => handleCreatorChange('')}
+              placeholder="请输入创建人"
+            />
             <SimpleSelect
             <SimpleSelect
               wrapperClassName="h-[32px] w-[200px]"
               wrapperClassName="h-[32px] w-[200px]"
               defaultValue={authType}
               defaultValue={authType}
@@ -191,7 +211,7 @@ const Container = () => {
       </div>
       </div>
       {activeTab === 'dataset' && (
       {activeTab === 'dataset' && (
         <>
         <>
-          <Datasets containerRef={containerRef} tags={tagIDs} keywords={searchKeywords} includeAll={includeAll} type={searchType} dept={dept} authType={authType} />
+          <Datasets containerRef={containerRef} tags={tagIDs} keywords={searchKeywords} includeAll={includeAll} type={searchType} dept={dept} authType={authType} creator={searchCreator} />
           <DatasetFooter />
           <DatasetFooter />
           {showTagManagementModal && (
           {showTagManagementModal && (
             <TagManagementModal type='knowledge' show={showTagManagementModal} />
             <TagManagementModal type='knowledge' show={showTagManagementModal} />

+ 6 - 1
web/app/(commonLayout)/datasets/Datasets.tsx

@@ -19,6 +19,7 @@ const getKey = (
   type: string,
   type: string,
   dept: string,
   dept: string,
   authType: string,
   authType: string,
+  creator: string,
 ) => {
 ) => {
   if (!pageIndex || previousPageData.has_more) {
   if (!pageIndex || previousPageData.has_more) {
     const params: FetchDatasetsParams = {
     const params: FetchDatasetsParams = {
@@ -39,6 +40,8 @@ const getKey = (
       params.params.creatorDept = dept
       params.params.creatorDept = dept
     if (authType)
     if (authType)
       params.params.authType = authType
       params.params.authType = authType
+    if (creator)
+      params.params.creator = creator
     return params
     return params
   }
   }
   return null
   return null
@@ -52,6 +55,7 @@ type Props = {
   type: string,
   type: string,
   dept: string,
   dept: string,
   authType: string,
   authType: string,
+  creator: string,
 }
 }
 
 
 const Datasets = ({
 const Datasets = ({
@@ -62,10 +66,11 @@ const Datasets = ({
   type,
   type,
   dept,
   dept,
   authType,
   authType,
+  creator,
 }: Props) => {
 }: Props) => {
   const { isCurrentWorkspaceEditor } = useAppContext()
   const { isCurrentWorkspaceEditor } = useAppContext()
   const { data, isLoading, setSize, mutate } = useSWRInfinite(
   const { data, isLoading, setSize, mutate } = useSWRInfinite(
-    (pageIndex: number, previousPageData: DataSetListResponse) => getKey(pageIndex, previousPageData, tags, keywords, includeAll, type, dept, authType),
+    (pageIndex: number, previousPageData: DataSetListResponse) => getKey(pageIndex, previousPageData, tags, keywords, includeAll, type, dept, authType, creator),
     fetchDatasets,
     fetchDatasets,
     { revalidateFirstPage: false, revalidateAll: true },
     { revalidateFirstPage: false, revalidateAll: true },
   )
   )

+ 10 - 5
web/app/components/workflow/nodes/intent-recon-train/default.ts

@@ -10,17 +10,22 @@ import {
 const nodeDefault: NodeDefault<HttpNodeType> = {
 const nodeDefault: NodeDefault<HttpNodeType> = {
   defaultValue: {
   defaultValue: {
     variables: [],
     variables: [],
-    method: Method.get,
-    url: '',
+    method: Method.post,
+    url: ['localhost', '1.95.78.201'].includes(location.hostname) ? 'http://1.95.78.201:30001/call' : 'http://10.76.102.168.:5006/call',
     authorization: {
     authorization: {
       type: AuthorizationType.none,
       type: AuthorizationType.none,
       config: null,
       config: null,
     },
     },
-    headers: '',
+    headers: 'accept:application/json\nContent-Type:application/json',
     params: '',
     params: '',
     body: {
     body: {
-      type: BodyType.none,
-      data: [],
+      type: BodyType.rawText,
+      data: <any>[
+        {
+          type: 'text',
+          value: '{\n    "input": {\n      "text": ""\n    },\n    "parameters": {\n      "candidate_labels": []\n    }\n}',
+        },
+      ],
     },
     },
     timeout: {
     timeout: {
       max_connect_timeout: 0,
       max_connect_timeout: 0,

+ 24 - 27
web/app/components/workflow/nodes/intent-recon-train/panel.tsx

@@ -9,12 +9,9 @@ import AuthorizationModal from './components/authorization'
 import type { HttpNodeType } from './types'
 import type { HttpNodeType } from './types'
 import Timeout from './components/timeout'
 import Timeout from './components/timeout'
 import CurlPanel from './components/curl-panel'
 import CurlPanel from './components/curl-panel'
-import cn from '@/utils/classnames'
 import Field from '@/app/components/workflow/nodes/_base/components/field'
 import Field from '@/app/components/workflow/nodes/_base/components/field'
 import Split from '@/app/components/workflow/nodes/_base/components/split'
 import Split from '@/app/components/workflow/nodes/_base/components/split'
 import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
 import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
-import { Settings01 } from '@/app/components/base/icons/src/vender/line/general'
-import { FileArrow01 } from '@/app/components/base/icons/src/vender/line/files'
 import type { NodePanelProps } from '@/app/components/workflow/types'
 import type { NodePanelProps } from '@/app/components/workflow/types'
 import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/before-run-form'
 import BeforeRunForm from '@/app/components/workflow/nodes/_base/components/before-run-form'
 import ResultPanel from '@/app/components/workflow/run/result-panel'
 import ResultPanel from '@/app/components/workflow/run/result-panel'
@@ -69,33 +66,33 @@ const Panel: FC<NodePanelProps<HttpNodeType>> = ({
       <div className='space-y-4 px-4 pb-4'>
       <div className='space-y-4 px-4 pb-4'>
         <Field
         <Field
           title={t(`${i18nPrefix}.api`)}
           title={t(`${i18nPrefix}.api`)}
-          operations={
-            <div className='flex'>
-              <div
-                onClick={showAuthorization}
-                className={cn(!readOnly && 'cursor-pointer hover:bg-gray-50', 'flex h-6 items-center space-x-1 rounded-md px-2 ')}
-              >
-                {!readOnly && <Settings01 className='h-3 w-3 text-gray-500' />}
-                <div className='text-xs font-medium text-gray-500'>
-                  {t(`${i18nPrefix}.authorization.authorization`)}
-                  <span className='ml-1 text-gray-700'>{t(`${i18nPrefix}.authorization.${inputs.authorization.type}`)}</span>
-                </div>
-              </div>
-              <div
-                onClick={showCurlPanel}
-                className={cn(!readOnly && 'cursor-pointer hover:bg-gray-50', 'flex h-6 items-center space-x-1 rounded-md px-2 ')}
-              >
-                {!readOnly && <FileArrow01 className='h-3 w-3 text-gray-500' />}
-                <div className='text-xs font-medium text-gray-500'>
-                  {t(`${i18nPrefix}.curl.title`)}
-                </div>
-              </div>
-            </div>
-          }
+          // operations={
+          //   <div className='flex'>
+          //     <div
+          //       onClick={showAuthorization}
+          //       className={cn(!readOnly && 'cursor-pointer hover:bg-gray-50', 'flex h-6 items-center space-x-1 rounded-md px-2 ')}
+          //     >
+          //       {!readOnly && <Settings01 className='h-3 w-3 text-gray-500' />}
+          //       <div className='text-xs font-medium text-gray-500'>
+          //         {t(`${i18nPrefix}.authorization.authorization`)}
+          //         <span className='ml-1 text-gray-700'>{t(`${i18nPrefix}.authorization.${inputs.authorization.type}`)}</span>
+          //       </div>
+          //     </div>
+          //     <div
+          //       onClick={showCurlPanel}
+          //       className={cn(!readOnly && 'cursor-pointer hover:bg-gray-50', 'flex h-6 items-center space-x-1 rounded-md px-2 ')}
+          //     >
+          //       {!readOnly && <FileArrow01 className='h-3 w-3 text-gray-500' />}
+          //       <div className='text-xs font-medium text-gray-500'>
+          //         {t(`${i18nPrefix}.curl.title`)}
+          //       </div>
+          //     </div>
+          //   </div>
+          // }
         >
         >
           <ApiInput
           <ApiInput
             nodeId={id}
             nodeId={id}
-            readonly={readOnly}
+            readonly={true}
             method={inputs.method}
             method={inputs.method}
             onMethodChange={handleMethodChange}
             onMethodChange={handleMethodChange}
             url={inputs.url}
             url={inputs.url}

+ 9 - 9
web/utils/app-redirection.ts

@@ -5,13 +5,13 @@ export const getRedirection = (
   app: { id: string, mode: AppMode },
   app: { id: string, mode: AppMode },
   redirectionFunc: (href: string) => void,
   redirectionFunc: (href: string) => void,
 ) => {
 ) => {
-  if (!isCurrentWorkspaceEditor) {
-    redirectionFunc(`/app/${app.id}/overview`)
-  }
-  else {
-    if (app.mode === 'workflow' || app.mode === 'advanced-chat')
-      redirectionFunc(`/app/${app.id}/workflow`)
-    else
-      redirectionFunc(`/app/${app.id}/configuration`)
-  }
+  // if (!isCurrentWorkspaceEditor) {
+  //   redirectionFunc(`/app/${app.id}/overview`)
+  // }
+  // else {
+  if (app.mode === 'workflow' || app.mode === 'advanced-chat')
+    redirectionFunc(`/app/${app.id}/workflow`)
+  else
+    redirectionFunc(`/app/${app.id}/configuration`)
+  // }
 }
 }