diff --git a/packages/xgen/components/edit/CodeEditor/index.less b/packages/xgen/components/edit/CodeEditor/index.less
index 2f35c05d..23e5c962 100644
--- a/packages/xgen/components/edit/CodeEditor/index.less
+++ b/packages/xgen/components/edit/CodeEditor/index.less
@@ -1,4 +1,10 @@
+.editor {
+ width: 100%;
+ height: 100%;
+ position: relative;
+}
+
._local {
- border-radius: var(--radius) !important;
- overflow: hidden;
-}
\ No newline at end of file
+ width: 100%;
+ height: 100%;
+}
diff --git a/packages/xgen/components/edit/CodeEditor/index.tsx b/packages/xgen/components/edit/CodeEditor/index.tsx
index e01ce0b8..2a5b3434 100644
--- a/packages/xgen/components/edit/CodeEditor/index.tsx
+++ b/packages/xgen/components/edit/CodeEditor/index.tsx
@@ -1,14 +1,10 @@
import { useEffect, useMemo, useRef, useState } from 'react'
import Editor from 'react-monaco-editor'
-
import { Item } from '@/components'
import { useGlobal } from '@/context/app'
import vars from '@/styles/preset/vars'
-
import styles from './index.less'
-
import type { Component } from '@/types'
-
import yaml from 'js-yaml'
import type { EditorDidMount, monaco } from 'react-monaco-editor'
import { message } from 'antd'
@@ -78,6 +74,23 @@ const Custom = window.$app.memo((props: ICustom) => {
setValue(props.value)
}, [props.value])
+ useEffect(() => {
+ const resizeObserver = new ResizeObserver(() => {
+ if (ref.current) {
+ ref.current.layout()
+ }
+ })
+
+ const container = document.querySelector(`.${styles.editor}`)
+ if (container) {
+ resizeObserver.observe(container)
+ }
+
+ return () => {
+ resizeObserver.disconnect()
+ }
+ }, [])
+
const onChange = (v: any) => {
if (!props.onChange) return
props.onChange(v)
@@ -121,30 +134,32 @@ const Custom = window.$app.memo((props: ICustom) => {
}
return (
-
+
+
+
)
})
diff --git a/packages/xgen/pages/assistants/detail/$.tsx b/packages/xgen/pages/assistants/detail/$.tsx
index af02b428..286de185 100644
--- a/packages/xgen/pages/assistants/detail/$.tsx
+++ b/packages/xgen/pages/assistants/detail/$.tsx
@@ -6,10 +6,11 @@ import type { Assistant } from '@/layouts/components/Neo/components/AIChat/Card'
import type { UploadChangeParam } from 'antd/es/upload'
import type { UploadFile } from 'antd/es/upload/interface'
import Tag from '@/layouts/components/Neo/components/AIChat/Tag'
-import BasicInfo from './components/BasicInfo'
-import KnowledgeFiles from './components/KnowledgeFiles'
+import General from './components/General'
+import Files from './components/Files'
import Workflow from './components/Workflow'
-import CodeEditor from './components/CodeEditor'
+import Script from './components/Script'
+import Functions from './components/Functions'
import styles from './index.less'
const AssistantDetail = () => {
@@ -108,14 +109,14 @@ const AssistantDetail = () => {
const items = [
{
- key: 'basic',
- label: 'Basic Info',
- children:
+ key: 'general',
+ label: 'General',
+ children:
},
{
key: 'files',
- label: 'Knowledge Files',
- children:
+ label: 'Files',
+ children:
},
{
key: 'workflow',
@@ -123,9 +124,14 @@ const AssistantDetail = () => {
children:
},
{
- key: 'code',
- label: 'Code',
- children:
+ key: 'functions',
+ label: 'Functions',
+ children:
+ },
+ {
+ key: 'script',
+ label: 'Script',
+ children:
}
]
diff --git a/packages/xgen/pages/assistants/detail/components/Files.tsx b/packages/xgen/pages/assistants/detail/components/Files.tsx
new file mode 100644
index 00000000..4e73bd85
--- /dev/null
+++ b/packages/xgen/pages/assistants/detail/components/Files.tsx
@@ -0,0 +1,117 @@
+import { useState } from 'react'
+import { Table, Button, Upload, Space, Typography } from 'antd'
+import { UploadOutlined, DeleteOutlined } from '@ant-design/icons'
+import type { UploadFile } from 'antd/es/upload/interface'
+import styles from '../index.less'
+
+const { Title } = Typography
+
+interface FilesProps {
+ files: UploadFile[]
+ onFilesChange: (files: UploadFile[]) => void
+}
+
+// Generate 100 test files
+const fileTypes = [
+ { ext: 'json', type: 'application/json' },
+ { ext: 'yaml', type: 'application/yaml' },
+ { ext: 'md', type: 'text/markdown' },
+ { ext: 'js', type: 'application/javascript' },
+ { ext: 'py', type: 'text/x-python' },
+ { ext: 'ts', type: 'application/typescript' }
+]
+
+const testFiles: UploadFile[] = Array.from({ length: 100 }, (_, index) => {
+ const fileType = fileTypes[index % fileTypes.length]
+ return {
+ uid: String(index + 1),
+ name: `file_${index + 1}.${fileType.ext}`,
+ size: Math.floor(Math.random() * 1024 * 1024 * 5), // Random size up to 5MB
+ type: fileType.type,
+ status: 'done'
+ }
+})
+
+export default function Files({ files: propFiles, onFilesChange }: FilesProps) {
+ const [files, setFiles] = useState(testFiles)
+
+ const columns = [
+ {
+ title: 'Name',
+ dataIndex: 'name',
+ key: 'name',
+ ellipsis: true
+ },
+ {
+ title: 'Size',
+ dataIndex: 'size',
+ key: 'size',
+ width: 120,
+ render: (size: number) => {
+ if (size < 1024) {
+ return `${size} B`
+ } else if (size < 1024 * 1024) {
+ return `${(size / 1024).toFixed(1)} KB`
+ } else {
+ return `${(size / (1024 * 1024)).toFixed(1)} MB`
+ }
+ }
+ },
+ {
+ title: 'Action',
+ key: 'action',
+ width: 80,
+ render: (_: any, record: UploadFile) => (
+ }
+ onClick={() => handleRemove(record)}
+ style={{ color: 'var(--color_text_grey)' }}
+ />
+ )
+ }
+ ]
+
+ const handleRemove = (file: UploadFile) => {
+ const newFiles = files.filter((item) => item.uid !== file.uid)
+ setFiles(newFiles)
+ onFilesChange(newFiles)
+ }
+
+ const handleUpload = (info: any) => {
+ const newFiles = [...files, ...info.fileList]
+ setFiles(newFiles)
+ onFilesChange(newFiles)
+ }
+
+ return (
+
+
+
+ Assistant Files
+
+ false}
+ onChange={handleUpload}
+ showUploadList={false}
+ >
+ }>
+ Upload
+
+
+
+
+
+ )
+}
diff --git a/packages/xgen/pages/assistants/detail/components/Functions.tsx b/packages/xgen/pages/assistants/detail/components/Functions.tsx
new file mode 100644
index 00000000..be9d75b5
--- /dev/null
+++ b/packages/xgen/pages/assistants/detail/components/Functions.tsx
@@ -0,0 +1,81 @@
+import { useState } from 'react'
+import Editor from 'react-monaco-editor'
+import { useGlobal } from '@/context/app'
+import vars from '@/styles/preset/vars'
+import styles from '../index.less'
+
+const defaultFunctions = {
+ functions: [
+ {
+ name: 'example_function',
+ description: 'An example function',
+ parameters: {
+ type: 'object',
+ properties: {
+ param1: {
+ type: 'string',
+ description: 'First parameter'
+ },
+ param2: {
+ type: 'number',
+ description: 'Second parameter'
+ }
+ },
+ required: ['param1']
+ }
+ }
+ ]
+}
+
+export default function Functions() {
+ const [value, setValue] = useState(JSON.stringify(defaultFunctions, null, 2))
+ const global = useGlobal()
+ const theme = global.theme === 'dark' ? 'x-dark' : 'x-light'
+
+ const editorDidMount = (editor: any, monaco: any) => {
+ monaco.editor.defineTheme('x-dark', {
+ base: 'vs-dark',
+ inherit: true,
+ rules: [],
+ colors: {
+ 'editor.background': vars[global.theme].color_bg_nav
+ }
+ })
+
+ monaco.editor.defineTheme('x-light', {
+ base: 'vs',
+ inherit: true,
+ rules: [],
+ colors: {
+ 'editor.background': vars[global.theme].color_bg_nav
+ }
+ })
+
+ monaco.editor.setTheme(theme)
+ }
+
+ return (
+
+
+
+ )
+}
diff --git a/packages/xgen/pages/assistants/detail/components/BasicInfo.tsx b/packages/xgen/pages/assistants/detail/components/General.tsx
similarity index 95%
rename from packages/xgen/pages/assistants/detail/components/BasicInfo.tsx
rename to packages/xgen/pages/assistants/detail/components/General.tsx
index 069ec55d..4e158207 100644
--- a/packages/xgen/pages/assistants/detail/components/BasicInfo.tsx
+++ b/packages/xgen/pages/assistants/detail/components/General.tsx
@@ -6,11 +6,11 @@ import styles from '../index.less'
const { TextArea } = Input
const { Option } = Select
-interface BasicInfoProps {
- form: any
+interface GeneralProps {
+ form: FormInstance
}
-export default function BasicInfo({ form }: { form: FormInstance }) {
+export default function General({ form }: GeneralProps) {
return (