Skip to content

Instantly share code, notes, and snippets.

@celsowm
celsowm / index.htm
Created June 28, 2025 21:13
Json stream
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<title>SimpleCanvasLLM with History - Chat Style</title>
<link
rel="stylesheet"
href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css"
/>
<link
@celsowm
celsowm / LLMJsonStreamParser.js
Last active June 28, 2025 21:13
LLMJsonStreamParser.js
/**
* @typedef {'object' | 'array'} ContainerType
*/
/**
* @typedef {Object} ParserEvent
* @property {'objectStart' | 'objectEnd' | 'arrayStart' | 'arrayEnd' | 'key' | 'valueChunk' | 'value' | 'done' | 'error'} type
* @property {(string|number)[]} [path]
* @property {*} [value]
* @property {string} [chunk]
@celsowm
celsowm / JsonStreamParser.js
Last active June 28, 2025 07:05
JsonStreamParser.js
/**
* @typedef {'object' | 'array'} ContainerType
*/
/**
* @typedef {Object} ParserEvent
* @property {'objectStart' | 'objectEnd' | 'arrayStart' | 'arrayEnd' | 'key' | 'valueChunk' | 'value'} type
* @property {(string|number)[]} path
* @property {*} [value]
* @property {string} [chunk]
@celsowm
celsowm / build.sh
Last active July 3, 2025 00:40
Build vllm on 5090
docker build . \
--target vllm-openai \
--file docker/Dockerfile \
--tag vllm-5090:latest \
--build-arg max_jobs=2 \
--build-arg nvcc_threads=1 \
--build-arg RUN_WHEEL_CHECK=false \
--progress=plain | tee build.log
@celsowm
celsowm / gguf_loader.py
Last active June 27, 2025 00:04
python/sglang/srt/weight_loader/gguf_loader.py
from __future__ import annotations
import io
import mmap
import pathlib
import struct
import time
from enum import IntEnum
from typing import Any, BinaryIO, Dict, List, Tuple
@celsowm
celsowm / index.htm
Last active June 7, 2025 15:03
Editor Markdown WYSWYG
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Editor Markdown Avançado</title>
<!-- CSS Essencial do Editor (para ser distribuído com o editor) -->
<style id="editor-core-styles">
@celsowm
celsowm / index.htm
Last active June 15, 2025 17:53
SimpleCanvasLLM
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<title>SimpleCanvasLLM with History - Chat Style</title>
<link rel="stylesheet" href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css" />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
html,
@celsowm
celsowm / stream_mode_artefato.js
Created June 1, 2025 23:58
stream_mode_artefato.js
(async function() {
// 1) URL do seu servidor
const ENDPOINT = "http://localhost:8081/v1/chat/completions";
// 2) Nome exato do modelo (case‐sensitive)
const MODEL = "seu-modelo-aqui";
// 3) Texto que o usuário pediu
const PROMPT_DO_USUARIO = "escreva uma redação sobre a vida";
@celsowm
celsowm / stream_mode_json_chat_completion.js
Created June 1, 2025 23:54
stream_mode_json_chat_completion.js
(async () => {
// 1) Ajuste para o URL do seu servidor
const ENDPOINT = "http://localhost:8081/v1/chat/completions";
// 2) Use exatamente o mesmo nome de modelo que funcionou no Python
const MODEL = "seu-modelo-aqui";
// 3) Prompt de teste (igual ao Python: "Who won the world series in 2020")
const PROMPT = "Who won the world series in 2020";
@celsowm
celsowm / index.htm
Last active May 24, 2025 20:13
OPEN EXCELLM
<!DOCTYPE html>
<html lang="pt-BR" data-bs-theme="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Leitor & Editor de Planilhas XLSX + AI</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet">