[PR #76] feat: vercel/ai binding #85

Open
opened 2026-02-16 03:16:08 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/run-llama/workflows-ts/pull/76
Author: @himself65
Created: 4/24/2025
Status: 🔄 Open

Base: mainHead: himself65/data-stream


📝 Commits (1)

📊 Changes

22 files changed (+2386 additions, -19 deletions)

View changed files

📝 demo/hono/app.ts (+15 -0)
demo/next/.gitignore (+41 -0)
demo/next/README.md (+36 -0)
demo/next/next.config.ts (+7 -0)
demo/next/package-lock.json (+1558 -0)
demo/next/package.json (+26 -0)
demo/next/postcss.config.mjs (+5 -0)
demo/next/public/file.svg (+1 -0)
demo/next/public/globe.svg (+1 -0)
demo/next/public/next.svg (+1 -0)
demo/next/public/vercel.svg (+1 -0)
demo/next/public/window.svg (+1 -0)
demo/next/src/app/favicon.ico (+0 -0)
demo/next/src/app/globals.css (+26 -0)
demo/next/src/app/layout.tsx (+34 -0)
demo/next/src/app/page.tsx (+33 -0)
demo/next/tsconfig.json (+27 -0)
📝 demo/package.json (+2 -0)
demo/workflows/ai-chat-workflow.ts (+20 -0)
📝 packages/core/package.json (+19 -0)

...and 2 more files

📄 Description

basic example:

import { createWorkflow, workflowEvent } from "@llama-flow/core";
import { mergeToWorkflow } from "@llama-flow/core/ai";
import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";

const chatWorkflow = createWorkflow();

const startChatEvent = workflowEvent<string>();
const stopChatEvent = workflowEvent();

chatWorkflow.handle([startChatEvent], async () => {
  const result = streamText({
    model: openai("gpt-4.1"),
    prompt: "You are a helpful assistant.",
  });
  await mergeToWorkflow(result.fullStream);
  return stopChatEvent.with();
});

export { startChatEvent, stopChatEvent, chatWorkflow };
app.post("/chat", async (context) => {
  const { messages } = await context.req.json();
  const { stream, sendEvent } = chatWorkflow.createContext();
  sendEvent(startChatEvent.with(messages));
  return new Response(dataStream(stream));
});
// frontend
import { useChat } from 'ai/react'

useChat({
  api: '/chat'
})

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/run-llama/workflows-ts/pull/76 **Author:** [@himself65](https://github.com/himself65) **Created:** 4/24/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `himself65/data-stream` --- ### 📝 Commits (1) - [`da20c69`](https://github.com/run-llama/workflows-ts/commit/da20c6947b7dbab36c62c8b1bd8505bf374e9f89) feat: vercel/ai binding ### 📊 Changes **22 files changed** (+2386 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `demo/hono/app.ts` (+15 -0) ➕ `demo/next/.gitignore` (+41 -0) ➕ `demo/next/README.md` (+36 -0) ➕ `demo/next/next.config.ts` (+7 -0) ➕ `demo/next/package-lock.json` (+1558 -0) ➕ `demo/next/package.json` (+26 -0) ➕ `demo/next/postcss.config.mjs` (+5 -0) ➕ `demo/next/public/file.svg` (+1 -0) ➕ `demo/next/public/globe.svg` (+1 -0) ➕ `demo/next/public/next.svg` (+1 -0) ➕ `demo/next/public/vercel.svg` (+1 -0) ➕ `demo/next/public/window.svg` (+1 -0) ➕ `demo/next/src/app/favicon.ico` (+0 -0) ➕ `demo/next/src/app/globals.css` (+26 -0) ➕ `demo/next/src/app/layout.tsx` (+34 -0) ➕ `demo/next/src/app/page.tsx` (+33 -0) ➕ `demo/next/tsconfig.json` (+27 -0) 📝 `demo/package.json` (+2 -0) ➕ `demo/workflows/ai-chat-workflow.ts` (+20 -0) 📝 `packages/core/package.json` (+19 -0) _...and 2 more files_ </details> ### 📄 Description basic example: ```ts import { createWorkflow, workflowEvent } from "@llama-flow/core"; import { mergeToWorkflow } from "@llama-flow/core/ai"; import { streamText } from "ai"; import { openai } from "@ai-sdk/openai"; const chatWorkflow = createWorkflow(); const startChatEvent = workflowEvent<string>(); const stopChatEvent = workflowEvent(); chatWorkflow.handle([startChatEvent], async () => { const result = streamText({ model: openai("gpt-4.1"), prompt: "You are a helpful assistant.", }); await mergeToWorkflow(result.fullStream); return stopChatEvent.with(); }); export { startChatEvent, stopChatEvent, chatWorkflow }; ``` ```ts app.post("/chat", async (context) => { const { messages } = await context.req.json(); const { stream, sendEvent } = chatWorkflow.createContext(); sendEvent(startChatEvent.with(messages)); return new Response(dataStream(stream)); }); ``` ```ts // frontend import { useChat } from 'ai/react' useChat({ api: '/chat' }) ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 03:16:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/workflows-ts#85