Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI improvements #12

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brown-apes-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'aibitat': patch
---

Improve cli for better feedback to what is happening
6 changes: 6 additions & 0 deletions .changeset/five-badgers-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'aibitat': patch
---

Added `.onThinking` event to better track when AI providers are generating
responses
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"typescript.tsdk": "node_modules/typescript/lib"
}
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
This project is a fork from the original
[autogen](https://github.com/microsoft/autogen) but done in TypeScript.

# AIbitat - Multi-Agent Conversation Framework
# AIbitat 🗯️🗯️💬 - Multi-Agent Conversation Framework

AIbitat is a stateless & extensible framework designed to enable interaction
between multiple agents while allowing human participation.
Expand Down Expand Up @@ -130,7 +130,7 @@ config:
// from: '🧑',
// to: '🤖',
// content: `Talk about something`,
// state: 'success',
// state: 'replied',
// },
],
}
Expand Down Expand Up @@ -233,6 +233,10 @@ The following events are available:
- `onInterrupt`: Called when the conversation is interrupted by an agent.
Generally means the agent has a question or needs help. The conversation can
be resumed by calling `.continue(feedback)`.
- `onThinking`: Called when a message is sent to the provider. Generally means
the provider is thinking and the conversation is waiting for a response.
`thinking` status is added to the chat history and gets replaced by either
`replied` or `error`.

## Contributing

Expand Down
Binary file modified bun.lockb
Binary file not shown.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@
"@inquirer/prompts": "^3.2.0",
"chalk": "^5.3.0",
"debug": "^4.3.4",
"ink": "4.3.1",
"ink-spinner": "^5.0.0",
"langchain": "^0.0.169",
"node-html-markdown": "^1.3.0",
"openai": "^4.11.1"
"openai": "^4.11.1",
"pretty-ms": "^8.0.0",
"react": "^18.2.0"
},
"nano-staged": {
"*.{js,jsx,json,yml,yaml,css,ts,tsx,md,mdx}": "prettier --write"
Expand Down
45 changes: 37 additions & 8 deletions src/aibitat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ describe('direct message', () => {
from: '🤖',
to: '🧑',
content: 'TERMINATE',
state: 'success',
state: 'replied',
// @ts-expect-error
time: expect.any(Number),
})
})

Expand Down Expand Up @@ -92,7 +94,8 @@ describe('direct message', () => {
from: '🧑',
to: '🤖',
content: '2 + 2 = 4?',
state: 'success',
state: 'replied',
time: 2,
},
],
})
Expand All @@ -110,7 +113,8 @@ describe('direct message', () => {
from: '🧑',
to: '🤖',
content: '2 + 2 = 4?',
state: 'success',
state: 'replied',
time: 2,
})
})

Expand Down Expand Up @@ -180,8 +184,9 @@ describe('direct message', () => {
})

expect(p).resolves.toBeTrue()
// @ts-expect-error
expect(aibitat.chats[3].content).toBe('...')
expect(aibitat.chats[3].state).toBe('success')
expect(aibitat.chats[3].state).toBe('replied')
expect(aibitat.chats).toHaveLength(5)
})

Expand Down Expand Up @@ -211,14 +216,16 @@ describe('direct message', () => {
expect(p).resolves.toBeTrue()
expect(aibitat.chats[2].from).toBe('🧑')
expect(aibitat.chats[2].to).toBe('🤖')
expect(aibitat.chats[2].state).toBe('seeded')
// @ts-expect-error
expect(aibitat.chats[2].content).toBe('my feedback')
})
})

describe('as a group', () => {
const members = ['🐶', '😸', '🐭']

let aibitat: AIbitat
let aibitat: AIbitat<any>

beforeEach(() => {
ai.create.mockImplementation(x => {
Expand Down Expand Up @@ -258,6 +265,26 @@ describe('as a group', () => {
})
})

test('should be thinking while LLM generate responses', async () => {
const aibitat = new AIbitat({provider})
.agent('🧑', {interrupt: 'ALWAYS'})
.agent('🤖')

const callback = mock(() => {
expect(aibitat.chats).toHaveLength(2)
expect(aibitat.chats.at(-1)).toEqual({
from: '🤖',
to: '🧑',
state: 'thinking',
})
})
aibitat.onThinking(callback)

await aibitat.start(defaultStart)

expect(callback).toHaveBeenCalledTimes(1)
})

test.todo('should call a function', async () => {
// FIX: I can't mock the API yet
// ai.create.mockImplementation(() =>
Expand Down Expand Up @@ -339,7 +366,7 @@ describe('when errors happen', () => {
from: '🤖',
to: '🧑',
content: 'known error!!!',
state: 'error',
state: 'failed',
})
})

Expand Down Expand Up @@ -382,7 +409,7 @@ describe('when errors happen', () => {
from: '🤖',
to: '🧑',
content: '401: Rate limit',
state: 'error',
state: 'failed',
})

await aibitat.retry()
Expand All @@ -393,7 +420,9 @@ describe('when errors happen', () => {
from: '🤖',
to: '🧑',
content: 'TERMINATE',
state: 'success',
state: 'replied',
// @ts-expect-error
time: expect.any(Number),
})
})
})
Loading