feat: can show schema tooltip

pull/22091/head
Joel 12 months ago
parent 83c9ebbacc
commit 1c44fb77af

@ -1,3 +1,5 @@
import type { SchemaRoot } from '@/app/components/workflow/nodes/llm/types'
export type FormValue = Record<string, any> export type FormValue = Record<string, any>
export type TypeWithI18N<T = string> = { export type TypeWithI18N<T = string> = {
@ -109,6 +111,7 @@ export type FormShowOnObject = {
} }
export type CredentialFormSchemaBase = { export type CredentialFormSchemaBase = {
name: string
variable: string variable: string
label: TypeWithI18N label: TypeWithI18N
type: FormTypeEnum type: FormTypeEnum
@ -118,6 +121,7 @@ export type CredentialFormSchemaBase = {
show_on: FormShowOnObject[] show_on: FormShowOnObject[]
url?: string url?: string
scope?: string scope?: string
input_schema?: SchemaRoot
} }
export type CredentialFormSchemaTextInput = CredentialFormSchemaBase & { export type CredentialFormSchemaTextInput = CredentialFormSchemaBase & {

@ -80,7 +80,6 @@ const AgentPanel: FC<NodePanelProps<AgentNodeType>> = (props) => {
})() })()
const resetEditor = useStore(s => s.setControlPromptEditorRerenderKey) const resetEditor = useStore(s => s.setControlPromptEditorRerenderKey)
console.log(canChooseMCPTool)
return <div className='my-2'> return <div className='my-2'>
<Field <Field
required required

@ -10,6 +10,8 @@ import { useLanguage } from '@/app/components/header/account-setting/model-provi
import Button from '@/app/components/base/button' import Button from '@/app/components/base/button'
import Tooltip from '@/app/components/base/tooltip' import Tooltip from '@/app/components/base/tooltip'
import FormInputItem from '@/app/components/workflow/nodes/_base/components/form-input-item' import FormInputItem from '@/app/components/workflow/nodes/_base/components/form-input-item'
import { useBoolean } from 'ahooks'
import SchemaModal from '@/app/components/plugins/plugin-detail-panel/tool-selector/schema-modal'
type Props = { type Props = {
readOnly: boolean readOnly: boolean
@ -27,10 +29,13 @@ const ToolFormItem: FC<Props> = ({
onChange, onChange,
}) => { }) => {
const language = useLanguage() const language = useLanguage()
const { label, type, required, tooltip } = schema const { name, label, type, required, tooltip, input_schema } = schema
const showSchemaButton = type === FormTypeEnum.object || type === FormTypeEnum.array const showSchemaButton = type === FormTypeEnum.object || type === FormTypeEnum.array
const showDescription = type === FormTypeEnum.textInput || type === FormTypeEnum.secretInput const showDescription = type === FormTypeEnum.textInput || type === FormTypeEnum.secretInput
const [isShowSchema, {
setTrue: showSchema,
setFalse: hideSchema,
}] = useBoolean(false)
return ( return (
<div className='space-y-0.5 py-1'> <div className='space-y-0.5 py-1'>
<div> <div>
@ -54,9 +59,7 @@ const ToolFormItem: FC<Props> = ({
<Button <Button
variant='ghost' variant='ghost'
size='small' size='small'
onClick={() => { onClick={showSchema}
// onOpen?.(index)
}}
className='system-xs-regular px-1 text-text-tertiary' className='system-xs-regular px-1 text-text-tertiary'
> >
<RiBracesLine className='mr-1 size-3.5' /> <RiBracesLine className='mr-1 size-3.5' />
@ -76,6 +79,15 @@ const ToolFormItem: FC<Props> = ({
value={value} value={value}
onChange={onChange} onChange={onChange}
/> />
{isShowSchema && (
<SchemaModal
isShow
onClose={hideSchema}
rootName={name}
schema={input_schema!}
/>
)}
</div> </div>
) )
} }

Loading…
Cancel
Save