alith
TypeScript icon, indicating that this package has built-in type declarations

0.5.1 • Public • Published

Alith Node SDK

Installation

  • Install alith dependency
npm install alith
# Or use pnpm `pnpm install alith`
# Or use yarn `yarn install alith`
  • Install the json-schema dependency
npm i --save-dev @types/json-schema
# Or use pnpm `pnpm install --save-dev @types/json-schema`
# Or use yarn `yarn install --save-dev @types/json-schema`

Quick Start

  • Simple Agent
import { Agent } from "alith";

const agent = new Agent({
  model: "gpt-4o-mini",
  preamble:
    "You are a calculator here to help the user perform arithmetic operations. Use the tools provided to answer the user question.",
});
console.log(await agent.prompt("Calculate 10 - 3"));
  • Agent with Tools
import { Agent } from "alith";

const agent = new Agent({
  model: "gpt-4o-mini",
  preamble:
    "You are a calculator here to help the user perform arithmetic operations. Use the tools provided to answer the user question.",
  tools: [
    {
      name: "subtract",
      description: "Subtract y from x (i.e.: x - y)",
      parameters: JSON.stringify({
        type: "object",
        properties: {
          x: {
            type: "number",
            description: "The number to substract from",
          },
          y: {
            type: "number",
            description: "The number to substract",
          },
        },
      }),
      handler: (x: number, y: number) => {
        return x - y;
      },
    },
  ],
});
console.log(await agent.prompt("Calculate 10 - 3"));

Examples

See here for more examples.

Developing

  • Install node.js
  • Install cargo (for Rust code)

Install dependencies

npm install

Building

npm run build

Testing

npm test

Format

npm run format

Readme

Keywords

none

Package Sidebar

Install

npm i alith

Weekly Downloads

49

Version

0.5.1

License

Apache-2.0

Unpacked Size

50.2 kB

Total Files

19

Last publish

Collaborators

  • nora-lazai-xyz