Temel Alt Ajanlar

Karmaşık görev dağıtımı için birden fazla yapay zeka ajanı oluşturun ve koordine edin.

Hızlı Başlangıç#

Eksiksiz Örneği Klonlayın#

Başlamanın en kolay yolu, eksiksiz örnek repository'sini klonlamaktır:

bash
git clone https://github.com/astreus-ai/examples
cd examples/sub-agents-basic
npm install

Ya da Sadece Paketi Yükleyin#

Sıfırdan oluşturmayı tercih ediyorsanız:

bash
npm install @astreus-ai/astreus

Ortam Kurulumu#

bash
# .env
OPENAI_API_KEY=sk-your-openai-api-key-here
DB_URL=sqlite://./astreus.db

Basit Alt Ajan Kurulumu#

typescript
import { Agent } from '@astreus-ai/astreus';

// Create specialized sub-agents
const researcher = await Agent.create({
  name: 'Researcher',
  model: 'gpt-6-astra',
  systemPrompt: 'You are an expert researcher who gathers comprehensive information.'
});

const writer = await Agent.create({
  name: 'Writer',
  model: 'gpt-6-astra',
  systemPrompt: 'You are a skilled writer who creates clear, engaging content.'
});

// Create main coordinator agent
const mainAgent = await Agent.create({
  name: 'Coordinator',
  model: 'gpt-6-astra',
  systemPrompt: 'You coordinate tasks between specialized agents.',
  subAgents: [researcher, writer]
});

// Use auto delegation
const result = await mainAgent.ask(
  'Research artificial intelligence trends and write a summary',
  {
    useSubAgents: true,
    delegation: 'auto'
  }
);

console.log(result);

Örneği Çalıştırma#

Repository'yi klonladıysanız:

bash
npm run dev

Sıfırdan oluşturduysanız, yukarıdaki kodla bir index.ts dosyası oluşturun ve şunu çalıştırın:

bash
npx tsx index.ts

Repository#

Eksiksiz örnek GitHub üzerinde mevcuttur: examples/sub-agents-basic