@@ -2,18 +2,32 @@ import { createPortal } from 'react-dom'
2
2
import { useState , useEffect } from 'react'
3
3
import PropTypes from 'prop-types'
4
4
import { MemoizedReactMarkdown } from '@/ui-component/markdown/MemoizedReactMarkdown'
5
- import { Typography , Stack , Card , Accordion , AccordionSummary , AccordionDetails , Dialog , DialogContent , DialogTitle } from '@mui/material'
5
+ import {
6
+ Typography ,
7
+ Stack ,
8
+ Card ,
9
+ Accordion ,
10
+ AccordionSummary ,
11
+ AccordionDetails ,
12
+ Dialog ,
13
+ DialogContent ,
14
+ DialogTitle ,
15
+ Box
16
+ } from '@mui/material'
6
17
import { TableViewOnly } from '@/ui-component/table/Table'
7
18
import documentstoreApi from '@/api/documentstore'
8
19
import useApi from '@/hooks/useApi'
9
20
import { useTheme } from '@mui/material/styles'
21
+ import { useSelector } from 'react-redux'
10
22
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
23
+ import { IconInfoCircle } from '@tabler/icons-react'
11
24
import { baseURL } from '@/store/constant'
12
25
13
26
const DocStoreAPIDialog = ( { show, dialogProps, onCancel } ) => {
14
27
const [ nodeConfig , setNodeConfig ] = useState ( { } )
15
28
const [ values , setValues ] = useState ( '' )
16
29
const theme = useTheme ( )
30
+ const customization = useSelector ( ( state ) => state . customization )
17
31
const [ nodeConfigExpanded , setNodeConfigExpanded ] = useState ( { } )
18
32
19
33
const getConfigApi = useApi ( documentstoreApi . getDocumentStoreConfig )
@@ -38,6 +52,7 @@ body_data = {
38
52
"metadata": {}, # Add additional metadata to the document chunks
39
53
"replaceExisting": True, # Replace existing document with the new upserted chunks
40
54
"createNewDocStore": False, # Create a new document store
55
+ "loaderName": "Custom Loader Name", # Override the loader name
41
56
"splitter": json.dumps({"config":{"chunkSize":20000}}) # Override existing configuration
42
57
# "loader": "",
43
58
# "vectorStore": "",
@@ -64,6 +79,7 @@ print(output)
64
79
let formData = new FormData();
65
80
formData.append("files", input.files[0]);
66
81
formData.append("docId", "${ dialogProps . loaderId } ");
82
+ formData.append("loaderName", "Custom Loader Name");
67
83
formData.append("splitter", JSON.stringify({"config":{"chunkSize":20000}}));
68
84
// Add additional metadata to the document chunks
69
85
formData.append("metadata", "{}");
@@ -103,6 +119,7 @@ curl -X POST ${baseURL}/api/v1/document-store/upsert/${dialogProps.storeId} \\
103
119
-H "Authorization: Bearer <your_api_key_here>" \\
104
120
-F "files=@<file-path>" \\
105
121
-F "docId=${ dialogProps . loaderId } " \\
122
+ -F "loaderName=Custom Loader Name" \\
106
123
-F "splitter={"config":{"chunkSize":20000}}" \\
107
124
-F "metadata={}" \\
108
125
-F "replaceExisting=true" \\
@@ -139,6 +156,7 @@ output = query({
139
156
"metadata": "{}", # Add additional metadata to the document chunks
140
157
"replaceExisting": True, # Replace existing document with the new upserted chunks
141
158
"createNewDocStore": False, # Create a new document store
159
+ "loaderName": "Custom Loader Name", # Override the loader name
142
160
# Override existing configuration
143
161
"loader": {
144
162
"config": {
@@ -176,10 +194,11 @@ async function query(data) {
176
194
}
177
195
178
196
query({
179
- "docId": "${ dialogProps . loaderId } ,
197
+ "docId": "${ dialogProps . loaderId } " ,
180
198
"metadata": "{}", // Add additional metadata to the document chunks
181
199
"replaceExisting": true, // Replace existing document with the new upserted chunks
182
200
"createNewDocStore": false, // Create a new document store
201
+ "loaderName": "Custom Loader Name", // Override the loader name
183
202
// Override existing configuration
184
203
"loader": {
185
204
"config": {
@@ -209,6 +228,7 @@ curl -X POST ${baseURL}/api/v1/document-store/upsert/${dialogProps.storeId} \\
209
228
"metadata": "{}",
210
229
"replaceExisting": true,
211
230
"createNewDocStore": false,
231
+ "loaderName": "Custom Loader Name",
212
232
"loader": {
213
233
"config": {
214
234
"text": "This is a new text"
@@ -304,6 +324,37 @@ curl -X POST ${baseURL}/api/v1/document-store/upsert/${dialogProps.storeId} \\
304
324
{ dialogProps . title }
305
325
</ DialogTitle >
306
326
< DialogContent >
327
+ { /* Info Box */ }
328
+ < Box
329
+ sx = { {
330
+ display : 'flex' ,
331
+ alignItems : 'center' ,
332
+ padding : 2 ,
333
+ mb : 3 ,
334
+ background : customization . isDarkMode
335
+ ? 'linear-gradient(135deg, rgba(33, 150, 243, 0.2) 0%, rgba(33, 150, 243, 0.1) 100%)'
336
+ : 'linear-gradient(135deg, rgba(33, 150, 243, 0.1) 0%, rgba(33, 150, 243, 0.05) 100%)' ,
337
+ color : customization . isDarkMode ? 'white' : '#333333' ,
338
+ fontWeight : 400 ,
339
+ borderRadius : 2 ,
340
+ border : `1px solid ${ customization . isDarkMode ? 'rgba(33, 150, 243, 0.3)' : 'rgba(33, 150, 243, 0.2)' } ` ,
341
+ gap : 1.5
342
+ } }
343
+ >
344
+ < IconInfoCircle
345
+ size = { 20 }
346
+ style = { {
347
+ color : customization . isDarkMode ? '#64b5f6' : '#1976d2' ,
348
+ flexShrink : 0
349
+ } }
350
+ />
351
+ < Box sx = { { flex : 1 } } >
352
+ < strong > Note:</ strong > Upsert API can only be used when the existing document loader has been upserted before.
353
+ </ Box >
354
+ </ Box >
355
+
356
+ { /** info */ }
357
+
307
358
< MemoizedReactMarkdown > { values } </ MemoizedReactMarkdown >
308
359
309
360
< Typography sx = { { mt : 3 , mb : 1 } } > You can override existing configurations:</ Typography >
0 commit comments