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
291201db
Commit
291201db
authored
Feb 20, 2024
by
Joel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: llm use config
parent
c8ea6d7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
use-config.ts
web/app/components/workflow/nodes/llm/use-config.ts
+10
-10
No files found.
web/app/components/workflow/nodes/llm/use-config.ts
View file @
291201db
/* eslint-disable react-hooks/exhaustive-deps */
import
{
useCallback
,
useState
}
from
'react'
import
produce
from
'immer'
import
type
{
LLMNodeData
,
Variable
}
from
'../../types'
import
type
{
Variable
}
from
'../../types'
import
type
{
LLMNodeType
}
from
'./types'
const
use
Input
=
(
initInputs
:
LLMNodeData
)
=>
{
const
[
inputs
,
setInputs
]
=
useState
<
LLMNode
Data
>
(
initInputs
)
const
use
Config
=
(
initInputs
:
LLMNodeType
)
=>
{
const
[
inputs
,
setInputs
]
=
useState
<
LLMNode
Type
>
(
initInputs
)
// model
const
handleModelChanged
=
useCallback
((
model
:
{
provider
:
string
;
modelId
:
string
;
mode
?:
string
})
=>
{
...
...
@@ -14,14 +14,14 @@ const useInput = (initInputs: LLMNodeData) => {
draft
.
model
.
mode
=
model
.
mode
!
})
setInputs
(
newInputs
)
},
[
inputs
.
model
])
},
[
inputs
,
setInputs
])
const
handleCompletionParamsChange
=
useCallback
((
newParams
:
Record
<
string
,
any
>
)
=>
{
const
newInputs
=
produce
(
inputs
,
(
draft
)
=>
{
draft
.
model
.
completion_params
=
newParams
})
setInputs
(
newInputs
)
},
[
inputs
.
model
])
},
[
inputs
,
setInputs
])
// variables
const
handleVarListChange
=
useCallback
((
newList
:
Variable
[])
=>
{
...
...
@@ -29,7 +29,7 @@ const useInput = (initInputs: LLMNodeData) => {
draft
.
variables
=
newList
})
setInputs
(
newInputs
)
},
[
inputs
.
variable
s
])
},
[
inputs
,
setInput
s
])
const
handleAddVariable
=
useCallback
(()
=>
{
const
newInputs
=
produce
(
inputs
,
(
draft
)
=>
{
...
...
@@ -39,7 +39,7 @@ const useInput = (initInputs: LLMNodeData) => {
})
})
setInputs
(
newInputs
)
},
[
inputs
.
variable
s
])
},
[
inputs
,
setInput
s
])
// context
const
toggleContextEnabled
=
useCallback
(()
=>
{
...
...
@@ -47,7 +47,7 @@ const useInput = (initInputs: LLMNodeData) => {
draft
.
context
.
enabled
=
!
draft
.
context
.
enabled
})
setInputs
(
newInputs
)
},
[
inputs
.
context
.
enabled
])
},
[
inputs
,
setInputs
])
return
{
inputs
,
...
...
@@ -59,4 +59,4 @@ const useInput = (initInputs: LLMNodeData) => {
}
}
export
default
use
Input
export
default
use
Config
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