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
60d57951
Commit
60d57951
authored
2 weeks ago
by
ali asaria
Browse files
Options
Downloads
Patches
Plain Diff
show a->z in model store vs z->a as default
parent
ba0aab35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/renderer/components/ModelZoo/ModelStore.tsx
+20
-19
20 additions, 19 deletions
src/renderer/components/ModelZoo/ModelStore.tsx
with
20 additions
and
19 deletions
src/renderer/components/ModelZoo/ModelStore.tsx
+
20
−
19
View file @
60d57951
...
...
@@ -20,6 +20,7 @@ import {
import
{
ArrowDownIcon
,
CheckIcon
,
ChevronDownIcon
,
CreativeCommonsIcon
,
DownloadIcon
,
ExternalLinkIcon
,
...
...
@@ -59,10 +60,10 @@ type Order = 'asc' | 'desc';
function
getComparator
<
Key
extends
keyof
any
>
(
order
:
Order
,
orderBy
:
Key
orderBy
:
Key
,
):
(
a
:
{
[
key
in
Key
]:
number
|
string
},
b
:
{
[
key
in
Key
]:
number
|
string
}
b
:
{
[
key
in
Key
]:
number
|
string
}
,
)
=>
number
{
return
order
===
'
desc
'
?
(
a
,
b
)
=>
descendingComparator
(
a
,
b
,
orderBy
)
...
...
@@ -75,7 +76,7 @@ function getComparator<Key extends keyof any>(
// with exampleArray.slice().sort(exampleComparator)
function
stableSort
<
T
>
(
array
:
readonly
T
[],
comparator
:
(
a
:
T
,
b
:
T
)
=>
number
comparator
:
(
a
:
T
,
b
:
T
)
=>
number
,
)
{
const
stabilizedThis
=
array
.
map
((
el
,
index
)
=>
[
el
,
index
]
as
[
T
,
number
]);
stabilizedThis
.
sort
((
a
,
b
)
=>
{
...
...
@@ -97,7 +98,7 @@ function getModelHuggingFaceURL(model) {
const
fetcher
=
(
url
)
=>
fetch
(
url
).
then
((
res
)
=>
res
.
json
());
export
default
function
ModelStore
()
{
const
[
order
,
setOrder
]
=
useState
<
Order
>
(
'
de
sc
'
);
const
[
order
,
setOrder
]
=
useState
<
Order
>
(
'
a
sc
'
);
// jobId is null if there is no current download in progress,
// and it is -1 if a download has been initiated but it hasn't started yet
const
[
jobId
,
setJobId
]
=
useState
(
null
);
...
...
@@ -118,7 +119,7 @@ export default function ModelStore() {
const
{
data
:
modelDownloadProgress
}
=
useSWR
(
jobId
&&
jobId
!=
'
-1
'
?
chatAPI
.
Endpoints
.
Jobs
.
Get
(
jobId
)
:
null
,
fetcher
,
{
refreshInterval
:
2000
}
{
refreshInterval
:
2000
}
,
);
// Creating a separate object to get useEffect for download jobs to work
...
...
@@ -128,12 +129,12 @@ export default function ModelStore() {
// check if we have a Hugging Face access token
const
{
data
:
hftoken
}
=
useSWR
(
chatAPI
.
Endpoints
.
Config
.
Get
(
'
HuggingfaceUserAccessToken
'
),
fetcher
fetcher
,
);
const
{
data
:
canLogInToHuggingFace
}
=
useSWR
(
chatAPI
.
Endpoints
.
Models
.
HuggingFaceLogin
(),
fetcher
fetcher
,
);
// Set isHFAccessTokenSet to true if message in canLogInToHuggingFace is 'OK'
...
...
@@ -224,7 +225,7 @@ export default function ModelStore() {
flexDirection
:
'
column
'
,
overflow
:
'
hidden
'
,
}
}
>
>
<
Box
sx
=
{
{
position
:
'
relative
'
,
...
...
@@ -336,7 +337,7 @@ export default function ModelStore() {
component
=
"button"
onClick
=
{
()
=>
setOrder
(
order
===
'
asc
'
?
'
desc
'
:
'
asc
'
)
}
fontWeight
=
"lg"
endDecorator
=
{
<
Ar
ro
w
DownIcon
/>
}
endDecorator
=
{
<
Chev
ro
n
DownIcon
/>
}
sx
=
{
{
'
& svg
'
:
{
transition
:
'
0.2s
'
,
...
...
@@ -360,7 +361,7 @@ export default function ModelStore() {
{
modelGalleryData
&&
stableSort
(
filterByFilters
(
modelGalleryData
,
searchText
,
filters
),
getComparator
(
order
,
'
name
'
)
getComparator
(
order
,
'
name
'
)
,
).
map
((
row
)
=>
(
<
tr
key
=
{
row
.
uniqueID
}
>
<
td
>
...
...
@@ -473,7 +474,7 @@ export default function ModelStore() {
'
To access gated Hugging Face models you must first:
\r\r
'
+
'
1. Create a READ access token in your Hugging Face account.
\r\r
'
+
'
2. Enter the token on the Transformer Lab Settings page.
\r\r
'
+
'
Click OK to go to Settings.
'
'
Click OK to go to Settings.
'
,
);
if
(
confirm_result
)
{
navigate
(
'
/settings
'
);
...
...
@@ -492,19 +493,19 @@ export default function ModelStore() {
setCurrentlyDownloading
(
row
.
name
);
try
{
let
response
=
await
fetch
(
chatAPI
.
Endpoints
.
Jobs
.
Create
()
chatAPI
.
Endpoints
.
Jobs
.
Create
()
,
);
const
newJobId
=
await
response
.
json
();
setJobId
(
newJobId
);
response
=
await
downloadModelFromGallery
(
row
?.
uniqueID
,
newJobId
newJobId
,
);
if
(
response
?.
status
==
'
error
'
)
{
setCurrentlyDownloading
(
null
);
setJobId
(
null
);
return
alert
(
`Failed to download:\n
${
response
.
message
}
`
`Failed to download:\n
${
response
.
message
}
`
,
);
}
else
if
(
response
?.
status
==
'
unauthorized
'
)
{
setCurrentlyDownloading
(
null
);
...
...
@@ -514,7 +515,7 @@ export default function ModelStore() {
window
.
open
(
getModelHuggingFaceURL
(
row
),
'
_blank
'
'
_blank
'
,
)
?.
focus
();
}
...
...
@@ -539,7 +540,7 @@ export default function ModelStore() {
value
=
{
clamp
(
modelDownloadProgress
?.
progress
,
0
,
100
100
,
)
}
sx
=
{
{
width
:
'
100px
'
}
}
variant
=
"solid"
...
...
@@ -550,10 +551,10 @@ export default function ModelStore() {
<>
{
clamp
(
Number
.
parseFloat
(
modelDownloadProgress
?.
progress
modelDownloadProgress
?.
progress
,
),
0
,
100
100
,
).
toFixed
(
0
)
}
%
</>
...
...
@@ -570,7 +571,7 @@ export default function ModelStore() {
modelDownloadProgress
?.
job_data
?.
downloaded
*
1024
*
1024
1024
,
)
}
{
/* {modelDownloadProgress?.job_data} */
}
<
ArrowDownIcon
size
=
"18px"
/>
...
...
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