1.1.10 • Published 11 months ago

chariotai v1.1.10

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Chariot Node.js library

The Chariot Node.js library provides convenient access to the Chariot API from applications written in Node.js.

https://www.npmjs.com/package/chariotai

Installation

npm install chariotai

Documentation

Full docs and api reference can be found at chariotai.com/docs

Usage

To use the Chariot API, you'll need to create an api key in the Chariot Dashboard.

import { Chariot } from 'chariotai';

const chariot = new Chariot(process.env.CHARIOT_API_KEY);

const applications = await chariot.listApplications();

console.log(applications);

Or without ES modules and async/await:

const { Chariot } = require('chariotai');

const chariot = new Chariot(process.env.CHARIOT_API_KEY)

chariot.listApplications()
  .then(applications => console.log(applications))
  .catch(error => console.error(error));

Streaming conversations

You can use streamConversation() to read the server-sent event stream from the Chariot API:

import { Chariot } from 'chariotai';

const chariot = new Chariot(process.env.CHARIOT_API_KEY);

// If no conversation_id is provided, a new conversation will be created
const conversation = await chariot.streamConversation({
  message: message,
  application_id: 'app_MDUxZmU4'
})

// Triggered for each new message chunk
// Includes the message chunk, conversation_id, and conversation title
conversation.on('message', (message: any) => {
  console.log(message);
});

// Triggered when the stream ends successfuly
// Includes total token count and sources used by the LLM
conversation.on('complete', (data: any) => {
  console.log('Streaming completed:', data);
});

// Triggered when the stream ends (successfuly or not)
conversation.on('end', () => {
  console.log('Stream ended');
});

// Triggered when there is an error during the stream
conversation.on('error', (data: any) => {
  console.log('Error:', data);
});

// Aborts the stream and terminates the request
conversation.abort();

Alternatively, if you want to work with the raw server-sent event stream, you can make a POST request to the /conversations endpoint manually.

1.1.10

11 months ago

1.1.9

11 months ago

1.1.8

11 months ago

1.1.7

11 months ago

1.1.6

11 months ago

1.1.5

11 months ago

1.1.4

11 months ago

1.1.3

12 months ago

1.1.2

12 months ago

1.1.1

12 months ago

1.1.0

12 months ago

1.0.16

12 months ago

1.0.15

12 months ago

1.0.14

12 months ago

1.0.13

12 months ago

1.0.12

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago