-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from SkywardAI/first-time-setup
add settings on user start application
- Loading branch information
Showing
10 changed files
with
171 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { useEffect, useState } from 'react' | ||
import useIDB from '../utils/idb' | ||
import { downloadModel, isModelDownloaded, loadModel } from '../utils/worker' | ||
|
||
export default function Entry({complete}) { | ||
|
||
const [loadStep, setLoadStep] = useState(0); | ||
const [download_progress, setProgress] = useState(-1); | ||
const idb = useIDB(); | ||
|
||
async function firstTimeSetup() { | ||
if(!(await isModelDownloaded())) { | ||
await downloadModel('completion', (progress)=>{ | ||
setProgress(progress); | ||
}) | ||
} | ||
localStorage.setItem('not-first-time', '1'); | ||
setLoadStep(2); | ||
} | ||
|
||
async function startUp() { | ||
await idb.initDB(); | ||
loadStep !== 3 && await loadModel(); | ||
complete(); | ||
} | ||
|
||
useEffect(()=>{ | ||
loadStep >= 2 && startUp(); | ||
// eslint-disable-next-line | ||
}, [loadStep]) | ||
|
||
useEffect(()=>{ | ||
setLoadStep( | ||
1+!!localStorage.getItem('not-first-time') | ||
) | ||
}, []) | ||
|
||
return ( | ||
<div className='load-page'> | ||
{ | ||
loadStep === 0 ? | ||
<div className='loading'>Loading, please wait...</div> : | ||
loadStep === 1 ? | ||
<div className="first-time"> | ||
<div className="title">Welcome to SkywardAI Chat!</div> | ||
<div className="description"> | ||
Seems like this is the first time you using SkywardAI Chat.<br/> | ||
To start chat, you need to download a basic model that is around 400MiB.<br/> | ||
You don't need to download it again in the future<br/> | ||
If you want to use your own model or you want to setup later, please skip. | ||
</div> | ||
{ | ||
download_progress < 0 ? | ||
<> | ||
<div className="download-model clickable" onClick={firstTimeSetup}>Set Me Up Now!</div> | ||
<div className="skip clickable" onClick={()=>setLoadStep(2)}>Skip for now</div> | ||
</> : | ||
<div className='download-progress'> | ||
<div className='progress-bar' style={{transform: `translateX(-${100-download_progress}%)`}}></div> | ||
<div className='progress-num'>{Math.round(download_progress)}%</div> | ||
</div> | ||
} | ||
</div>: | ||
<div className='loading'>Loading necessary resources, please wait...</div> | ||
} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
.load-page > .loading { | ||
width: 100%; | ||
user-select: none; | ||
text-align: center; | ||
color: gray; | ||
margin-top: 20px; | ||
} | ||
|
||
.load-page > .first-time { | ||
width: 100%; | ||
padding: 60px 40px; | ||
text-align: center; | ||
} | ||
|
||
.load-page > .first-time > .title { | ||
font-size: 30px; | ||
color: gray; | ||
} | ||
|
||
.load-page > .first-time > .description { | ||
font-size: 18px; | ||
color: gray; | ||
margin-top: 20px; | ||
line-height: 25px; | ||
} | ||
|
||
.load-page > .first-time > .download-model { | ||
width: 270px; | ||
height: 40px; | ||
border-radius: 10px; | ||
align-content: center; | ||
margin: auto; | ||
background-color: rgb(150, 150, 150); | ||
margin-top: 20px; | ||
color: white; | ||
user-select: none; | ||
font-size: 20px; | ||
transition-duration: .3s; | ||
} | ||
.load-page > .first-time > .download-model:hover { | ||
background-color: gray; | ||
} | ||
|
||
.load-page > .first-time > .skip { | ||
width: fit-content; | ||
margin: auto; | ||
margin-top: 10px; | ||
text-decoration: underline; | ||
color: gray; | ||
} | ||
|
||
.load-page > .first-time > .download-progress { | ||
margin: auto; | ||
margin-top: 20px; | ||
width: 500px; | ||
background-color: lightgray; | ||
border-radius: 20px; | ||
height: 20px; | ||
align-content: center; | ||
font-size: 12px; | ||
color: white; | ||
position: relative; | ||
overflow: hidden; | ||
} | ||
|
||
.load-page > .first-time > .download-progress > .progress-bar { | ||
position: absolute; | ||
width: 100%; | ||
height: 100%; | ||
top: 0; | ||
left: 0; | ||
background-color: limegreen; | ||
transform: translateX(-100%); | ||
z-index: 1; | ||
} | ||
|
||
.load-page > .first-time > .download-progress > .progress-num { | ||
z-index: 2; | ||
position: relative; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters