JSPM

  • Created
  • Published
  • Downloads 34832
  • Score
    100M100P100Q141956F
  • License Apache-2.0

Package Exports

  • langbase
  • langbase/package.json

Readme

Langbase SDK

The AI framework for building declarative and composable AI-powered LLM products.

Getting Started with langbase SDK

Installation

First, install the langbase package using npm or yarn:

npm install langbase

or

pnpm add langbase

or

yarn add langbase

Usage

You can generateText or streamText based on the type of a pipe.

import 'dotenv/config';
import {Pipe} from 'langbase';

// STREAM: OFF
const pipeStreamOff = new Pipe({
    apiKey: process.env.PIPE_LESS_WORDY!,
});

const result = await pipeStreamOff.generateText({
    messages: [{role: 'user', content: 'Who is Ahmad Awais?'}],
});

console.log(result.completion);

// STREAM: ON
const pipeStreaming = new Pipe({
    apiKey: process.env.PIPE_LESS_WORDY_STREAM!,
});

const stream = await pipeStreaming.streamText({
    messages: [{role: 'user', content: 'Who is Ahmad Awais?'}],
});

for await (const chunk of stream) {
    process.stdout.write(chunk.choices[0]?.delta?.content || '');
}