From 953746bf7e03b2a08c7cd015acefba63f570e216 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 29 May 2025 16:58:13 +0800 Subject: [PATCH 1/2] feat: use api schema --- .../tool-selector/reasoning-config-form.tsx | 17 ++++- .../tool-selector/schema-modal.tsx | 76 +------------------ 2 files changed, 16 insertions(+), 77 deletions(-) diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx index 83050cb448..49b099662a 100644 --- a/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/reasoning-config-form.tsx @@ -25,6 +25,7 @@ import { VarType } from '@/app/components/workflow/types' import cn from '@/utils/classnames' import { useBoolean } from 'ahooks' import SchemaModal from './schema-modal' +import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types' type Props = { value: Record @@ -141,7 +142,10 @@ const ReasoningConfigForm: React.FC = ({ setFalse: hideSchema, }] = useBoolean(false) - const renderField = (schema: any, showSchema: () => void) => { + const [schema, setSchema] = useState(null) + console.log(schema) + + const renderField = (schema: any, showSchema: (schema: SchemaRoot) => void) => { const { variable, label, @@ -150,6 +154,7 @@ const ReasoningConfigForm: React.FC = ({ type, scope, url, + input_schema, } = schema const auto = value[variable]?.auto const tooltipContent = (tooltip && ( @@ -192,7 +197,7 @@ const ReasoningConfigForm: React.FC = ({ {tooltipContent} ยท {valueType} - {!isShowSchemaTooltip && ( + {isShowSchemaTooltip && ( {t('workflow.nodes.agent.clickToViewParameterSchema')} @@ -200,7 +205,7 @@ const ReasoningConfigForm: React.FC = ({ asChild={false}>
showSchema(input_schema as SchemaRoot)} >
@@ -313,10 +318,14 @@ const ReasoningConfigForm: React.FC = ({ } return (
- {!isShowSchema && schemas.map(schema => renderField(schema, showSchema))} + {!isShowSchema && schemas.map(schema => renderField(schema, (s: SchemaRoot) => { + setSchema(s) + showSchema() + }))} {isShowSchema && ( )} diff --git a/web/app/components/plugins/plugin-detail-panel/tool-selector/schema-modal.tsx b/web/app/components/plugins/plugin-detail-panel/tool-selector/schema-modal.tsx index 748b8d87eb..de4e96a8b7 100644 --- a/web/app/components/plugins/plugin-detail-panel/tool-selector/schema-modal.tsx +++ b/web/app/components/plugins/plugin-detail-panel/tool-selector/schema-modal.tsx @@ -4,89 +4,19 @@ import React from 'react' import Modal from '@/app/components/base/modal' import VisualEditor from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor' import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types' -import { Type } from '@/app/components/workflow/nodes/llm/types' import { MittProvider, VisualEditorContextProvider } from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context' import { useTranslation } from 'react-i18next' import { RiCloseLine } from '@remixicon/react' -const testSchema: SchemaRoot = { - type: Type.object, - properties: { - after: { - type: Type.string, - description: 'The ID of the existing block that the new block should be appended after. If not provided, content will be appended at the end of the page.', - }, - content_block: { - type: Type.object, - properties: { - block_property: { - type: Type.string, - description: 'The block property of the block to be added. Possible property are `paragraph`,`heading_1`,`heading_2`,`heading_3`,`callout`,`todo`,`toggle`,`quote`, `bulleted_list_item`, `numbered_list_item`, other properties possible are `file`,`image`,`video` (link required).', - }, - bold: { - type: Type.boolean, - description: 'Indicates if the text is bold.', - }, - code: { - type: Type.boolean, - description: 'Indicates if the text is formatted as code.', - }, - color: { - type: Type.string, - description: 'The color of the text background or text itself.', - }, - content: { - anyOf: [ - { - type: Type.string, - }, - { - enum: [ - 'null', - ], - nullable: true, - }, - ], - description: 'The textual content of the rich text object. Required for paragraph, heading_1, heading_2, heading_3, callout, todo, toggle, quote.', - }, - italic: { - type: Type.boolean, - description: 'Indicates if the text is italic.', - }, - link: { - type: Type.string, - description: 'The URL of the rich text object or the file to be uploaded or image/video link', - }, - strikethrough: { - type: Type.boolean, - description: 'Indicates if the text has strikethrough.', - }, - underline: { - type: Type.boolean, - description: 'Indicates if the text is underlined.', - }, - }, - additionalProperties: false, - description: 'Child content to append to a page.', - }, - parent_block_id: { - type: Type.string, - description: 'The ID of the page which the children will be added.', - }, - }, - required: [ - 'content_block', - 'parent_block_id', - ], - additionalProperties: false, -} type Props = { isShow: boolean + schema: SchemaRoot onClose: () => void } const SchemaModal: FC = ({ isShow, + schema, onClose, }) => { const { t } = useTranslation() @@ -112,7 +42,7 @@ const SchemaModal: FC = ({ From 049f904af84c2fe2b1f6f75962f45d32e5d2754e Mon Sep 17 00:00:00 2001 From: jZonG Date: Thu, 29 May 2025 17:22:19 +0800 Subject: [PATCH 2/2] fix: auto authorizing --- web/app/components/tools/mcp/index.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/web/app/components/tools/mcp/index.tsx b/web/app/components/tools/mcp/index.tsx index c5d06d571b..fa069ac7f0 100644 --- a/web/app/components/tools/mcp/index.tsx +++ b/web/app/components/tools/mcp/index.tsx @@ -68,13 +68,18 @@ const MCPList = ({ const handleCreate = async (provider: ToolWithProvider) => { await refetch() // update list setCurrentProviderID(provider.id) - await authorizeMcp({ + const res = await authorizeMcp({ provider_id: provider.id, }) - await refetch() // update authorization in list - await updateTools(provider.id) - invalidateMCPTools(provider.id) - await refetch() // update tool list in provider list + if (res.result === 'success') { + await refetch() // update authorization in list + await updateTools(provider.id) + invalidateMCPTools(provider.id) + await refetch() // update tool list in provider list + } + else if (res.authorization_url) { + router.push(res.authorization_url) + } } const handleUpdateAuthorization = async (providerID: string, code: string) => {