diff --git a/README.md b/README.md index a812358..b946578 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ bun install To run: ```bash -bun run examples/1-basic.ts +bun run examples/beginner-chat.ts ``` > Check out the [examples](./examples) folder for more examples. diff --git a/examples/beginner-chat.ts b/examples/beginner-chat.ts new file mode 100644 index 0000000..1a6ff56 --- /dev/null +++ b/examples/beginner-chat.ts @@ -0,0 +1,46 @@ +import * as cheerio from 'cheerio' + +import {AIbitat} from '../src' +import {cli} from '../src/plugins' + +enum Agent { + HUMAN = '🧑', + AI = '🤖', +} + +export const aibitat = new AIbitat({ + provider: 'openai', + model: 'gpt-3.5-turbo', +}) + .use(cli()) + .function({ + name: 'aibitat-documentations', + description: 'The documentation about aibitat AI project.', + parameters: { + type: 'object', + properties: {}, + }, + handler: async () => { + const response = await fetch( + 'https://raw.githubusercontent.com/wladiston/aibitat/main/README.md', + ) + const html = await response.text() + const text = cheerio.load(html).text() + return text + }, + }) + .agent(Agent.HUMAN, { + interrupt: 'ALWAYS', + role: 'You are a human assistant.', + }) + .agent(Agent.AI, { + functions: ['aibitat-documentations'], + }) + +if (import.meta.main) { + await aibitat.start({ + from: Agent.HUMAN, + to: Agent.AI, + content: `Please, talk about the documentation of AIbitat.`, + }) +}