alith
v0.12.3
Published
## Installation
Readme
Alith Node SDK
Installation
- Install
alithdependency
npm install alith
# Or use pnpm `pnpm install alith`
# Or use yarn `yarn install alith`- Install the
json-schemadependency
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`- Install
dotenv(for environment variables):
npm install dotenv
# Or use pnpm `pnpm install dotenv`
# Or use yarn `yarn install dotenv`- Create a
.envfile in your project root
LLM_API_KEY=<your_api_key>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"));- Running Examples
npx ts-node examples/agent_with_async_tool_handlers.tsExamples
See here for more examples.
Developing
- Install node.js
- Install cargo (for Rust code)
Install dependencies
npm installRust build errors
rustup updateBuilding
npm run buildTesting
npm testFormat
npm run format