
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
llm-prompt-stream
Advanced tools
A lightweight Node.js module for streaming OpenAI responses with Markdown formatting and file saving support.
A lightweight Node.js module for streaming OpenAI responses with Markdown formatting and file saving support.
Install via npm:
npm install llm-prompt-stream
import { createCompletionAndStream, readStream } from "llm-prompt-stream";
// Your OpenAI API key
const openAIKey = "your-api-key";
const messages = [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Tell me a fun fact!" },
];
async function run() {
const stream = await createCompletionAndStream(openAIKey, messages);
const response = await readStream(stream);
console.log("Full Response:", response);
}
run();
import { createCompletionAndStream, readStream } from "llm-prompt-stream";
const openAIKey = "your-api-key";
const messages = [{ role: "user", content: "Give me a summary of AI." }];
async function run() {
const stream = await createCompletionAndStream(openAIKey, messages);
await readStream(stream, true, "output.md");
console.log("Response saved to output.md!");
}
run();
Creates an OpenAI streaming completion.
Returns: A `ReadableStream` containing the OpenAI response.
Reads and processes a streamed response.
Returns: A string containing the full response.
To run tests locally:
npm test
This project is licensed under the MIT License.
Contributions are welcome! Feel free to open an issue or submit a PR.
If you like this package, give it a ⭐ on GitHub!
FAQs
A lightweight Node.js module for streaming OpenAI responses with Markdown formatting and file saving support.
The npm package llm-prompt-stream receives a total of 563 weekly downloads. As such, llm-prompt-stream popularity was classified as not popular.
We found that llm-prompt-stream demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.