Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Transformerlab App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
TransformerLab
Transformerlab App
Commits
64bee1c4
Commit
64bee1c4
authored
1 month ago
by
deep1401
Browse files
Options
Downloads
Patches
Plain Diff
Elevate selectedDocs to parent component to maintain state and avoid and reloading
parent
b366c18b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/renderer/components/Experiment/Generate/GenerateModal.tsx
+8
-1
8 additions, 1 deletion
...renderer/components/Experiment/Generate/GenerateModal.tsx
src/renderer/components/Experiment/Rag/PickADocumentMenu.tsx
+6
-6
6 additions, 6 deletions
src/renderer/components/Experiment/Rag/PickADocumentMenu.tsx
with
14 additions
and
7 deletions
src/renderer/components/Experiment/Generate/GenerateModal.tsx
+
8
−
1
View file @
64bee1c4
...
...
@@ -71,6 +71,7 @@ export default function GenerateModal({
const
[
hasDatasetKey
,
setHasDatasetKey
]
=
useState
(
false
);
const
[
hasDocumentsKey
,
setHasDocumentsKey
]
=
useState
(
false
);
const
[
hasContextKey
,
setHasContextKey
]
=
useState
(
false
);
const
[
selectedDocs
,
setSelectedDocs
]
=
useState
([]);
const
[
nameInput
,
setNameInput
]
=
useState
(
''
);
const
[
currentTab
,
setCurrentTab
]
=
useState
(
0
);
const
[
contextInput
,
setContextInput
]
=
useState
(
''
);
...
...
@@ -185,6 +186,8 @@ export default function GenerateModal({
if
(
!
nameInput
&&
evalConfig
?.
name
.
length
>
0
)
{
setNameInput
(
evalConfig
.
name
);
}
config
.
docs
?
setSelectedDocs
(
config
.
docs
)
:
[];
}
// if (nameInput !== '' && evalConfig?.name) {
// setNameInput(evalConfig?.name);
...
...
@@ -204,6 +207,7 @@ export default function GenerateModal({
try
{
parsedData
=
JSON
.
parse
(
data
);
//Parsing data for easy access to parameters}
// Set config as a JSON object with keys of the parameters and values of the default values
setSelectedDocs
([]);
let
tempconfig
:
{
[
key
:
string
]:
any
}
=
{};
if
(
parsedData
&&
parsedData
.
parameters
)
{
tempconfig
=
Object
.
fromEntries
(
...
...
@@ -328,7 +332,9 @@ export default function GenerateModal({
<
PickADocumentMenu
experimentInfo
=
{
experimentInfo
}
showFoldersOnly
=
{
false
}
defaultValue
=
{
config
.
docs
?
config
.
docs
:
[]
}
selected
=
{
selectedDocs
}
onChange
=
{
setSelectedDocs
}
// defaultValue={config.docs? config.docs : []}
name
=
"docs"
/>
<
FormHelperText
>
Select documents to upload
</
FormHelperText
>
...
...
@@ -337,6 +343,7 @@ export default function GenerateModal({
);
}
function
ContextTab
({
contextInput
,
setContextInput
})
{
return
(
<
Stack
spacing
=
{
2
}
>
...
...
This diff is collapsed.
Click to expand it.
src/renderer/components/Experiment/Rag/PickADocumentMenu.tsx
+
6
−
6
View file @
64bee1c4
...
...
@@ -7,7 +7,8 @@ const fetcher = (url) => fetch(url).then((res) => res.json());
export
default
function
PickADocumentMenu
({
name
,
experimentInfo
,
defaultValue
=
[],
selected
,
onChange
,
showFoldersOnly
=
false
,
})
{
const
{
...
...
@@ -16,16 +17,15 @@ export default function PickADocumentMenu({
mutate
,
}
=
useSWR
(
chatAPI
.
Endpoints
.
Documents
.
List
(
experimentInfo
?.
id
,
''
),
fetcher
);
const
[
selected
,
setSelected
]
=
useState
([]);
useEffect
(()
=>
{
setSelected
(
defaultValue
||
[]);
},
[
defaultValue
]);
//
useEffect(() => {
//
setSelected(defaultValue || []);
//
}, [defaultValue]);
function
handleChange
(
event
,
newValue
)
{
console
.
log
(
newValue
);
setSelected
(
newValue
);
onChange
(
newValue
);
}
return
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment