@gensx/vercel-ai-sdk
TypeScript icon, indicating that this package has built-in type declarations

0.1.17 • Public • Published

@gensx/vercel-ai-sdk

Vercel AI SDK for GenSX

Installation

npm install @gensx/vercel-ai-sdk

Requires gensx

This package requires gensx to be installed as a peer dependency.

npm install gensx

Usage

import * as gensx from "@gensx/core";
import { GenerateText, StreamText } from "@gensx/vercel-ai-sdk";

const ChatBot = gensx.Component(async ({ userInput }) => {
  return (
    <GenerateText
      messages={[
        { role: "system", content: "You are a helpful assistant." },
        { role: "user", content: userInput },
      ]}
      model="gpt-4o"
      temperature={0.7}
    />
  );
});

// Use with streaming
const StreamingChat = gensx.Component(async ({ userInput }) => {
  return (
    <StreamText
      messages={[
        { role: "system", content: "You are a helpful assistant." },
        { role: "user", content: userInput },
      ]}
      stream={true}
    >
      {async (stream) => {
        for await (const token of stream) {
          process.stdout.write(token);
        }
      }}
    </StreamText>
  );
});

Readme

Keywords

Package Sidebar

Install

npm i @gensx/vercel-ai-sdk

Weekly Downloads

58

Version

0.1.17

License

Apache-2.0

Unpacked Size

31.2 kB

Total Files

14

Last publish

Collaborators

  • jmoseley
  • evanboyle