### Project Setup and Execution Source: https://github.com/wladpaiva/aibitat/blob/main/README.md Instructions for setting up the project and running examples. This involves installing dependencies using Bun and executing example scripts. ```bash bun install ``` ```bash bun run examples/beginner-chat.ts ``` -------------------------------- ### Install AIbitat with Bun Source: https://github.com/wladpaiva/aibitat/blob/main/README.md Steps to set up a new project using Bun, install the AIbitat package, and configure the OpenAI API key. ```bash mkdir my-project cd my-project bun init bun install aibitat # Create .env file with your API key OPENAI_API_KEY=... ``` -------------------------------- ### Basic AIbitat Usage Example Source: https://github.com/wladpaiva/aibitat/blob/main/README.md A TypeScript example demonstrating how to create an AIbitat instance, define agents with roles, set up a channel, and start a conversation. ```typescript import {AIbitat} from 'aibitat' import {cli} from 'aibitat/plugins' const aibitat = new AIbitat() .use(cli()) .agent('client', { interrupt: 'ALWAYS', role: 'You are a human assistant. Reply "TERMINATE" when there is a correct answer or there`s no answer to the question.', }) .agent('mathematician', { role: `You are a Mathematician and only solve math problems from @client`, }) .agent('reviewer', { role: `You are a Peer-Reviewer and you do not solve math problems. Check the result from @mathematician and then confirm. Just confirm, no talk.`, }) .channel('management', ['mathematician', 'reviewer', 'client']) // aibitat.onMessage(console.log) await aibitat.start({ from: 'client', to: 'management', content: 'How much is 2 + 2?', }) console.log(aibitat.chats) ``` -------------------------------- ### Create Custom Plugins Source: https://github.com/wladpaiva/aibitat/blob/main/README.md Provides a template for creating custom AIbitat plugins. A plugin is defined as a function returning an object implementing the `AIbitatPlugin` interface, which includes a `name` and a `setup` method. The `setup` method receives the AIbitat instance and can register event listeners or add new functionality. ```typescript import {AIbitatPlugin} from 'aibitat' export function myPlugin(): AIbitatPlugin { return { name: 'my-plugin', setup(aibitat) { console.log(`setting up my plugin`) aibitat.onMessage(({from, to, content}) => { console.log(`${from}: ${content}`) }) }, } } ``` -------------------------------- ### AIbitat Constructor Configuration Source: https://github.com/wladpaiva/aibitat/blob/main/README.md Details the default configuration options for the AIbitat constructor, including providers, models, and conversation settings. ```APIDOC new AIbitat(config) - Creates a new AIbitat instance. - The `config` object can be used to configure the instance. - By default, aibitat uses **OpenAI** and **GPT-3.5-TURBO** as the provider for the conversation and **GPT-4** for predicting the next agent to speak. - You can change it by passing `provider` and `model` to the `AIbitat` constructor or by setting them on the specific agent/channel config. Default config: { providers: 'openai', model: 'gpt-3.5-turbo', interrupt: 'NEVER', maxRounds: 100, chats: [ // { from: '🧑', to: '🤖', content: `Talk about something`, state: 'success' }, ] } .agent(name, config) - Creates a new agent. - The `config` object can be used to configure the agent. - By default, agents use the `interrupt` from the `AIbitat` config. .channel(name, agents, config) - Creates a new channel. - The `config` object can be used to configure the channel. - By default, `maxRounds` is set to `100`. ``` -------------------------------- ### Use Built-in Plugins Source: https://github.com/wladpaiva/aibitat/blob/main/README.md Illustrates how to extend AIbitat's capabilities by using built-in plugins. The `cli()` plugin adds CLI interaction, while others like `fileHistory` and `experimental_webBrowsing` offer additional features. ```typescript import {cli} from 'aibitat/plugins' const aibitat = new AIbitat().use(cli()) ``` -------------------------------- ### Define and Use Functions Source: https://github.com/wladpaiva/aibitat/blob/main/README.md Demonstrates how to define functions for AIbitat agents to execute. Functions are registered with a name, description, parameters, and an asynchronous handler. The function name must be added to the agent's configuration to be callable. ```typescript const aibitat = new AIbitat() .agent('...', {functions: ['doSomething']}) .function({ name: 'doSomething', description: 'Let me do something for you.', parameters: { type: 'object', properties: {}, }, async handler() { return '...' }, }) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.