mirror of
https://github.com/Mintplex-Labs/abitat.git
synced 2026-07-01 10:05:27 -04:00
adding a simple example which work with gpt-3.5-turbo.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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.`,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user