Create a personal assistant that helps with various tasks:
Copy
import { TruffleAI } from 'truffle-ai';const truffle = new TruffleAI('your-api-key');const assistant = await truffle.deployAgent({ name: 'Personal Assistant', instruction: `You are a helpful personal assistant who: - Provides clear and concise responses - Maintains a friendly tone - Helps users with their tasks - Remembers context from previous interactions`, model: 'gpt-4o-mini', tool: 'Google Calendar' // Authentication is required for this tool via dashboard});// Run one-off tasksconst taskResponse = await assistant.run("What's on my schedule today?");console.log(taskResponse);// Start an interactive sessionconst chat = assistant.chat();const responses = await Promise.all([ chat.send('Can you help me plan my week?'), chat.send('I need to schedule a meeting for tomorrow'), chat.send('Also remind me to buy groceries')]);// Check conversation historyconst history = chat.getHistory();console.log('Conversation History:', history);
Create a Q&A system that provides accurate information:
Copy
const qaBot = await truffle.deployAgent({ name: 'Research Assistant', instruction: `You are a research assistant who: - Provides accurate, factual information - Cites sources when possible - Admits when information is uncertain - Explains complex topics clearly - Uses examples to illustrate concepts`, model: 'gpt-4o-mini', tool: 'Tavily Research'});// Ask specific questionsconst answer1 = await qaBot.run('What is quantum computing?');console.log('Quantum Computing:', answer1);const answer2 = await qaBot.run('Explain machine learning in simple terms');console.log('Machine Learning:', answer2);// Interactive learning sessionconst chat = qaBot.chat();await chat.send('I want to learn about artificial intelligence');await chat.send('What should I study first?');await chat.send('Can you create a learning plan for me?');
Create an agent that helps repurpose YouTube content:
Copy
const contentAgent = await truffle.deployAgent({ name: 'Content Creator', instruction: `You are a content creator who: - Writes engaging and clear content - Adapts tone to match the target audience - Provides creative suggestions - Helps with editing and improvement - Maintains consistent style`, model: 'gpt-4o-mini', tool: 'YouTube Transcript'});// Convert YouTube video to blog postconst blogPost = await contentAgent.run( 'Convert this YouTube video to a blog post: https://youtube.com/watch?v=example');console.log('Blog Post:', blogPost);// Interactive content repurposingconst chat = contentAgent.chat();await chat.send('I want to turn this YouTube video into social media content: https://youtube.com/watch?v=example');await chat.send('Can you create 5 Twitter threads from the key points?');await chat.send('Now let's create some LinkedIn carousel slides from the main concepts');
For examples of how to create agents that can access and utilize knowledge from custom documents using Retrieval Augmented Generation (RAG), see our dedicated RAG documentation: