Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
0064daee
Commit
0064daee
authored
Jun 21, 2023
by
Joel
Browse files
Options
Browse Files
Download
Plain Diff
fix: file size limit to 15M
parents
63fbf6d1
772d222d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
99 additions
and
84 deletions
+99
-84
stale.yml
.github/workflows/stale.yml
+1
-1
xlsx_parser.py
api/core/index/readers/xlsx_parser.py
+3
-1
layout.tsx
...ut)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx
+1
-1
index.tsx
web/app/components/datasets/create/file-uploader/index.tsx
+1
-1
index.module.css
web/app/components/datasets/create/step-one/index.module.css
+2
-0
index.tsx
web/app/components/datasets/hit-testing/index.tsx
+89
-78
dataset-creation.en.ts
web/i18n/lang/dataset-creation.en.ts
+1
-1
dataset-creation.zh.ts
web/i18n/lang/dataset-creation.zh.ts
+1
-1
No files found.
.github/workflows/stale.yml
View file @
0064daee
...
...
@@ -27,4 +27,4 @@ jobs:
stale-pr-message
:
"
Close
due
to
it's
no
longer
active,
if
you
have
any
questions,
you
can
reopen
it."
stale-issue-label
:
'
no-issue-activity'
stale-pr-label
:
'
no-pr-activity'
only
-labels
:
'
duplicate,question,invalid,wontfix,no-issue-activity,no-pr-activity,enhancement'
any-of
-labels
:
'
duplicate,question,invalid,wontfix,no-issue-activity,no-pr-activity,enhancement'
api/core/index/readers/xlsx_parser.py
View file @
0064daee
...
...
@@ -27,5 +27,7 @@ class XLSXParser(BaseParser):
if
keys
==
[]:
keys
=
list
(
map
(
str
,
row
))
else
:
data
.
append
(
json
.
dumps
(
dict
(
zip
(
keys
,
list
(
map
(
str
,
row
)))),
ensure_ascii
=
False
))
row_dict
=
dict
(
zip
(
keys
,
row
))
row_dict
=
{
k
:
v
for
k
,
v
in
row_dict
.
items
()
if
v
}
data
.
append
(
json
.
dumps
(
row_dict
,
ensure_ascii
=
False
))
return
'
\n\n
'
.
join
(
data
)
web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout.tsx
View file @
0064daee
...
...
@@ -124,7 +124,7 @@ const DatasetDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
?
(
<>
<
div
className=
{
s
.
subTitle
}
>
{
relatedApps
?.
total
||
'--'
}
{
t
(
'common.datasetMenus.relatedApp'
)
}
</
div
>
{
relatedApps
?.
data
?.
map
(
item
=>
(<
LikedItem
detail=
{
item
}
/>))
}
{
relatedApps
?.
data
?.
map
(
(
item
,
index
)
=>
(<
LikedItem
key=
{
index
}
detail=
{
item
}
/>))
}
</>
)
:
(
...
...
web/app/components/datasets/create/file-uploader/index.tsx
View file @
0064daee
...
...
@@ -30,7 +30,7 @@ const ACCEPTS = [
'.csv'
,
]
const
MAX_SIZE
=
1
0
*
1024
*
1024
const
MAX_SIZE
=
1
5
*
1024
*
1024
const
BATCH_COUNT
=
5
const
FileUploader
=
({
...
...
web/app/components/datasets/create/step-one/index.module.css
View file @
0064daee
...
...
@@ -10,7 +10,9 @@
}
.form
{
position
:
relative
;
padding
:
12px
64px
;
background-color
:
#fff
;
}
.dataSourceTypeList
{
...
...
web/app/components/datasets/hit-testing/index.tsx
View file @
0064daee
'use client'
import
React
,
{
useState
,
FC
,
useMemo
}
from
'react'
import
type
{
FC
}
from
'react'
import
React
,
{
useMemo
,
useState
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
useSWR
from
'swr'
import
{
fetchTestingRecords
}
from
'@/service/datasets'
import
{
omit
}
from
'lodash-es'
import
Pagination
from
'@/app/components/base/pagination'
import
Modal
from
'@/app/components/base/modal'
import
Loading
from
'@/app/components/base/loading'
import
type
{
HitTestingResponse
,
HitTesting
}
from
'@/models/datasets'
import
cn
from
'classnames'
import
dayjs
from
'dayjs'
import
SegmentCard
from
'../documents/detail/completed/SegmentCard'
...
...
@@ -15,8 +11,14 @@ import docStyle from '../documents/detail/completed/style.module.css'
import
Textarea
from
'./textarea'
import
s
from
'./style.module.css'
import
HitDetail
from
'./hit-detail'
import
type
{
HitTestingResponse
}
from
'@/models/datasets'
import
{
HitTesting
}
from
'@/models/datasets'
import
Loading
from
'@/app/components/base/loading'
import
Modal
from
'@/app/components/base/modal'
import
Pagination
from
'@/app/components/base/pagination'
import
{
fetchTestingRecords
}
from
'@/service/datasets'
const
limit
=
10
;
const
limit
=
10
type
Props
=
{
datasetId
:
string
...
...
@@ -32,23 +34,24 @@ const RecordsEmpty: FC = () => {
</
div
>
}
// eslint-disable-next-line @typescript-eslint/no-redeclare
const
HitTesting
:
FC
<
Props
>
=
({
datasetId
}:
Props
)
=>
{
const
{
t
}
=
useTranslation
()
const
[
hitResult
,
setHitResult
]
=
useState
<
HitTestingResponse
|
undefined
>
()
;
// 初始化记录为空数组
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
)
;
const
[
hitResult
,
setHitResult
]
=
useState
<
HitTestingResponse
|
undefined
>
()
// 初始化记录为空数组
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
)
const
[
currParagraph
,
setCurrParagraph
]
=
useState
<
{
paraInfo
?:
HitTesting
;
showModal
:
boolean
}
>
({
showModal
:
false
})
const
[
text
,
setText
]
=
useState
(
''
)
;
const
[
text
,
setText
]
=
useState
(
''
)
const
[
currPage
,
setCurrPage
]
=
React
.
useState
<
number
>
(
0
)
const
{
data
:
recordsRes
,
error
,
mutate
:
recordsMutate
}
=
useSWR
({
action
:
'fetchTestingRecords'
,
datasetId
,
params
:
{
limit
,
page
:
currPage
+
1
,
}
params
:
{
limit
,
page
:
currPage
+
1
},
},
apiParams
=>
fetchTestingRecords
(
omit
(
apiParams
,
'action'
)))
const
total
=
recordsRes
?.
total
||
0
const
points
=
useMemo
(()
=>
(
hitResult
?.
records
.
map
(
(
v
)
=>
[
v
.
tsne_position
.
x
,
v
.
tsne_position
.
y
])
||
[]),
[
hitResult
?.
records
])
const
points
=
useMemo
(()
=>
(
hitResult
?.
records
.
map
(
v
=>
[
v
.
tsne_position
.
x
,
v
.
tsne_position
.
y
])
||
[]),
[
hitResult
?.
records
])
const
onClickCard
=
(
detail
:
HitTesting
)
=>
{
setCurrParagraph
({
paraInfo
:
detail
,
showModal
:
true
})
...
...
@@ -71,50 +74,54 @@ const HitTesting: FC<Props> = ({ datasetId }: Props) => {
text=
{
text
}
/>
<
div
className=
{
cn
(
s
.
title
,
'mt-8 mb-2'
)
}
>
{
t
(
'datasetHitTesting.recents'
)
}
</
div
>
{
!
recordsRes
&&
!
error
?
(
<
div
className=
'flex-1'
><
Loading
type=
'app'
/></
div
>
)
:
recordsRes
?.
data
?.
length
?
(
<>
<
table
className=
{
`w-full border-collapse border-0 mt-3 ${s.table}`
}
>
<
thead
className=
"h-8 leading-8 border-b border-gray-200 text-gray-500 font-bold"
>
<
tr
>
<
td
className=
'w-28'
>
{
t
(
'datasetHitTesting.table.header.source'
)
}
</
td
>
<
td
>
{
t
(
'datasetHitTesting.table.header.text'
)
}
</
td
>
<
td
className=
'w-48'
>
{
t
(
'datasetHitTesting.table.header.time'
)
}
</
td
>
</
tr
>
</
thead
>
<
tbody
className=
"text-gray-500"
>
{
recordsRes
?.
data
?.
map
((
record
)
=>
{
return
<
tr
key=
{
record
.
id
}
className=
'group border-b border-gray-200 h-8 hover:bg-gray-50 cursor-pointer'
onClick=
{
()
=>
setText
(
record
.
content
)
}
>
<
td
className=
'w-24'
>
<
div
className=
'flex items-center'
>
<
div
className=
{
cn
(
s
[
`${record.source}_icon`
],
s
.
commonIcon
,
'mr-1'
)
}
/>
<
span
className=
'capitalize'
>
{
record
.
source
.
replace
(
'_'
,
' '
)
}
</
span
>
</
div
>
</
td
>
<
td
className=
'max-w-xs group-hover:text-primary-600'
>
{
record
.
content
}
</
td
>
<
td
className=
'w-36'
>
{
dayjs
.
unix
(
record
.
created_at
).
format
(
t
(
'datasetHitTesting.dateTimeFormat'
)
as
string
)
}
</
td
>
</
tr
>
})
}
</
tbody
>
</
table
>
{
(
total
&&
total
>
limit
)
?
<
Pagination
current=
{
currPage
}
onChange=
{
setCurrPage
}
total=
{
total
}
limit=
{
limit
}
/>
:
null
}
</>
)
:
(
<
RecordsEmpty
/>
)
}
{
(
!
recordsRes
&&
!
error
)
?
(
<
div
className=
'flex-1'
><
Loading
type=
'app'
/></
div
>
)
:
recordsRes
?.
data
?.
length
?
(
<>
<
table
className=
{
`w-full border-collapse border-0 mt-3 ${s.table}`
}
>
<
thead
className=
"h-8 leading-8 border-b border-gray-200 text-gray-500 font-bold"
>
<
tr
>
<
td
className=
'w-28'
>
{
t
(
'datasetHitTesting.table.header.source'
)
}
</
td
>
<
td
>
{
t
(
'datasetHitTesting.table.header.text'
)
}
</
td
>
<
td
className=
'w-48'
>
{
t
(
'datasetHitTesting.table.header.time'
)
}
</
td
>
</
tr
>
</
thead
>
<
tbody
className=
"text-gray-500"
>
{
recordsRes
?.
data
?.
map
((
record
)
=>
{
return
<
tr
key=
{
record
.
id
}
className=
'group border-b border-gray-200 h-8 hover:bg-gray-50 cursor-pointer'
onClick=
{
()
=>
setText
(
record
.
content
)
}
>
<
td
className=
'w-24'
>
<
div
className=
'flex items-center'
>
<
div
className=
{
cn
(
s
[
`${record.source}_icon`
],
s
.
commonIcon
,
'mr-1'
)
}
/>
<
span
className=
'capitalize'
>
{
record
.
source
.
replace
(
'_'
,
' '
)
}
</
span
>
</
div
>
</
td
>
<
td
className=
'max-w-xs group-hover:text-primary-600'
>
{
record
.
content
}
</
td
>
<
td
className=
'w-36'
>
{
dayjs
.
unix
(
record
.
created_at
).
format
(
t
(
'datasetHitTesting.dateTimeFormat'
)
as
string
)
}
</
td
>
</
tr
>
})
}
</
tbody
>
</
table
>
{
(
total
&&
total
>
limit
)
?
<
Pagination
current=
{
currPage
}
onChange=
{
setCurrPage
}
total=
{
total
}
limit=
{
limit
}
/>
:
null
}
</>
)
:
(
<
RecordsEmpty
/>
)
}
</
div
>
<
div
className=
{
s
.
rightDiv
}
>
{
submitLoading
?
<
div
className=
{
s
.
cardWrapper
}
>
{
submitLoading
?
<
div
className=
{
s
.
cardWrapper
}
>
<
SegmentCard
loading=
{
true
}
scene=
'hitTesting'
...
...
@@ -125,32 +132,36 @@ const HitTesting: FC<Props> = ({ datasetId }: Props) => {
scene=
'hitTesting'
className=
'h-[216px]'
/>
</
div
>
:
!
hitResult
?.
records
.
length
?
(
<
div
className=
'h-full flex flex-col justify-center items-center'
>
<
div
className=
{
cn
(
docStyle
.
commonIcon
,
docStyle
.
targetIcon
,
'!bg-gray-200 !h-14 !w-14'
)
}
/>
<
div
className=
'text-gray-300 text-[13px] mt-3'
>
{
t
(
'datasetHitTesting.hit.emptyTip'
)
}
</
div
>
</
div
>
)
:
(
<>
<
div
className=
'text-gray-600 font-semibold mb-4'
>
{
t
(
'datasetHitTesting.hit.title'
)
}
</
div
>
<
div
className=
'overflow-auto flex-1'
>
<
div
className=
{
s
.
cardWrapper
}
>
{
hitResult
?.
records
.
map
((
record
)
=>
{
return
<
SegmentCard
loading=
{
false
}
detail=
{
record
.
segment
as
any
}
score=
{
record
.
score
}
scene=
'hitTesting'
className=
'h-[216px] mb-4'
onClick=
{
()
=>
onClickCard
(
record
as
any
)
}
/>
})
}
</
div
>
:
!
hitResult
?.
records
.
length
?
(
<
div
className=
'h-full flex flex-col justify-center items-center'
>
<
div
className=
{
cn
(
docStyle
.
commonIcon
,
docStyle
.
targetIcon
,
'!bg-gray-200 !h-14 !w-14'
)
}
/>
<
div
className=
'text-gray-300 text-[13px] mt-3'
>
{
t
(
'datasetHitTesting.hit.emptyTip'
)
}
</
div
>
</
div
>
</>
)
)
:
(
<>
<
div
className=
'text-gray-600 font-semibold mb-4'
>
{
t
(
'datasetHitTesting.hit.title'
)
}
</
div
>
<
div
className=
'overflow-auto flex-1'
>
<
div
className=
{
s
.
cardWrapper
}
>
{
hitResult
?.
records
.
map
((
record
,
idx
)
=>
{
return
<
SegmentCard
key=
{
idx
}
loading=
{
false
}
detail=
{
record
.
segment
as
any
}
score=
{
record
.
score
}
scene=
'hitTesting'
className=
'h-[216px] mb-4'
onClick=
{
()
=>
onClickCard
(
record
as
any
)
}
/>
})
}
</
div
>
</
div
>
</>
)
}
</
div
>
<
Modal
...
...
web/i18n/lang/dataset-creation.en.ts
View file @
0064daee
...
...
@@ -23,7 +23,7 @@ const translation = {
title
:
'Upload text file'
,
button
:
'Drag and drop file, or'
,
browse
:
'Browse'
,
tip
:
'Supports txt, html, markdown, xlsx, and pdf. Max 1
0
MB each.'
,
tip
:
'Supports txt, html, markdown, xlsx, and pdf. Max 1
5
MB each.'
,
validation
:
{
typeError
:
'File type not supported'
,
size
:
'File too large. Maximum is 10MB'
,
...
...
web/i18n/lang/dataset-creation.zh.ts
View file @
0064daee
...
...
@@ -23,7 +23,7 @@ const translation = {
title
:
'上传文本文件'
,
button
:
'拖拽文件至此,或者'
,
browse
:
'选择文件'
,
tip
:
'已支持 TXT、 HTML、 Markdown、 PDF、 XLSX,每个文件不超过 1
0
MB。'
,
tip
:
'已支持 TXT、 HTML、 Markdown、 PDF、 XLSX,每个文件不超过 1
5
MB。'
,
validation
:
{
typeError
:
'文件类型不支持'
,
size
:
'文件太大了,不能超过 10MB'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment