Welcome to the localtrain.ai Typescript SDK! A powerful TypeScript toolkit designed to help you seamlessly build AI-powered agents using any LLMs on runtimes like Node.js. Explore the SDK to integrate AI into your applications effortlessly and scale your capabilities!
Before you dive in, make sure you have Node.js installed on your machine.
Installation
First, install the Core Package of localtrain.ai:Using npm
Using yarn
π Usage Guide
Example: Building an AI Agent with the SDK Core
Letβs walk through creating a Customer Feedback Analyzer Agent step by step:Step 1: Initialize the SDK
Start by importing the required components and initializing the localtrain.ai SDK:LocalTrain.initialize() sets up the SDK, making it ready to use.
Step 2: Attach Providers to the Registry
Add the necessary providers (e.g., OpenAI) for your agent to use:LocalTrain.useProviders() function registers the providers, allowing your agent to leverage their services (e.g., OpenAI for LLM functionalities).
Step 3: Create and Configure the Agent
Define an agent with its configuration and purpose:feedbackAgent and specifying its name, description, and behaviors. Each behavior defines how the agent interacts with the OpenAI provider.
Step 4: Run the Agent
Finally, run the agent with a custom prompt:run() method executes the agent with the given prompt and logs the results.