feat: write to the same files in homedir everytime
This commit is contained in:
parent
cfc494ba53
commit
1f59cbca7b
1 changed files with 8 additions and 3 deletions
11
index.ts
11
index.ts
|
|
@ -1,3 +1,4 @@
|
|||
import os from "node:os";
|
||||
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
|
||||
import { streamText } from "ai";
|
||||
|
||||
|
|
@ -17,14 +18,18 @@ const { fullStream, reasoningText, text } = streamText({
|
|||
|
||||
renderStream(fullStream);
|
||||
|
||||
const home = os.homedir();
|
||||
const reasoningPath = `${home}/.aicl_reasoning.md`;
|
||||
const responsePath = `${home}/.aicl_response.md`;
|
||||
|
||||
const reasoning = await reasoningText;
|
||||
Bun.file("reasoning.md").write(reasoning ?? "");
|
||||
await Bun.file(reasoningPath).write(reasoning ?? "");
|
||||
|
||||
const response = await text;
|
||||
Bun.file("response.md").write(response);
|
||||
await Bun.file(responsePath).write(response);
|
||||
|
||||
const [numColumns] = process.stdout.getWindowSize();
|
||||
Bun.spawnSync({
|
||||
cmd: ["glow", "-w", `${numColumns}`, "response.md"],
|
||||
cmd: ["glow", "-w", `${numColumns}`, responsePath],
|
||||
stdio: ["inherit", "inherit", "inherit"],
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue