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

This commit is contained in:
Joel 2025-06-03 10:46:52 +08:00
commit c27af0dd7d
3 changed files with 11 additions and 5 deletions

View File

@ -143,9 +143,9 @@ const ReasoningConfigForm: React.FC<Props> = ({
}] = useBoolean(false)
const [schema, setSchema] = useState<SchemaRoot | null>(null)
console.log(schema)
const [schemaRootName, setSchemaRootName] = useState<string>('')
const renderField = (schema: any, showSchema: (schema: SchemaRoot) => void) => {
const renderField = (schema: any, showSchema: (schema: SchemaRoot, rootName: string) => void) => {
const {
variable,
label,
@ -205,7 +205,7 @@ const ReasoningConfigForm: React.FC<Props> = ({
asChild={false}>
<div
className='ml-0.5 cursor-pointer rounded-[4px] p-px text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary'
onClick={() => showSchema(input_schema as SchemaRoot)}
onClick={() => showSchema(input_schema as SchemaRoot, label[language] || label.en_US)}
>
<RiBracesLine className='size-3.5'/>
</div>
@ -318,14 +318,16 @@ const ReasoningConfigForm: React.FC<Props> = ({
}
return (
<div className='space-y-3 px-4 py-2'>
{!isShowSchema && schemas.map(schema => renderField(schema, (s: SchemaRoot) => {
{!isShowSchema && schemas.map(schema => renderField(schema, (s: SchemaRoot, rootName: string) => {
setSchema(s)
setSchemaRootName(rootName)
showSchema()
}))}
{isShowSchema && (
<SchemaModal
isShow={isShowSchema}
schema={schema!}
rootName={schemaRootName}
onClose={hideSchema}
/>
)}

View File

@ -11,12 +11,14 @@ import { RiCloseLine } from '@remixicon/react'
type Props = {
isShow: boolean
schema: SchemaRoot
rootName: string
onClose: () => void
}
const SchemaModal: FC<Props> = ({
isShow,
schema,
rootName,
onClose,
}) => {
const { t } = useTranslation()
@ -43,6 +45,7 @@ const SchemaModal: FC<Props> = ({
<VisualEditorContextProvider>
<VisualEditor
schema={schema}
rootName={rootName}
readOnly
></VisualEditor>
</VisualEditorContextProvider>

View File

@ -5,6 +5,7 @@ import { useSchemaNodeOperations } from './hooks'
export type VisualEditorProps = {
schema: SchemaRoot
rootName?: string
readOnly?: boolean
onChange?: (schema: SchemaRoot) => void
}
@ -16,7 +17,7 @@ const VisualEditor: FC<VisualEditorProps> = (props) => {
return (
<div className='h-full overflow-auto rounded-xl bg-background-section-burn p-1 pl-2'>
<SchemaNode
name='structured_output'
name={props.rootName || 'structured_output'}
schema={schema}
required={false}
path={[]}