Merge pull request #14 from Pierre-Mike/docs/fix-readme

adding a simple example which work with gpt-3.5-turbo.
This commit is contained in:
Wlad Paiva
2023-11-02 11:21:11 -03:00
committed by GitHub
2 changed files with 47 additions and 1 deletions
+1 -1
View File
@@ -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.
+46
View File
@@ -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.`,
})
}