refactor: only write reasoning to file; count line overflow better
This commit is contained in:
parent
8facbb0de2
commit
993fb143a2
2 changed files with 13 additions and 15 deletions
20
index.ts
20
index.ts
|
|
@ -6,9 +6,6 @@ import { renderStream } from "./src/render";
|
|||
|
||||
const home = os.homedir();
|
||||
const convoFile = Bun.file(`${home}/.aicl_convo.json`);
|
||||
const reasoningFile = Bun.file(`${home}/.aicl_reasoning.md`);
|
||||
const responsePath = `${home}/.aicl_response.md`;
|
||||
const responseFile = Bun.file(responsePath);
|
||||
|
||||
const provider = createOpenAICompatible({
|
||||
name: "llama.cpp",
|
||||
|
|
@ -27,8 +24,8 @@ try {
|
|||
const prompt = Bun.argv[2] ?? "Introduce yourself.";
|
||||
messages.push({ role: "user", content: prompt });
|
||||
|
||||
const { fullStream, textStream, reasoningText, text, totalUsage } = streamText({
|
||||
model: provider("qwen3.5-35b-a3b"),
|
||||
const { fullStream, textStream, text, totalUsage } = streamText({
|
||||
model: provider("gemma4-26b-a4b"),
|
||||
messages,
|
||||
});
|
||||
|
||||
|
|
@ -43,20 +40,15 @@ const glow = Bun.spawn({
|
|||
stdout: "inherit",
|
||||
});
|
||||
|
||||
const reasoning = await reasoningText;
|
||||
const response = await text;
|
||||
await streamRender;
|
||||
|
||||
const stop = Date.now();
|
||||
|
||||
messages.push({ role: "assistant", content: response });
|
||||
await convoFile.write(JSON.stringify(messages));
|
||||
|
||||
await reasoningFile.write(reasoning ?? "");
|
||||
await responseFile.write(response);
|
||||
|
||||
await streamRender;
|
||||
await glow.exited;
|
||||
|
||||
messages.push({ role: "assistant", content: await text });
|
||||
await convoFile.write(JSON.stringify(messages));
|
||||
|
||||
const { inputTokens, outputTokens } = await totalUsage;
|
||||
const context = (inputTokens ?? 0) / 1000;
|
||||
const output = (outputTokens ?? 0) / 1000;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue