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
bed0a286
Commit
bed0a286
authored
Jul 12, 2023
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: gen res
parent
45437a51
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
30 deletions
+34
-30
index.tsx
web/app/components/share/text-generation/index.tsx
+23
-5
index.tsx
web/app/components/share/text-generation/result/index.tsx
+5
-5
index.tsx
...ts/share/text-generation/run-batch/res-download/index.tsx
+4
-20
share-app.en.ts
web/i18n/lang/share-app.en.ts
+1
-0
share-app.zh.ts
web/i18n/lang/share-app.zh.ts
+1
-0
No files found.
web/app/components/share/text-generation/index.tsx
View file @
bed0a286
...
@@ -103,6 +103,20 @@ const TextGeneration: FC<IMainProps> = ({
...
@@ -103,6 +103,20 @@ const TextGeneration: FC<IMainProps> = ({
const
noPendingTask
=
pendingTaskList
.
length
===
0
const
noPendingTask
=
pendingTaskList
.
length
===
0
const
showTaskList
=
allTaskList
.
filter
(
task
=>
task
.
status
!==
TaskStatus
.
pending
)
const
showTaskList
=
allTaskList
.
filter
(
task
=>
task
.
status
!==
TaskStatus
.
pending
)
const
allTaskFinished
=
allTaskList
.
every
(
task
=>
task
.
status
===
TaskStatus
.
completed
)
const
allTaskFinished
=
allTaskList
.
every
(
task
=>
task
.
status
===
TaskStatus
.
completed
)
const
[
batchCompletionRes
,
setBatchCompletionRes
,
getBatchCompletionRes
]
=
useGetState
<
Record
<
string
,
string
>>
({})
const
exportRes
=
allTaskList
.
map
((
task
)
=>
{
if
(
!
allTaskFinished
||
allTaskList
.
length
===
0
)
return
{}
const
batchCompletionResLatest
=
getBatchCompletionRes
()
const
res
:
Record
<
string
,
string
>
=
{}
const
{
inputs
,
query
}
=
task
.
params
promptConfig
?.
prompt_variables
.
forEach
((
v
)
=>
{
res
[
v
.
name
]
=
inputs
[
v
.
key
]
})
res
[
t
(
'share.generation.queryTitle'
)]
=
query
res
[
t
(
'share.generation.completionResult'
)]
=
batchCompletionResLatest
[
task
.
id
]
return
res
})
const
checkBatchInputs
=
(
data
:
string
[][])
=>
{
const
checkBatchInputs
=
(
data
:
string
[][])
=>
{
if
(
!
data
||
data
.
length
===
0
)
{
if
(
!
data
||
data
.
length
===
0
)
{
notify
({
type
:
'error'
,
message
:
t
(
'share.generation.errorMsg.empty'
)
})
notify
({
type
:
'error'
,
message
:
t
(
'share.generation.errorMsg.empty'
)
})
...
@@ -228,10 +242,9 @@ const TextGeneration: FC<IMainProps> = ({
...
@@ -228,10 +242,9 @@ const TextGeneration: FC<IMainProps> = ({
// clear run once task status
// clear run once task status
setControlStopResponding
(
Date
.
now
())
setControlStopResponding
(
Date
.
now
())
}
}
const
handleCompleted
=
(
completionRes
:
string
,
taskId
?:
number
)
=>
{
const
handleCompleted
=
(
taskId
?:
number
,
isSuccess
?:
boolean
)
=>
{
// console.log(taskId, isSuccess)
const
allTasklistLatest
=
getLatestTaskList
()
const
allTasklistLatest
=
getLatestTaskList
()
const
batchCompletionResLatest
=
getBatchCompletionRes
()
const
pendingTaskList
=
allTasklistLatest
.
filter
(
task
=>
task
.
status
===
TaskStatus
.
pending
)
const
pendingTaskList
=
allTasklistLatest
.
filter
(
task
=>
task
.
status
===
TaskStatus
.
pending
)
const
nextPendingTaskId
=
pendingTaskList
[
0
]?.
id
const
nextPendingTaskId
=
pendingTaskList
[
0
]?.
id
// console.log(`start: ${allTasklistLatest.map(item => item.status).join(',')}`)
// console.log(`start: ${allTasklistLatest.map(item => item.status).join(',')}`)
...
@@ -252,6 +265,12 @@ const TextGeneration: FC<IMainProps> = ({
...
@@ -252,6 +265,12 @@ const TextGeneration: FC<IMainProps> = ({
})
})
// console.log(`end: ${newAllTaskList.map(item => item.status).join(',')}`)
// console.log(`end: ${newAllTaskList.map(item => item.status).join(',')}`)
setAllTaskList
(
newAllTaskList
)
setAllTaskList
(
newAllTaskList
)
if
(
taskId
)
{
setBatchCompletionRes
({
...
batchCompletionResLatest
,
[
`
${
taskId
}
`
]:
completionRes
,
})
}
}
}
const
fetchInitData
=
async
()
=>
{
const
fetchInitData
=
async
()
=>
{
...
@@ -343,8 +362,7 @@ const TextGeneration: FC<IMainProps> = ({
...
@@ -343,8 +362,7 @@ const TextGeneration: FC<IMainProps> = ({
{
allTaskFinished
&&
(
{
allTaskFinished
&&
(
<
ResDownload
<
ResDownload
isMobile=
{
isMobile
}
isMobile=
{
isMobile
}
vars=
{
promptConfig
?.
prompt_variables
||
[]
}
values=
{
exportRes
}
values=
{
[[
'a'
,
'b'
,
'c'
]]
}
/>
/>
)
}
)
}
{
!
isPC
&&
(
{
!
isPC
&&
(
...
...
web/app/components/share/text-generation/result/index.tsx
View file @
bed0a286
'use client'
'use client'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
React
,
{
useEffect
,
useState
}
from
'react'
import
React
,
{
useEffect
,
useState
}
from
'react'
import
{
useBoolean
}
from
'ahooks'
import
{
useBoolean
,
useGetState
}
from
'ahooks'
import
{
t
}
from
'i18next'
import
{
t
}
from
'i18next'
import
cn
from
'classnames'
import
cn
from
'classnames'
import
TextGenerationRes
from
'@/app/components/app/text-generate/item'
import
TextGenerationRes
from
'@/app/components/app/text-generate/item'
...
@@ -27,7 +27,7 @@ export type IResultProps = {
...
@@ -27,7 +27,7 @@ export type IResultProps = {
onShowRes
:
()
=>
void
onShowRes
:
()
=>
void
handleSaveMessage
:
(
messageId
:
string
)
=>
void
handleSaveMessage
:
(
messageId
:
string
)
=>
void
taskId
?:
number
taskId
?:
number
onCompleted
:
(
taskId
?:
number
,
success
?:
boolean
)
=>
void
onCompleted
:
(
completionRes
:
string
,
taskId
?:
number
,
success
?:
boolean
)
=>
void
}
}
const
Result
:
FC
<
IResultProps
>
=
({
const
Result
:
FC
<
IResultProps
>
=
({
...
@@ -53,7 +53,7 @@ const Result: FC<IResultProps> = ({
...
@@ -53,7 +53,7 @@ const Result: FC<IResultProps> = ({
setResponsingFalse
()
setResponsingFalse
()
},
[
controlStopResponding
])
},
[
controlStopResponding
])
const
[
completionRes
,
setCompletionRes
]
=
use
State
(
''
)
const
[
completionRes
,
setCompletionRes
,
getCompletionRes
]
=
useGet
State
(
''
)
const
{
notify
}
=
Toast
const
{
notify
}
=
Toast
const
isNoData
=
!
completionRes
const
isNoData
=
!
completionRes
...
@@ -141,11 +141,11 @@ const Result: FC<IResultProps> = ({
...
@@ -141,11 +141,11 @@ const Result: FC<IResultProps> = ({
onCompleted
:
()
=>
{
onCompleted
:
()
=>
{
setResponsingFalse
()
setResponsingFalse
()
setMessageId
(
tempMessageId
)
setMessageId
(
tempMessageId
)
onCompleted
(
taskId
,
true
)
onCompleted
(
getCompletionRes
(),
taskId
,
true
)
},
},
onError
()
{
onError
()
{
setResponsingFalse
()
setResponsingFalse
()
onCompleted
(
taskId
,
false
)
onCompleted
(
getCompletionRes
(),
taskId
,
false
)
},
},
},
isInstalledApp
,
installedAppInfo
?.
id
)
},
isInstalledApp
,
installedAppInfo
?.
id
)
}
}
...
...
web/app/components/share/text-generation/run-batch/res-download/index.tsx
View file @
bed0a286
...
@@ -10,42 +10,26 @@ import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vend
...
@@ -10,42 +10,26 @@ import { Download02 as DownloadIcon } from '@/app/components/base/icons/src/vend
import
Button
from
'@/app/components/base/button'
import
Button
from
'@/app/components/base/button'
export
type
IResDownloadProps
=
{
export
type
IResDownloadProps
=
{
isMobile
:
boolean
isMobile
:
boolean
vars
:
{
name
:
string
}[]
values
:
Record
<
string
,
string
>
[]
values
:
string
[][]
}
}
const
ResDownload
:
FC
<
IResDownloadProps
>
=
({
const
ResDownload
:
FC
<
IResDownloadProps
>
=
({
isMobile
,
isMobile
,
vars
,
values
,
values
,
})
=>
{
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
CSVDownloader
,
Type
}
=
useCSVDownloader
()
const
{
CSVDownloader
,
Type
}
=
useCSVDownloader
()
const
addQueryContentVars
=
[
...
vars
,
{
name
:
t
(
'share.generation.queryTitle'
)
},
{
name
:
'Result'
},
]
const
headers
=
(()
=>
{
const
res
:
Record
<
string
,
string
>
=
{}
addQueryContentVars
.
forEach
((
item
)
=>
{
res
[
item
.
name
]
=
''
})
return
res
})()
return
(
return
(
<
CSVDownloader
<
CSVDownloader
className=
"block cursor-pointer"
className=
"block cursor-pointer"
type=
{
Type
.
Link
}
type=
{
Type
.
Link
}
filename=
{
'
template
'
}
filename=
{
'
result
'
}
bom=
{
true
}
bom=
{
true
}
config=
{
{
config=
{
{
// delimiter: ';',
// delimiter: ';',
}
}
}
}
data=
{
[
data=
{
values
}
headers
,
...
values
,
]
}
>
>
<
Button
className=
{
cn
(
'flex items-center !h-8 space-x-2 bg-white !text-[13px] font-medium'
,
isMobile
?
'!p-0 !w-8 justify-center'
:
'!px-3'
)
}
>
<
Button
className=
{
cn
(
'flex items-center !h-8 space-x-2 bg-white !text-[13px] font-medium'
,
isMobile
?
'!p-0 !w-8 justify-center'
:
'!px-3'
)
}
>
<
DownloadIcon
className=
'w-4 h-4 text-[#155EEF]'
/>
<
DownloadIcon
className=
'w-4 h-4 text-[#155EEF]'
/>
...
...
web/i18n/lang/share-app.en.ts
View file @
bed0a286
...
@@ -41,6 +41,7 @@ const translation = {
...
@@ -41,6 +41,7 @@ const translation = {
},
},
title
:
'AI Completion'
,
title
:
'AI Completion'
,
queryTitle
:
'Query content'
,
queryTitle
:
'Query content'
,
completionResult
:
'Completion result'
,
queryPlaceholder
:
'Write your query content...'
,
queryPlaceholder
:
'Write your query content...'
,
run
:
'Execute'
,
run
:
'Execute'
,
copy
:
'Copy'
,
copy
:
'Copy'
,
...
...
web/i18n/lang/share-app.zh.ts
View file @
bed0a286
...
@@ -37,6 +37,7 @@ const translation = {
...
@@ -37,6 +37,7 @@ const translation = {
},
},
title
:
'AI 智能书写'
,
title
:
'AI 智能书写'
,
queryTitle
:
'查询内容'
,
queryTitle
:
'查询内容'
,
completionResult
:
'生成结果'
,
queryPlaceholder
:
'请输入文本内容'
,
queryPlaceholder
:
'请输入文本内容'
,
run
:
'运行'
,
run
:
'运行'
,
copy
:
'拷贝'
,
copy
:
'拷贝'
,
...
...
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