Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/test_ai_examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: test / AI examples

on:
push:
branches: [main]
paths:
- "examples/nextjs-app-router/**"
- "examples/vercel-ai-sdk/**"
- "packages/create-askable-app/**"
- ".github/workflows/test_ai_examples.yml"
pull_request:
branches: [main]
paths:
- "examples/nextjs-app-router/**"
- "examples/vercel-ai-sdk/**"
- "packages/create-askable-app/**"
- ".github/workflows/test_ai_examples.yml"
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ai-examples:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
app: [nextjs-app-router, vercel-ai-sdk, template-nextjs]
env:
NEXT_TELEMETRY_DISABLED: "1"
OPENAI_API_KEY: ""
ANTHROPIC_API_KEY: ""
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-node@v7
with:
node-version: 22
- name: Select example
if: matrix.app != 'template-nextjs'
run: echo "APP_DIR=$GITHUB_WORKSPACE/examples/${{ matrix.app }}" >> "$GITHUB_ENV"
- name: Scaffold a standalone Next.js app
if: matrix.app == 'template-nextjs'
working-directory: ${{ runner.temp }}
run: |
node "$GITHUB_WORKSPACE/packages/create-askable-app/bin/create-askable-app.js" ai-template --template nextjs
echo "APP_DIR=$RUNNER_TEMP/ai-template" >> "$GITHUB_ENV"
- name: Resolve generated template dependencies
if: matrix.app == 'template-nextjs'
working-directory: ${{ env.APP_DIR }}
run: npm install --package-lock-only --workspaces=false
- name: Clean install
working-directory: ${{ env.APP_DIR }}
run: npm ci --workspaces=false
- name: Secrets-free provider and stream regressions
working-directory: ${{ env.APP_DIR }}
run: npm test
- name: Typecheck
working-directory: ${{ env.APP_DIR }}
run: npm run typecheck
- name: Production build (no inference)
working-directory: ${{ env.APP_DIR }}
run: npm run build
- name: Audit all dependencies
working-directory: ${{ env.APP_DIR }}
run: npm audit --workspaces=false
5 changes: 5 additions & 0 deletions examples/nextjs-app-router/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
.next/
next-env.d.ts
*.tsbuildinfo
.env*.local
8 changes: 4 additions & 4 deletions examples/nextjs-app-router/app/api/chat/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { streamText } from 'ai';
import { convertToModelMessages, generateId, streamText, type UIMessage } from 'ai';
import { createAnthropic } from '@ai-sdk/anthropic';

export const runtime = 'edge';
Expand All @@ -7,7 +7,7 @@ const anthropic = createAnthropic();

export async function POST(req: Request) {
const { messages, uiContext } = await req.json() as {
messages: Array<{ role: 'user' | 'assistant'; content: string }>;
messages: UIMessage[];
uiContext?: string;
};

Expand All @@ -21,8 +21,8 @@ export async function POST(req: Request) {
const result = streamText({
model: anthropic('claude-sonnet-4-6'),
system: systemPrompt,
messages,
messages: await convertToModelMessages(messages),
});

return result.toDataStreamResponse();
return result.toUIMessageStreamResponse({ originalMessages: messages, generateMessageId: generateId });
}
Loading
Loading