import os from "node:os"; 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 home = os.homedir(); const reasoningPath = `${home}/.aicl_reasoning.md`; const responsePath = `${home}/.aicl_response.md`; const reasoning = await reasoningText; await Bun.file(reasoningPath).write(reasoning ?? ""); const response = await text; await Bun.file(responsePath).write(response); const [numColumns] = process.stdout.getWindowSize(); Bun.spawnSync({ cmd: ["glow", "-w", `${numColumns}`, responsePath], stdio: ["inherit", "inherit", "inherit"], });