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
516036cc
Commit
516036cc
authored
Jun 29, 2023
by
StyleZhang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'main' into feat/refact-common-layout
parents
c70168bb
c6ab7eeb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
10 deletions
+44
-10
prompts.py
api/core/prompt/prompts.py
+4
-4
index.tsx
...app/components/app/configuration/dataset-config/index.tsx
+19
-2
index.tsx
...app/configuration/dataset-config/select-dataset/index.tsx
+15
-2
index.tsx
web/app/components/explore/item-operation/index.tsx
+2
-2
style.module.css
web/app/components/explore/item-operation/style.module.css
+4
-0
No files found.
api/core/prompt/prompts.py
View file @
516036cc
CONVERSATION_TITLE_PROMPT
=
(
"Human:{query}
\n
-----
\n
"
"Help me summarize the intent of what the human said and provide a title, the title should not exceed 20 words.
\n
"
"If
the human said is conducted in Chinese, you should return a Chinese
title.
\n
"
"If
the human said is conducted in English, you should return an English
title.
\n
"
"If
what the human said is conducted in English, you should only return an English
title.
\n
"
"If
what the human said is conducted in Chinese, you should only return a Chinese
title.
\n
"
"title:"
)
CONVERSATION_SUMMARY_PROMPT
=
(
"Please generate a short summary of the following conversation.
\n
"
"If the
conversation communicating in Chinese, you should return a Chinese
summary.
\n
"
"If the
conversation communicating in English, you should return an English
summary.
\n
"
"If the
following conversation communicating in English, you should only return an English
summary.
\n
"
"If the
following conversation communicating in Chinese, you should only return a Chinese
summary.
\n
"
"[Conversation Start]
\n
"
"{context}
\n
"
"[Conversation End]
\n\n
"
...
...
web/app/components/app/configuration/dataset-config/index.tsx
View file @
516036cc
...
...
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next'
import
{
useContext
}
from
'use-context-selector'
import
{
useBoolean
}
from
'ahooks'
import
{
isEqual
}
from
'lodash-es'
import
produce
from
'immer'
import
FeaturePanel
from
'../base/feature-panel'
import
OperationBtn
from
'../base/operation-btn'
import
CardItem
from
'./card-item'
...
...
@@ -31,11 +32,27 @@ const DatasetConfig: FC = () => {
const
hasData
=
dataSet
.
length
>
0
const
[
isShowSelectDataSet
,
{
setTrue
:
showSelectDataSet
,
setFalse
:
hideSelectDataSet
}]
=
useBoolean
(
false
)
const
handleSelect
=
(
data
:
DataSet
[])
=>
{
if
(
isEqual
(
data
,
dataSet
))
if
(
isEqual
(
data
.
map
(
item
=>
item
.
id
),
dataSet
.
map
(
item
=>
item
.
id
)))
{
hideSelectDataSet
()
return
}
setFormattingChanged
(
true
)
setDataSet
(
data
)
if
(
data
.
find
(
item
=>
!
item
.
name
))
{
// has not loaded selected dataset
const
newSelected
=
produce
(
data
,
(
draft
)
=>
{
data
.
forEach
((
item
,
index
)
=>
{
if
(
!
item
.
name
)
{
// not fetched database
const
newItem
=
dataSet
.
find
(
i
=>
i
.
id
===
item
.
id
)
if
(
newItem
)
draft
[
index
]
=
newItem
}
})
})
setDataSet
(
newSelected
)
}
else
{
setDataSet
(
data
)
}
hideSelectDataSet
()
}
const
onRemove
=
(
id
:
string
)
=>
{
...
...
web/app/components/app/configuration/dataset-config/select-dataset/index.tsx
View file @
516036cc
...
...
@@ -5,6 +5,7 @@ import { useGetState, useInfiniteScroll } from 'ahooks'
import
cn
from
'classnames'
import
{
useTranslation
}
from
'react-i18next'
import
Link
from
'next/link'
import
produce
from
'immer'
import
TypeIcon
from
'../type-icon'
import
s
from
'./style.module.css'
import
Modal
from
'@/app/components/base/modal'
...
...
@@ -28,7 +29,7 @@ const SelectDataSet: FC<ISelectDataSetProps> = ({
onSelect
,
})
=>
{
const
{
t
}
=
useTranslation
()
const
[
selected
,
setSelected
]
=
React
.
useState
<
DataSet
[]
>
(
[]
)
const
[
selected
,
setSelected
]
=
React
.
useState
<
DataSet
[]
>
(
selectedIds
.
map
(
id
=>
({
id
})
as
any
)
)
const
[
loaded
,
setLoaded
]
=
React
.
useState
(
false
)
const
[
datasets
,
setDataSets
]
=
React
.
useState
<
DataSet
[]
|
null
>
(
null
)
const
hasNoData
=
!
datasets
||
datasets
?.
length
===
0
...
...
@@ -47,7 +48,19 @@ const SelectDataSet: FC<ISelectDataSetProps> = ({
const
newList
=
[...(
datasets
||
[]),
...
data
]
setDataSets
(
newList
)
setLoaded
(
true
)
setSelected
(
newList
.
filter
(
item
=>
selectedIds
.
includes
(
item
.
id
)))
if
(
!
selected
.
find
(
item
=>
!
item
.
name
))
return
{
list
:
[]
}
const
newSelected
=
produce
(
selected
,
(
draft
)
=>
{
selected
.
forEach
((
item
,
index
)
=>
{
if
(
!
item
.
name
)
{
// not fetched database
const
newItem
=
newList
.
find
(
i
=>
i
.
id
===
item
.
id
)
if
(
newItem
)
draft
[
index
]
=
newItem
}
})
})
setSelected
(
newSelected
)
}
return
{
list
:
[]
}
},
...
...
web/app/components/explore/item-operation/index.tsx
View file @
516036cc
...
...
@@ -43,8 +43,8 @@ const ItemOperation: FC<IItemOperationProps> = ({
</
div
>
{
isShowDelete
&&
(
<
div
className=
{
cn
(
s
.
actionItem
,
s
.
deleteActionItem
,
'hover:bg-gray-50 group'
)
}
onClick=
{
onDelete
}
>
<
TrashIcon
className=
{
'shrink-0 w-4 h-4 stroke-current text-gray-500 stroke-2 group-hover:text-red-500'
}
/>
<
span
className=
{
cn
(
s
.
actionName
,
'group-hover:text-red-500'
)
}
>
{
t
(
'explore.sidebar.action.delete'
)
}
</
span
>
<
TrashIcon
className=
{
cn
(
s
.
deleteActionItemChild
,
'shrink-0 w-4 h-4 stroke-current text-gray-500 stroke-2'
)
}
/>
<
span
className=
{
cn
(
s
.
actionName
,
s
.
deleteActionItemChild
)
}
>
{
t
(
'explore.sidebar.action.delete'
)
}
</
span
>
</
div
>
)
}
...
...
web/app/components/explore/item-operation/style.module.css
View file @
516036cc
...
...
@@ -28,4 +28,8 @@ body .btn {
body
.btn
:hover
{
/* background-image: ; */
background-color
:
#F2F4F7
;
}
.deleteActionItem
:hover
.deleteActionItemChild
{
@apply
text-red-500;
}
\ No newline at end of file
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