Skip to content

ahmadawais/ai-stack

Repository files navigation

ai-stack

DOWNLOADS Node.js CLI Learn VSCode Sponsor Follow @MrAhmadAwais on Twitter

AI Stack for AI Engineers

AI Stack simplifies the creation and management of AI agents using the Langbase SDK.


πŸ“Ÿ

Install

npm install ai-stack
pnpm install ai-stack

βš™οΈ

Usage

Full documentation is available at Langbase SDK. First, set up your environment variables by creating a .env file in your project root:

LANGBASE_API_KEY=your_api_key_here

Replace your_api_key_here with your actual Langbase API key.

Then, use the package in your project:

import {
createAgent,
runAgent,
createMemory,
uploadDocument,
retrieveMemory,
} from 'ai-stack';

const agentConfig = {
name: 'MyAgent',
description: 'An AI agent for processing data',
// Add other configuration details as needed
};

async function main() {
// Create an agent
const agent = await createAgent(agentConfig);

// Run the agent
const response = await runAgent(agent.name, [
	{ role: 'user', content: 'Your input here' },
]);
console.log('Agent response:', response);

// Create a memory
const memory = await createMemory({
	name: 'knowledge-base',
	description: 'A memory for storing documents',
});

// Upload a document to memory
await uploadDocument('knowledge-base', {
	contentType: 'application/pdf',
	documentName: 'example-doc.pdf',
	document: fs.readFileSync('path/to/document.pdf'),
	meta: {
	author: 'Author Name',
	url: 'https://example.com/document.pdf',
	},
});

// Retrieve information from memory
const results = await retrieveMemory('knowledge-base', 'Your query here');
console.log('Memory retrieval results:', results);
}

main();

πŸ“

Changelog

❯ Read the changelog here β†’


KEY: πŸ“¦ NEW, πŸ‘Œ IMPROVE, πŸ› FIX, πŸ“– DOC, πŸš€ RELEASE, and πŸ€– TEST

I use Emoji-log, you should try it and simplify your git commits.


πŸ“ƒ

License & Conduct


πŸ™Œ

Connect

GitHub @AhmadAwais (follow) To stay up to date on free & open-source software

Twitter @MrAhmadAwais (follow) To get #OneDevMinute daily hot tips & trolls

YouTube AhmadAwais (subscribe) To tech talks & #OneDevMinute videos

Blog: AhmadAwais.com (read) In-depth & long form technical articles

LinkedIn @MrAhmadAwais (connect) On the LinkedIn profile y'all