import { TruffleAI } from 'truffle-ai';
async function main() {
// Initialize client
const truffle = new TruffleAI('your-api-key');
// Create an agent
const agent = await truffle.deployAgent({
name: 'Support Assistant',
instruction: 'You are a customer support specialist who helps users with their questions.',
model: 'gpt-4o-mini'
});
// Run a one-off task
const taskResult = await agent.run('What are your main responsibilities?');
console.log('Task Result:', taskResult);
// Start a chat session
const chat = agent.chat();
// Have a conversation
const responses = await Promise.all([
chat.send('Hi! I need help with my account.'),
chat.send('How do I change my password?'),
chat.send('Thanks for your help!')
]);
// Get chat history
const history = chat.getHistory();
console.log('Chat History:', history);
}
main().catch(console.error);