🔥FLASH SALE: 30% OFF everything!
LogoTemplateFame
icon of Reasoning Steps - AI SDK

Reasoning Steps - AI SDK

This Next.js chatbot uses the AI SDK's streamText function with maxSteps and a reasoning tool to reason on user queries.

Introduction

This example demonstrates how to use the AI SDK with Next.js and the streamText function to automatically handle multi-step generations. It provides a Next.js chatbot that leverages the AI SDK's streamText function, specifically utilizing maxSteps and a reasoning tool to process and respond to complex user queries. This allows for more sophisticated AI interactions where the model can break down problems into multiple reasoning steps before providing a final answer.

To deploy your own version of this application, you can use the provided Vercel deploy button or clone the repository directly.

How to Use:

To get started with this example, you can bootstrap the project using create-next-app with your preferred package manager:

npx create-next-app --example https://github.com/vercel-labs/ai-sdk-preview-steps-reasoning ai-sdk-preview-steps-reasoning-example
# or
yarn create next-app --example https://github.com/vercel-labs/ai-sdk-preview-steps-reasoning ai-sdk-preview-steps-reasoning-example
# or
pnpm create next-app --example https://github.com/vercel-labs/ai-sdk-preview-steps-reasoning ai-sdk-preview-steps-reasoning-example

Running Locally:

To run the example locally, follow these steps:

  1. Sign up for accounts with the AI providers you intend to use (e.g., OpenAI, Anthropic).
  2. Obtain the necessary API keys for each provider.
  3. Set these API keys as environment variables in a new .env file, mirroring the structure of the .env.example file.
  4. Install the project dependencies by running npm install.
  5. Launch the development server with npm run dev.

Key Features:

  • Multi-Step Generations: Utilizes the AI SDK's streamText function with maxSteps to enable the AI to perform complex reasoning over multiple steps.
  • Reasoning Tool Integration: Incorporates a reasoning tool to enhance the chatbot's ability to understand and respond to intricate user queries.
  • Next.js Framework: Built on Next.js, offering a robust and scalable foundation for web applications.
  • Vercel AI SDK: Leverages the Vercel AI SDK for seamless integration with various AI models.

Learn More:

For further details, refer to these resources:

Information

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates