Merge branch 'feat/mcp-frontend' into deploy/dev

This commit is contained in:
jZonG 2025-05-29 17:23:57 +08:00
commit f74ffecfb0
3 changed files with 26 additions and 82 deletions

View File

@ -25,6 +25,7 @@ import { VarType } from '@/app/components/workflow/types'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import { useBoolean } from 'ahooks' import { useBoolean } from 'ahooks'
import SchemaModal from './schema-modal' import SchemaModal from './schema-modal'
import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types'
type Props = { type Props = {
value: Record<string, any> value: Record<string, any>
@ -141,7 +142,10 @@ const ReasoningConfigForm: React.FC<Props> = ({
setFalse: hideSchema, setFalse: hideSchema,
}] = useBoolean(false) }] = useBoolean(false)
const renderField = (schema: any, showSchema: () => void) => { const [schema, setSchema] = useState<SchemaRoot | null>(null)
console.log(schema)
const renderField = (schema: any, showSchema: (schema: SchemaRoot) => void) => {
const { const {
variable, variable,
label, label,
@ -150,6 +154,7 @@ const ReasoningConfigForm: React.FC<Props> = ({
type, type,
scope, scope,
url, url,
input_schema,
} = schema } = schema
const auto = value[variable]?.auto const auto = value[variable]?.auto
const tooltipContent = (tooltip && ( const tooltipContent = (tooltip && (
@ -192,7 +197,7 @@ const ReasoningConfigForm: React.FC<Props> = ({
{tooltipContent} {tooltipContent}
<span className='system-xs-regular mx-1 text-text-quaternary'>·</span> <span className='system-xs-regular mx-1 text-text-quaternary'>·</span>
<span className='system-xs-regular text-text-tertiary'>{valueType}</span> <span className='system-xs-regular text-text-tertiary'>{valueType}</span>
{!isShowSchemaTooltip && ( {isShowSchemaTooltip && (
<Tooltip <Tooltip
popupContent={<div className='system-xs-medium text-text-secondary'> popupContent={<div className='system-xs-medium text-text-secondary'>
{t('workflow.nodes.agent.clickToViewParameterSchema')} {t('workflow.nodes.agent.clickToViewParameterSchema')}
@ -200,7 +205,7 @@ const ReasoningConfigForm: React.FC<Props> = ({
asChild={false}> asChild={false}>
<div <div
className='ml-0.5 cursor-pointer rounded-[4px] p-px text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary' className='ml-0.5 cursor-pointer rounded-[4px] p-px text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary'
onClick={showSchema} onClick={() => showSchema(input_schema as SchemaRoot)}
> >
<RiBracesLine className='size-3.5'/> <RiBracesLine className='size-3.5'/>
</div> </div>
@ -313,10 +318,14 @@ const ReasoningConfigForm: React.FC<Props> = ({
} }
return ( return (
<div className='space-y-3 px-4 py-2'> <div className='space-y-3 px-4 py-2'>
{!isShowSchema && schemas.map(schema => renderField(schema, showSchema))} {!isShowSchema && schemas.map(schema => renderField(schema, (s: SchemaRoot) => {
setSchema(s)
showSchema()
}))}
{isShowSchema && ( {isShowSchema && (
<SchemaModal <SchemaModal
isShow={isShowSchema} isShow={isShowSchema}
schema={schema!}
onClose={hideSchema} onClose={hideSchema}
/> />
)} )}

View File

@ -4,89 +4,19 @@ import React from 'react'
import Modal from '@/app/components/base/modal' import Modal from '@/app/components/base/modal'
import VisualEditor from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor' 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 { 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 { MittProvider, VisualEditorContextProvider } from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/context'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { RiCloseLine } from '@remixicon/react' 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 = { type Props = {
isShow: boolean isShow: boolean
schema: SchemaRoot
onClose: () => void onClose: () => void
} }
const SchemaModal: FC<Props> = ({ const SchemaModal: FC<Props> = ({
isShow, isShow,
schema,
onClose, onClose,
}) => { }) => {
const { t } = useTranslation() const { t } = useTranslation()
@ -112,7 +42,7 @@ const SchemaModal: FC<Props> = ({
<MittProvider> <MittProvider>
<VisualEditorContextProvider> <VisualEditorContextProvider>
<VisualEditor <VisualEditor
schema={testSchema} schema={schema}
readOnly readOnly
></VisualEditor> ></VisualEditor>
</VisualEditorContextProvider> </VisualEditorContextProvider>

View File

@ -68,14 +68,19 @@ const MCPList = ({
const handleCreate = async (provider: ToolWithProvider) => { const handleCreate = async (provider: ToolWithProvider) => {
await refetch() // update list await refetch() // update list
setCurrentProviderID(provider.id) setCurrentProviderID(provider.id)
await authorizeMcp({ const res = await authorizeMcp({
provider_id: provider.id, provider_id: provider.id,
}) })
if (res.result === 'success') {
await refetch() // update authorization in list await refetch() // update authorization in list
await updateTools(provider.id) await updateTools(provider.id)
invalidateMCPTools(provider.id) invalidateMCPTools(provider.id)
await refetch() // update tool list in provider list 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) => { const handleUpdateAuthorization = async (providerID: string, code: string) => {
const targetProvider = list.find(provider => provider.id === providerID) const targetProvider = list.find(provider => provider.id === providerID)