Skip to content

Commit

Permalink
fix (docs): remove force-dynamic from docs and examples (vercel#2332)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoalbanese authored Jul 18, 2024
1 parent c53f301 commit df5c774
Show file tree
Hide file tree
Showing 21 changed files with 18 additions and 48 deletions.
6 changes: 2 additions & 4 deletions content/docs/02-getting-started/02-nextjs-app-router.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ import { useState } from 'react';
import { continueConversation } from './actions';
import { readStreamableValue } from 'ai/rsc';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Chat() {
Expand Down Expand Up @@ -410,8 +409,7 @@ import { useState } from 'react';
import { continueConversation } from './actions';
import { readStreamableValue } from 'ai/rsc';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Chat() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ Let's create a simple React component that will call the `getAnswer` function wh
import { useState } from 'react';
import { getAnswer } from './actions';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import { useState } from 'react';
import { generate } from './actions';
import { readStreamableValue } from 'ai/rsc';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ Let's create a simple React component that will call the `getNotifications` func
import { useState } from 'react';
import { getNotifications } from './actions';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ import { useState } from 'react';
import { generate } from './actions';
import { readStreamableValue } from 'ai/rsc';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ Let's create a simple conversation between a user and a model, and place a butto
import { useState } from 'react';
import { Message, continueConversation } from './actions';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ import { useState } from 'react';
import { Message, continueConversation } from './actions';
import { readStreamableValue } from 'ai/rsc';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
3 changes: 1 addition & 2 deletions content/examples/01-next-app/03-tools/01-call-tool.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ Let's create a simple conversation between a user and model and place a button t
import { useState } from 'react';
import { Message, continueConversation } from './actions';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ Let's modify our previous example to call `getWeather` tool for multiple cities
import { useState } from 'react';
import { Message, continueConversation } from './actions';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ We can make a few changes to our previous example where the assistant could get
import { useState } from 'react';
import { Message, continueConversation } from './actions';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import { ClientMessage } from './actions';
import { useActions, useUIState } from 'ai/rsc';
import { generateId } from 'ai';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ import { ClientMessage } from './actions';
import { useActions, useUIState } from 'ai/rsc';
import { generateId } from 'ai';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import { ClientMessage } from './actions';
import { useActions, useUIState } from 'ai/rsc';
import { generateId } from 'ai';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import { ClientMessage } from './actions';
import { useActions, useUIState } from 'ai/rsc';
import { generateId } from 'ai';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
3 changes: 1 addition & 2 deletions content/examples/01-next-app/05-interface/03-token-usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import { ClientMessage } from './actions';
import { useActions, useUIState } from 'ai/rsc';
import { generateId } from 'ai';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Home() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ The last message is the user's message, and we add the image URL to it.
import { openai } from '@ai-sdk/openai';
import { convertToCoreMessages, streamText } from 'ai';

export const dynamic = 'force-dynamic';
export const maxDuration = 60;

export async function POST(req: Request) {
Expand Down Expand Up @@ -58,8 +57,7 @@ You can replace the `imageUrl` with the actual URL of the image you want to send

import { useChat } from 'ai/react';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

export default function Chat() {
Expand Down
1 change: 0 additions & 1 deletion content/providers/04-adapters/langchain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ The AI SDK `LangChainAdapter` uses the result from [LangChain ExpressionLanguage
import { ChatOpenAI } from '@langchain/openai';
import { LangChainAdapter, StreamingTextResponse } from 'ai';

export const dynamic = 'force-dynamic';
export const maxDuration = 60;

export async function POST(req: Request) {
Expand Down
4 changes: 0 additions & 4 deletions content/providers/05-legacy-providers/anthropic.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY || '',
});

export const dynamic = 'force-dynamic';

export async function POST(req: Request) {
// Extract the `prompt` from the body of the request
const { messages } = await req.json();
Expand Down Expand Up @@ -131,8 +129,6 @@ const anthropic = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY || '',
});

export const dynamic = 'force-dynamic';

export async function POST(req: Request) {
// Extract the `prompt` from the body of the request
const { prompt } = await req.json();
Expand Down
4 changes: 0 additions & 4 deletions content/providers/05-legacy-providers/cohere.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ For this example, we'll create a route handler at `app/api/chat/route.ts` that a
import { CohereStream, StreamingTextResponse } from 'ai';
import { CohereClient, Cohere } from 'cohere-ai';

// IMPORTANT! Set the dynamic to force-dynamic
// Prevent nextjs to cache this route
export const dynamic = 'force-dynamic';

if (!process.env.COHERE_API_KEY) {
throw new Error('Missing COHERE_API_KEY environment variable');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const KASADA_ENDPOINT = 'FILL_IN.kasadapolyform.io';

export const dynamic = 'force-dynamic';

async function handler(request: Request) {
const url = new URL(request.url);

Expand Down
3 changes: 1 addition & 2 deletions examples/next-openai/app/stream-object/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { useState } from 'react';
import { generateNotifications } from './actions';
import { PartialNotification } from './schema';

// Force the page to be dynamic and allow streaming responses up to 30 seconds
export const dynamic = 'force-dynamic';
// Allow streaming responses up to 30 seconds
export const maxDuration = 30;

// page component with a button to generate notifications
Expand Down

0 comments on commit df5c774

Please sign in to comment.