Skip to content

Commit b570322

Browse files
committed
docs: add multi-agent and non-streaming examples to README
1 parent 189e9ba commit b570322

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,54 @@ for await (const step of planner.executePlan(plan.id)) {
376376
}
377377
```
378378

379+
### Multi-Agent Collaboration
380+
381+
```typescript
382+
import { AgentOS, AgencyRegistry, AgentCommunicationBus } from '@framers/agentos';
383+
384+
// Create specialized agents
385+
const researcher = new AgentOS();
386+
await researcher.initialize({ llmProvider: llmConfig, persona: 'Research analyst' });
387+
388+
const writer = new AgentOS();
389+
await writer.initialize({ llmProvider: llmConfig, persona: 'Technical writer' });
390+
391+
// Register in agency with shared communication
392+
const agency = new AgencyRegistry();
393+
const bus = new AgentCommunicationBus();
394+
agency.register('researcher', researcher, { bus });
395+
agency.register('writer', writer, { bus });
396+
397+
// Agents coordinate via message passing
398+
bus.on('research:complete', async ({ findings }) => {
399+
await writer.processRequest({
400+
message: `Write documentation based on: ${JSON.stringify(findings)}`
401+
});
402+
});
403+
404+
await researcher.processRequest({ message: 'Analyze the authentication module' });
405+
```
406+
407+
### Non-Streaming Response
408+
409+
```typescript
410+
import { AgentOS } from '@framers/agentos';
411+
412+
const agent = new AgentOS();
413+
await agent.initialize({
414+
llmProvider: { provider: 'openai', apiKey: process.env.OPENAI_API_KEY, model: 'gpt-4o' }
415+
});
416+
417+
// Collect full response without streaming
418+
const chunks = [];
419+
for await (const chunk of agent.processRequest({ message: 'Explain OAuth 2.0 briefly' })) {
420+
if (chunk.type === 'content') {
421+
chunks.push(chunk.content);
422+
}
423+
}
424+
const fullResponse = chunks.join('');
425+
```
426+
379427
---
380428

381429
## Roadmap

0 commit comments

Comments
 (0)