Skip to content

Commit

Permalink
Reversed sorting and new code
Browse files Browse the repository at this point in the history
  • Loading branch information
midudev committed Jun 14, 2024
1 parent 7accafa commit b2f2304
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
13 changes: 10 additions & 3 deletions 04-chatgpt-local/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@
</style>

<script type="module">
import { CreateWebWorkerMLCEngine } from "https://esm.run/@mlc-ai/web-llm"
/*
en el vídeo usamos "https://esm.run/@mlc-ai/web-llm"
el problema es que eso siempre es la versión más reciente
en el código usamos https://cdn.jsdelivr.net/npm/@mlc-ai/[email protected]/+esm
para fijar la versión */
import { CreateWebWorkerMLCEngine } from "https://cdn.jsdelivr.net/npm/@mlc-ai/[email protected]/+esm"

const $ = el => document.querySelector(el)

Expand All @@ -183,6 +188,7 @@
const $loading = $('.loading')

let messages = []
let end = false

const SELECTED_MODEL = 'Llama-3-8B-Instruct-q4f32_1-MLC-1k'

Expand All @@ -192,8 +198,9 @@
{
initProgressCallback: (info) => {
$info.textContent = info.text
if (info.progress === 1) {
$loading.parentNode.removeChild($loading)
if (info.progress === 1 && !end) {
end = true
$loading?.parentNode?.removeChild($loading)
$button.removeAttribute('disabled')
addMessage("¡Hola! Soy un ChatGPT que se ejecuta completamente en tu navegador. ¿En qué puedo ayudarte hoy?", 'bot')
$input.focus()
Expand Down
2 changes: 1 addition & 1 deletion 04-chatgpt-local/worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WebWorkerMLCEngineHandler } from "https://esm.run/@mlc-ai/web-llm"
import { WebWorkerMLCEngineHandler } from "https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.46/+esm"

const handler = new WebWorkerMLCEngineHandler()

Expand Down
17 changes: 12 additions & 5 deletions web/public/projects/04-chatgpt-local/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,12 @@
</style>

<script type="module">
import { CreateWebWorkerMLCEngine } from "https://esm.run/@mlc-ai/web-llm"
/*
en el vídeo usamos "https://esm.run/@mlc-ai/web-llm"
el problema es que eso siempre es la versión más reciente
en el código usamos https://cdn.jsdelivr.net/npm/@mlc-ai/[email protected]/+esm
para fijar la versión */
import { CreateWebWorkerMLCEngine } from "https://cdn.jsdelivr.net/npm/@mlc-ai/[email protected]/+esm"

const $ = el => document.querySelector(el)

Expand All @@ -183,6 +188,7 @@
const $loading = $('.loading')

let messages = []
let end = false

const SELECTED_MODEL = 'Llama-3-8B-Instruct-q4f32_1-MLC-1k'

Expand All @@ -191,9 +197,10 @@
SELECTED_MODEL,
{
initProgressCallback: (info) => {
$info.textContent = `${info.text}%`
if (info.progress === 1) {
$loading.parentNode.removeChild($loading)
$info.textContent = info.text
if (info.progress === 1 && !end) {
end = true
$loading?.parentNode?.removeChild($loading)
$button.removeAttribute('disabled')
addMessage("¡Hola! Soy un ChatGPT que se ejecuta completamente en tu navegador. ¿En qué puedo ayudarte hoy?", 'bot')
$input.focus()
Expand Down Expand Up @@ -292,4 +299,4 @@ <h5>Esto puede tardar un poco. Paciencia.</h5>
</template>
</body>

</html>
</html>
2 changes: 1 addition & 1 deletion web/public/projects/04-chatgpt-local/worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WebWorkerMLCEngineHandler } from "https://esm.run/@mlc-ai/web-llm"
import { WebWorkerMLCEngineHandler } from "https://cdn.jsdelivr.net/npm/@mlc-ai/web-llm@0.2.46/+esm"

const handler = new WebWorkerMLCEngineHandler()

Expand Down
3 changes: 2 additions & 1 deletion web/src/components/Projects.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { PROJECTS } from "../consts"
class="grid gap-8 mb-6 lg:mb-16 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 max-w-6xl mx-auto"
>
{
PROJECTS.map((project, index) => {
PROJECTS.toReversed().map((project, reversedIndex) => {
const index = PROJECTS.length - reversedIndex - 1
const num = `${index + 1}`.padStart(2, "0")

return (
Expand Down

1 comment on commit b2f2304

@sombra2323
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Please sign in to comment.