import { createOpenAICompatible } from "@ai-sdk/openai-compatible"; import { streamText } from "ai"; import { renderStream } from "./src/render"; const provider = createOpenAICompatible({ name: "llama.cpp", apiKey: "local", baseURL: "http://127.0.0.1:8080/v1", includeUsage: true, // Include usage information in streaming responses }); const { fullStream, reasoningText, text } = streamText({ model: provider("qwen3.5-35b-a3b"), prompt: Bun.argv[2] ?? "Introduce yourself.", }); renderStream(fullStream); const reasoning = await reasoningText; Bun.file("reasoning.md").write(reasoning ?? ""); const response = await text; Bun.file("response.md").write(response); const [numColumns] = process.stdout.getWindowSize(); Bun.spawnSync({ cmd: ["glow", "-w", `${numColumns}`, "response.md"], stdio: ["inherit", "inherit", "inherit"], });