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
bf0f71c8
Commit
bf0f71c8
authored
Jul 24, 2023
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
application config prompt preview user input field collapse
parent
635f2973
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
41 deletions
+9
-41
index.tsx
...components/app/configuration/prompt-value-panel/index.tsx
+9
-41
No files found.
web/app/components/app/configuration/prompt-value-panel/index.tsx
View file @
bf0f71c8
'use client'
'use client'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
import
React
,
{
Fragment
,
useState
}
from
'react'
import
React
,
{
useState
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
import
{
useContext
}
from
'use-context-selector'
import
{
useContext
}
from
'use-context-selector'
import
{
import
{
PlayIcon
,
PlayIcon
,
}
from
'@heroicons/react/24/solid'
}
from
'@heroicons/react/24/solid'
import
{
Transition
}
from
'@headlessui/react'
import
VarIcon
from
'../base/icons/var-icon'
import
VarIcon
from
'../base/icons/var-icon'
import
ConfigContext
from
'@/context/debug-configuration'
import
ConfigContext
from
'@/context/debug-configuration'
import
type
{
PromptVariable
}
from
'@/models/debug'
import
type
{
PromptVariable
}
from
'@/models/debug'
...
@@ -67,7 +66,7 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
...
@@ -67,7 +66,7 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
}
}
const
promptPreview
=
(
const
promptPreview
=
(
<
div
className=
'p
t-3 pb-4
rounded-t-xl bg-indigo-25'
>
<
div
className=
'p
y-3
rounded-t-xl bg-indigo-25'
>
<
div
className=
"px-4"
>
<
div
className=
"px-4"
>
<
div
className=
"flex items-center space-x-1 cursor-pointer"
onClick=
{
()
=>
setPromptPreviewCollapse
(
!
promptPreviewCollapse
)
}
>
<
div
className=
"flex items-center space-x-1 cursor-pointer"
onClick=
{
()
=>
setPromptPreviewCollapse
(
!
promptPreviewCollapse
)
}
>
{
starIcon
}
{
starIcon
}
...
@@ -78,36 +77,7 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
...
@@ -78,36 +77,7 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
:
<
ChevronDown
className=
'w-3 h-3 text-gray-700'
/>
:
<
ChevronDown
className=
'w-3 h-3 text-gray-700'
/>
}
}
</
div
>
</
div
>
<
Transition
as=
{
Fragment
}
appear=
{
true
}
show=
{
!
promptPreviewCollapse
}
enter=
"transition-[max-height] duration-[10s]"
enterFrom=
"max-h-0"
enterTo=
"max-h-[9999px]"
leave=
"transition-[max-height] duration-[10s]"
leaveFrom=
"max-h-[9999px]"
leaveTo=
"max-h-0"
>
<
div
className=
'mt-2 leading-normal overflow-hidden'
>
{
{
(
promptTemplate
&&
promptTemplate
?.
trim
())
?
(
<
div
className=
"max-h-48 overflow-y-auto text-sm text-gray-700 break-all"
dangerouslySetInnerHTML=
{
{
__html
:
format
(
replaceStringWithValuesWithFormat
(
promptTemplate
.
replace
(
/</g
,
'<'
).
replace
(
/>/g
,
'>'
),
promptVariables
,
inputs
)),
}
}
>
</
div
>
)
:
(
<
div
className=
'text-xs text-gray-500'
>
{
t
(
'appDebug.inputs.noPrompt'
)
}
</
div
>
)
}
</
div
>
</
Transition
>
{
/* {
!
promptPreviewCollapse
&&
(
!
promptPreviewCollapse
&&
(
<
div
className=
'mt-2 leading-normal'
>
<
div
className=
'mt-2 leading-normal'
>
{
{
...
@@ -127,26 +97,24 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
...
@@ -127,26 +97,24 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
}
}
</
div
>
</
div
>
)
)
}
*/
}
}
</
div
>
</
div
>
</
div
>
</
div
>
)
)
return
(
return
(
<
div
className=
"pb-
5
border border-gray-200 bg-white rounded-xl"
style=
{
{
<
div
className=
"pb-
3
border border-gray-200 bg-white rounded-xl"
style=
{
{
boxShadow
:
'0px 4px 8px -2px rgba(16, 24, 40, 0.1), 0px 2px 4px -2px rgba(16, 24, 40, 0.06)'
,
boxShadow
:
'0px 4px 8px -2px rgba(16, 24, 40, 0.1), 0px 2px 4px -2px rgba(16, 24, 40, 0.06)'
,
}
}
>
}
}
>
{
promptPreview
}
{
promptPreview
}
<
div
className=
{
'mt-3 px-4 bg-white'
}
>
<
div
className=
{
<
div
className=
{
`${userInputFieldCollapse ? 'mt-3' : 'mt-4'} px-4 bg-white`
`${!userInputFieldCollapse && 'mb-2'}`
}
>
<
div
className=
{
`${!userInputFieldCollapse && 'mb-4'}`
}
>
}
>
<
div
className=
'flex items-center space-x-1 cursor-pointer'
onClick=
{
()
=>
setUserInputFieldCollapse
(
!
userInputFieldCollapse
)
}
>
<
div
className=
'flex items-center space-x-1 cursor-pointer'
onClick=
{
()
=>
setUserInputFieldCollapse
(
!
userInputFieldCollapse
)
}
>
<
div
className=
'flex items-center justify-center w-4 h-4'
><
VarIcon
/></
div
>
<
div
className=
'flex items-center justify-center w-4 h-4'
><
VarIcon
/></
div
>
<
div
className=
'text-
sm font-semibold
text-gray-800'
>
{
t
(
'appDebug.inputs.userInputField'
)
}
</
div
>
<
div
className=
'text-
xs font-medium
text-gray-800'
>
{
t
(
'appDebug.inputs.userInputField'
)
}
</
div
>
{
{
userInputFieldCollapse
userInputFieldCollapse
?
<
ChevronRight
className=
'w-3 h-3 text-gray-700'
/>
?
<
ChevronRight
className=
'w-3 h-3 text-gray-700'
/>
...
@@ -206,7 +174,7 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
...
@@ -206,7 +174,7 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
{
{
appType
===
AppType
.
completion
&&
(
appType
===
AppType
.
completion
&&
(
<
div
className=
'px-4'
>
<
div
className=
'px-4'
>
<
div
className=
"mt-
5
border-b border-gray-100"
></
div
>
<
div
className=
"mt-
3
border-b border-gray-100"
></
div
>
<
div
className=
"mt-4"
>
<
div
className=
"mt-4"
>
<
div
>
<
div
>
<
div
className=
"text-[13px] text-gray-900 font-medium"
>
{
t
(
'appDebug.inputs.queryTitle'
)
}
</
div
>
<
div
className=
"text-[13px] text-gray-900 font-medium"
>
{
t
(
'appDebug.inputs.queryTitle'
)
}
</
div
>
...
...
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