Skip to content

Instantly share code, notes, and snippets.

View CoffeeVampir3's full-sized avatar

Z CoffeeVampir3

View GitHub Profile
import express from "npm:express";
import { randomUUID } from "node:crypto";
import { McpServer } from "npm:@modelcontextprotocol/sdk/server/mcp.js";
import { StreamableHTTPServerTransport } from "npm:@modelcontextprotocol/sdk/server/streamableHttp.js";
import { z } from "npm:zod";
const PORT = 3000;
const MCP_ENDPOINT = "/mcp";
const app = express();
[TOOL_CALLS][{"name": "add", "arguments": {"a": 5, "b": 3}}][/TOOL_CALLS]
@CoffeeVampir3
CoffeeVampir3 / sadadjnsauhd897uashd98sahd9a897udshq.ts
Created April 29, 2025 03:45
wefjuejwuiofwjeuifchwie9ofh8i0923hf89023hf892h89fh298fh289f3h892hf.ts
import { StreamingWebSocket, CancellationError } from "./streamingWebSocket.ts";
/**
* Example of client-side streaming inference implementation
* Following the exact flow described in the specification
*/
async function streamInference(
socket: StreamingWebSocket,
onContent: (content: string) => void
): Promise<void> {
@CoffeeVampir3
CoffeeVampir3 / Router.ts
Created April 23, 2025 04:32
router thing
import {
InferenceJobArguments,
InferenceProcessor,
} from "../frontend/InferenceProcessor.ts";
import { ClientStream } from "../router/clientStream.ts";
import { delay } from "https://deno.land/[email protected]/async/delay.ts";
import { StreamingState } from "./types.ts";
interface StreamingJob {
id: string;
#ifndef RULE_STREAM_HPP
#define RULE_STREAM_HPP
#include <multisampler.hpp>
#include <slot.hpp>
#include "llama.h"
#include "sampling.h"
#include <unordered_map>
#include <utility>
@CoffeeVampir3
CoffeeVampir3 / log.ixx
Created January 20, 2025 10:50
Logging
export module Logging;
import std;
/*
Works exactly like std::print. Fail and ass will show verbose logging data (failure location.)
Logging::info("hello world");
Logging::warn("{} + {}", "sweg and", 5);
Logging::fail("{} {}", "the ", " game");
Logging::ass(false == true, "False was not true"); //outputs to cerr
*/
@CoffeeVampir3
CoffeeVampir3 / quixel.js
Created September 18, 2024 02:05
quixeling
(await (async (startPage = 0, autoClearConsole = true) => {
const getCookie = (name) => {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
const callCacheApi = async (params = {}) => {
const defaultParams = {
@CoffeeVampir3
CoffeeVampir3 / Vulkan.cc
Last active August 22, 2024 11:30
CPP Module Example
export module Vulkan;
import <stdexcept>;
import Validation;
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
export namespace Vulkan {
auto CreateInstance() {
VkInstance instance;
export module VulkanInstance;
#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>
import VulkanValidation;
export namespace Vulkan {
auto CreateInstance() {
VkInstance instance;
@CoffeeVampir3
CoffeeVampir3 / gemma2_format.py
Last active August 10, 2024 13:05
Rolling system prompt
from exllamav2 import(
ExLlamaV2Tokenizer
)
def encode_message(tokenizer: ExLlamaV2Tokenizer, role: str, message: str) -> list:
tokens = []
start_token = tokenizer.single_id("<start_of_turn>")
end_token = tokenizer.single_id("<end_of_turn>")
tokens.append(start_token)