| const { serve } = require('@hono/node-server'); | |
| const { Hono } = require('hono'); | |
| const { cors } = require('hono/cors'); | |
| const app = new Hono() | |
| app.use('/api/*', cors()) | |
| app.all('/api/abc', (c) => { | |
| return c.json({ success: true }) |
| class Game2048 { | |
| constructor() { | |
| this.board = this.initializeBoard(); | |
| this.score = 0; | |
| this.gameOver = false; | |
| this.gameWon = false; | |
| this.addRandomTile(); | |
| this.addRandomTile(); | |
| } |
| 🚀󠅅󠅔󠅑󠅘󠄐󠅣󠅙󠅑󠅠󠄯󠄐󠇠󠆏󠆁󠅰󠄐︊︊󠄱󠅛󠅥󠄐󠅒󠅑󠅗󠅙󠄝󠅒󠅑󠅗󠅙󠄐󠅘󠅑󠅔󠅙󠅑󠅘󠄐󠅠󠅑󠅛󠅑󠅙󠄐󠄷󠅟󠅀󠅑󠅩󠄑󠄐󠅘󠅤󠅤󠅠󠅣󠄪󠄟󠄟󠅑󠅠󠅠󠄞󠅗󠅟󠅠󠅑󠅩󠄞󠅓󠅟󠄞󠅙󠅔󠄟󠄾󠄶󠄨󠅠󠄟󠅧󠄥󠅠󠅨󠅛󠅥󠅦󠅞︊︊󠄲󠅥󠅢󠅥󠅑󠅞󠄐󠅒󠅥󠅛󠅑󠄐󠅘󠅑󠅔󠅙󠅑󠅘󠅞󠅩󠅑󠄐󠅣󠅕󠅒󠅕󠅜󠅥󠅝󠄐󠅘󠅑󠅞󠅗󠅥󠅣󠄐󠄻󠅑󠅝󠅙󠅣󠄜󠄐󠄣󠄐󠄱󠅠󠅢󠄐󠄢󠄠󠄢󠄥󠄐󠄝󠄐󠄡󠄥󠄪󠄠󠄤󠄐󠇠󠆏󠆂󠆨󠇠󠆏󠅼󠆚󠄐󠄺󠅑󠅞󠅗󠅑󠅞󠄐󠅣󠅑󠅝󠅠󠅕󠄐󠅛󠅕󠅔󠅥󠅜󠅥󠅑󠅞󠄐󠅩󠅑󠅞󠅗󠄐󠅜󠅑󠅙󠅞󠄐󠇠󠆏󠆔󠆝 |
| .-. .----. -. / .... ... --.. .. .-. -- - / .-- --.. -- --.. / .--. --.. - ...- --. / -- .-.. -.. -.-.-- / --- ...- --. .----. .... / -..- --- --.. .-. -. / .-. --. / -.-- ...- ..- .-.. .. ...- / .-. --. .----. .... / - .-.. -- ...- / # # # / ... --. --. -.- .... ---... -..-. -..-. --- .-. -- .--. .-.-.- .-- --.. -- --.. .-.-.- .-. .-- -..-. .-- --.. -- --.. .--. --.. - ...- --. ..--.. -..- -...- .... -.- --.. --... -..- ... --.- -.. ....- .-... .. -...- .-. --- .... -... -.- --.- .-... .-.. .. .-- ...- .. .-. .-- -...- ..--- ----- ..--- ..... ----- ....- ----- ..--- .---- ----- .---- ..--- .---- ....- ...-- ----. ----. .---- .---- ..... ----- .---- ----- ...-- ----- ----- .---- -.... -.... ...-- ..... .---- --... .---- ..... ---.. .---- ...-- ...-- ...-- ...-- | |
| .-. .----. -. / .... ... --.. .. .-. -- - / .-- --.. -- --.. / .--. --.. - ...- --. / -- .-.. -.. -.-.-- / --- ...- --. .----. .... / -..- --- --.. .-. -. / .-. --. / -.-- ...- ..- .-.. .. ...- / .-. --. .----. .... / - .-.. -- ...- / # # # / ... --. |
| jkrel://tqpb.bpgi.qf/uyctsiivr?r=lmmcdup3p&z=qnJWEc&wzfvpXw=20250326101214951815010300166351714606009 |
| How RAG Works: | |
| RAG consists of two main components: | |
| Retriever: | |
| The retriever is responsible for fetching relevant documents or passages from a knowledge base (e.g., Wikipedia, a database, or a custom corpus). | |
| It does not fetch from the generative model itself. Instead, it uses a separate mechanism (e.g., dense retrieval like DPR or sparse retrieval like BM25) to search through a large collection of documents. | |
| Generator: |
| import { HfInference } from "@huggingface/inference"; | |
| import fs from "fs"; | |
| const inference = new HfInference("HF_TOKEN"); | |
| async function saveBlobToFile(blob, filePath) { | |
| // Convert the blob to a buffer | |
| const arrayBuffer = await blob.arrayBuffer(); | |
| // Write the buffer to a file |
| server: { | |
| proxy: { | |
| "/image": { | |
| target: "https://_.s3.ap-southeast-1.amazonaws.com", | |
| changeOrigin: true, | |
| rewrite: (path) => path.replace(/^\/image/, ""), | |
| }, | |
| }, | |
| }, |
| // Fix issue for huge base64 image | |
| const compressImageFromUrl = (url, quality = 0.7) => { | |
| const img = new Image(); | |
| img.crossOrigin = "anonymous"; | |
| img.src = "/image/" + (url || "").split("/").pop(); | |
| img.onload = () => { | |
| const canvas = document.createElement("canvas"); | |
| const ctx = canvas.getContext("2d"); |