Learn how to use the Inngest SDK with personalized code examples.
LLM Summarization
Weekly reminders
Delivery app order flow
DisclaimerThe outputs of this system may be unpredictable and are not guaranteed to be perfect code or morally conscious.
Your history
You haven't submitted anything yet. Either use the form above, or check out one of our examples.
Prompt
Create a function that uses OpenAI to summarize text. It should take a long string of text, splits the text into chunks, uses openAI to summarize the chunks in parallel, then summarizes all summaries.
inngest.createFunction(
{ id: "summarize-text" },
{ event: "app/text.summarize" },
async ({ event, step }) => {
const chunks = splitTextIntoChunks(event.data.text);
const summaries = await Promise.all(
chunks.map((chunk) =>
step.run("summarize-chunk", () => summarizeChunk(chunk))
)
);
await step.run("summarize-summaries", () => summarizeSummaries(summaries));
}
);
Here we create a function called "Summarize text" that takes a long string of text, splits the text into chunks, uses openAI to summarize the chunks in parallel, then summarizes all summaries. We use step tooling to run as many actions in parallel as possible and provide retries and durability to each.
Want to learn more?
Ship background functions & workflows like never before
$ npx inngest-cli dev
Get started for free