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
0529c3d5
Commit
0529c3d5
authored
Mar 06, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add role tooltip and fix add prompt error
parent
5a27a95f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
6 deletions
+25
-6
editor.tsx
...ponents/workflow/nodes/_base/components/prompt/editor.tsx
+1
-1
selector.tsx
...p/components/workflow/nodes/_base/components/selector.tsx
+3
-1
config-prompt.tsx
...omponents/workflow/nodes/llm/components/config-prompt.tsx
+19
-4
workflow.ts
web/i18n/en-US/workflow.ts
+1
-0
workflow.ts
web/i18n/zh-Hans/workflow.ts
+1
-0
No files found.
web/app/components/workflow/nodes/_base/components/prompt/editor.tsx
View file @
0529c3d5
...
@@ -56,7 +56,7 @@ const Editor: FC<Props> = ({
...
@@ -56,7 +56,7 @@ const Editor: FC<Props> = ({
return
(
return
(
<
div
className=
{
cn
(
wrapClassName
)
}
>
<
div
className=
{
cn
(
wrapClassName
)
}
>
<
div
ref=
{
ref
}
className=
{
cn
(
isFocus
&&
s
.
gradientBorder
,
isExpand
&&
'h-full'
,
'!rounded-[9px]
shadow-md
'
)
}
>
<
div
ref=
{
ref
}
className=
{
cn
(
isFocus
&&
s
.
gradientBorder
,
isExpand
&&
'h-full'
,
'!rounded-[9px]'
)
}
>
<
div
className=
{
cn
(
isFocus
?
'bg-white'
:
'bg-gray-100'
,
isExpand
&&
'h-full flex flex-col'
,
'rounded-lg'
)
}
>
<
div
className=
{
cn
(
isFocus
?
'bg-white'
:
'bg-gray-100'
,
isExpand
&&
'h-full flex flex-col'
,
'rounded-lg'
)
}
>
<
div
className=
'pt-1 pl-3 pr-2 flex justify-between h-6 items-center'
>
<
div
className=
'pt-1 pl-3 pr-2 flex justify-between h-6 items-center'
>
<
div
className=
'leading-4 text-xs font-semibold text-gray-700 uppercase'
>
{
title
}
</
div
>
<
div
className=
'leading-4 text-xs font-semibold text-gray-700 uppercase'
>
{
title
}
</
div
>
...
...
web/app/components/workflow/nodes/_base/components/selector.tsx
View file @
0529c3d5
...
@@ -16,6 +16,7 @@ type Props = {
...
@@ -16,6 +16,7 @@ type Props = {
onChange
:
(
value
:
any
)
=>
void
onChange
:
(
value
:
any
)
=>
void
uppercase
?:
boolean
uppercase
?:
boolean
popupClassName
?:
string
popupClassName
?:
string
triggerClassName
?:
string
itemClassName
?:
string
itemClassName
?:
string
readonly
?:
boolean
readonly
?:
boolean
showChecked
?:
boolean
showChecked
?:
boolean
...
@@ -27,6 +28,7 @@ const TypeSelector: FC<Props> = ({
...
@@ -27,6 +28,7 @@ const TypeSelector: FC<Props> = ({
value
,
value
,
onChange
,
onChange
,
uppercase
,
uppercase
,
triggerClassName
,
popupClassName
,
popupClassName
,
itemClassName
,
itemClassName
,
readonly
,
readonly
,
...
@@ -52,7 +54,7 @@ const TypeSelector: FC<Props> = ({
...
@@ -52,7 +54,7 @@ const TypeSelector: FC<Props> = ({
<
div
<
div
onClick=
{
toggleShow
}
onClick=
{
toggleShow
}
className=
{
cn
(
showOption
&&
'bg-black/5'
,
'flex items-center h-5 pl-1 pr-0.5 rounded-md text-xs font-semibold text-gray-700 cursor-pointer hover:bg-black/5'
)
}
>
className=
{
cn
(
showOption
&&
'bg-black/5'
,
'flex items-center h-5 pl-1 pr-0.5 rounded-md text-xs font-semibold text-gray-700 cursor-pointer hover:bg-black/5'
)
}
>
<
div
className=
{
cn
(
'text-sm font-semibold'
,
uppercase
&&
'uppercase'
)
}
>
{
item
?.
label
}
</
div
>
<
div
className=
{
cn
(
triggerClassName
,
'text-sm font-semibold'
,
uppercase
&&
'uppercase'
)
}
>
{
item
?.
label
}
</
div
>
<
ChevronSelectorVertical
className=
'w-3 h-3 '
/>
<
ChevronSelectorVertical
className=
'w-3 h-3 '
/>
</
div
>
</
div
>
)
}
)
}
...
...
web/app/components/workflow/nodes/llm/components/config-prompt.tsx
View file @
0529c3d5
...
@@ -8,6 +8,8 @@ import { PromptRole } from '../../../types'
...
@@ -8,6 +8,8 @@ import { PromptRole } from '../../../types'
import
Editor
from
'@/app/components/workflow/nodes/_base/components/prompt/editor'
import
Editor
from
'@/app/components/workflow/nodes/_base/components/prompt/editor'
import
AddButton
from
'@/app/components/workflow/nodes/_base/components/add-button'
import
AddButton
from
'@/app/components/workflow/nodes/_base/components/add-button'
import
TypeSelector
from
'@/app/components/workflow/nodes/_base/components/selector'
import
TypeSelector
from
'@/app/components/workflow/nodes/_base/components/selector'
import
TooltipPlus
from
'@/app/components/base/tooltip-plus'
import
{
HelpCircle
}
from
'@/app/components/base/icons/src/vender/line/general'
const
i18nPrefix
=
'workflow.nodes.llm'
const
i18nPrefix
=
'workflow.nodes.llm'
...
@@ -38,13 +40,17 @@ const ConfigPrompt: FC<Props> = ({
...
@@ -38,13 +40,17 @@ const ConfigPrompt: FC<Props> = ({
},
[
onChange
,
payload
])
},
[
onChange
,
payload
])
const
roleOptions
=
[
const
roleOptions
=
[
{
label
:
'system'
,
value
:
PromptRole
.
system
,
},
{
{
label
:
'user'
,
label
:
'user'
,
value
:
PromptRole
.
user
,
value
:
PromptRole
.
user
,
},
},
{
{
label
:
'
system
'
,
label
:
'
assistant
'
,
value
:
PromptRole
.
system
,
value
:
PromptRole
.
assistant
,
},
},
]
]
...
@@ -60,7 +66,7 @@ const ConfigPrompt: FC<Props> = ({
...
@@ -60,7 +66,7 @@ const ConfigPrompt: FC<Props> = ({
const
handleAddPrompt
=
useCallback
(()
=>
{
const
handleAddPrompt
=
useCallback
(()
=>
{
const
newPrompt
=
produce
(
payload
as
PromptItem
[],
(
draft
)
=>
{
const
newPrompt
=
produce
(
payload
as
PromptItem
[],
(
draft
)
=>
{
const
isLastItemUser
=
draft
[
draft
.
length
-
1
].
role
===
PromptRole
.
user
const
isLastItemUser
=
draft
[
draft
.
length
-
1
].
role
===
PromptRole
.
user
draft
.
push
({
role
:
isLastItemUser
?
PromptRole
.
system
:
PromptRole
.
user
,
text
:
''
})
draft
.
push
({
role
:
isLastItemUser
?
PromptRole
.
assistant
:
PromptRole
.
user
,
text
:
''
})
})
})
onChange
(
newPrompt
)
onChange
(
newPrompt
)
},
[
onChange
,
payload
])
},
[
onChange
,
payload
])
...
@@ -93,12 +99,21 @@ const ConfigPrompt: FC<Props> = ({
...
@@ -93,12 +99,21 @@ const ConfigPrompt: FC<Props> = ({
<
Editor
<
Editor
key=
{
index
}
key=
{
index
}
title=
{
title=
{
<
div
className=
'relative left-1'
>
<
div
className=
'relative left-1
flex items-center
'
>
<
TypeSelector
<
TypeSelector
value=
{
item
.
role
as
string
}
value=
{
item
.
role
as
string
}
options=
{
roleOptions
}
options=
{
roleOptions
}
onChange=
{
handleChatModeMessageRoleChange
(
index
)
}
onChange=
{
handleChatModeMessageRoleChange
(
index
)
}
triggerClassName=
'text-xs font-semibold text-gray-700 uppercase'
itemClassName=
'text-[13px] font-medium text-gray-700'
/>
/>
<
TooltipPlus
popupContent=
{
<
div
>
{
t
(
`${i18nPrefix}.roleDescription`
)
}
</
div
>
}
>
<
HelpCircle
className=
'w-3.5 h-3.5 text-gray-400'
/>
</
TooltipPlus
>
</
div
>
</
div
>
}
}
value=
{
item
.
text
}
value=
{
item
.
text
}
...
...
web/i18n/en-US/workflow.ts
View file @
0529c3d5
...
@@ -97,6 +97,7 @@ const translation = {
...
@@ -97,6 +97,7 @@ const translation = {
context
:
'context'
,
context
:
'context'
,
contextTooltip
:
'You can import Knowledge as context'
,
contextTooltip
:
'You can import Knowledge as context'
,
prompt
:
'prompt'
,
prompt
:
'prompt'
,
roleDescription
:
'TODO: Role Description'
,
addMessage
:
'Add Message'
,
addMessage
:
'Add Message'
,
vision
:
'vision'
,
vision
:
'vision'
,
resolution
:
{
resolution
:
{
...
...
web/i18n/zh-Hans/workflow.ts
View file @
0529c3d5
...
@@ -98,6 +98,7 @@ const translation = {
...
@@ -98,6 +98,7 @@ const translation = {
contextTooltip
:
'您可以导入知识库作为上下文'
,
contextTooltip
:
'您可以导入知识库作为上下文'
,
prompt
:
'提示词'
,
prompt
:
'提示词'
,
addMessage
:
'添加消息'
,
addMessage
:
'添加消息'
,
roleDescription
:
'TODO: Role Description'
,
vision
:
'视觉'
,
vision
:
'视觉'
,
resolution
:
{
resolution
:
{
name
:
'分辨率'
,
name
:
'分辨率'
,
...
...
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