Skip to content

AI İkizlerini Yönetme

Bu öğreticide bir AI dijital ikiz oluşturacak, kişiselleştirmek için anılar ekleyecek, eylemler tetikleyecek ve tam CRUD işlemleri gerçekleştireceksiniz. İkiz, verilerinizden öğrenen ve sizin adınıza hareket edebilen kişiselleştirilmiş bir AI varlığıdır.

Ön Koşullar

  • Geçerli bir erişim token'ına sahip bir Chainabit hesabı
  • Terminalinizde kullanılabilir durumda curl
  • AI kredileri içeren bir plan

Ortam değişkenlerinizi ayarlayın:

bash
export TOKEN="your-access-token"

İkiz Mimarisi


Adım 1: AI İkiz Oluşturma

Bir kişilik ile yeni bir dijital ikiz oluşturun:

bash
curl -s -X POST "https://api.chainabit.com/api/v1/agents/twins" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Productivity Coach",
    "persona": "A focused, encouraging productivity coach that helps maintain daily routines.",
    "modelId": "model_01HQ..."
  }'
javascript
const res = await fetch(`https://api.chainabit.com/api/v1/agents/twins`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Productivity Coach',
    persona:
      'A focused, encouraging productivity coach that helps maintain daily routines.',
    modelId: 'model_01HQ...',
  }),
});
const data = await res.json();
console.log(data);
python
import requests

res = requests.post(
    f"{BASE}/agents/twins",
    headers={
        "Authorization": f"Bearer {TOKEN}",
        "Content-Type": "application/json",
    },
    json={
        "name": "Productivity Coach",
        "persona": "A focused, encouraging productivity coach that helps maintain daily routines.",
        "modelId": "model_01HQ...",
    },
)
print(res.json())

Yanıt:

json
{
  "data": {
    "id": "twin_01HQA...",
    "name": "Productivity Coach",
    "persona": "A focused, encouraging productivity coach that helps maintain daily routines.",
    "status": "active",
    "createdAt": "2026-03-17T10:00:00.000Z"
  }
}

İkiz kimliğini kaydedin:

bash
export TWIN_ID="twin_01HQA..."

Adım 2: Anı Ekleme

Anılar, ikizinize tercihleriniz ve alışkanlıklarınız hakkında bağlam sağlar:

bash
curl -s -X POST "https://api.chainabit.com/api/v1/agents/twins/$TWIN_ID/memories" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "preference",
    "content": "User prefers morning workouts between 6:00 and 7:00 AM.",
    "importance": "high"
  }'
javascript
const res = await fetch(`https://api.chainabit.com/api/v1/agents/twins/${TWIN_ID}/memories`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    type: 'preference',
    content:
      'User prefers morning workouts between 6:00 and 7:00 AM.',
    importance: 'high',
  }),
});
const data = await res.json();
console.log(data);
python
res = requests.post(
    f"{BASE}/agents/twins/{TWIN_ID}/memories",
    headers={
        "Authorization": f"Bearer {TOKEN}",
        "Content-Type": "application/json",
    },
    json={
        "type": "preference",
        "content": "User prefers morning workouts between 6:00 and 7:00 AM.",
        "importance": "high",
    },
)
print(res.json())

Yanıt:

json
{
  "data": {
    "id": "mem_01HQB...",
    "twinId": "twin_01HQA...",
    "type": "preference",
    "content": "User prefers morning workouts between 6:00 and 7:00 AM.",
    "importance": "high",
    "createdAt": "2026-03-17T10:01:00.000Z"
  }
}

Adım 3: Eylem Tetikleme

İkizden, biriktirdiği anıları ve bağlamı kullanarak bir eylem gerçekleştirmesini isteyin:

bash
curl -s -X POST "https://api.chainabit.com/api/v1/agents/twins/$TWIN_ID/actions" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "generate_summary",
    "input": {
      "scope": "today",
      "format": "brief"
    }
  }'
javascript
const res = await fetch(`https://api.chainabit.com/api/v1/agents/twins/${TWIN_ID}/actions`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    type: 'generate_summary',
    input: { scope: 'today', format: 'brief' },
  }),
});
const data = await res.json();
console.log(data);
python
res = requests.post(
    f"{BASE}/agents/twins/{TWIN_ID}/actions",
    headers={
        "Authorization": f"Bearer {TOKEN}",
        "Content-Type": "application/json",
    },
    json={
        "type": "generate_summary",
        "input": {"scope": "today", "format": "brief"},
    },
)
print(res.json())

Yanıt:

json
{
  "data": {
    "id": "action_01HQC...",
    "twinId": "twin_01HQA...",
    "type": "generate_summary",
    "status": "completed",
    "output": "Good morning! Based on your preferences, you have 3 bits scheduled before 7 AM. You completed your running streak yesterday (day 7). Keep it going today!",
    "completedAt": "2026-03-17T10:02:00.000Z"
  }
}

Adım 4: İkizi Güncelleme

İkizin kişiliğini veya yapılandırmasını değiştirin:

bash
curl -s -X PATCH "https://api.chainabit.com/api/v1/agents/twins/$TWIN_ID" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "persona": "A focused productivity coach that specializes in fitness and nutrition routines."
  }'
javascript
const res = await fetch(`https://api.chainabit.com/api/v1/agents/twins/${TWIN_ID}`, {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    persona:
      'A focused productivity coach that specializes in fitness and nutrition routines.',
  }),
});
const data = await res.json();
console.log(data);
python
res = requests.patch(
    f"{BASE}/agents/twins/{TWIN_ID}",
    headers={
        "Authorization": f"Bearer {TOKEN}",
        "Content-Type": "application/json",
    },
    json={
        "persona": "A focused productivity coach that specializes in fitness and nutrition routines.",
    },
)
print(res.json())

Adım 5: İkizi Silme

Artık ihtiyaç duyulmayan bir ikizi kaldırın:

bash
curl -s -X DELETE "https://api.chainabit.com/api/v1/agents/twins/$TWIN_ID" \
  -H "Authorization: Bearer $TOKEN"
javascript
const res = await fetch(`https://api.chainabit.com/api/v1/agents/twins/${TWIN_ID}`, {
  method: 'DELETE',
  headers: { Authorization: `Bearer ${TOKEN}` },
});
console.log(res.status); // 204
python
res = requests.delete(
    f"{BASE}/agents/twins/{TWIN_ID}",
    headers={"Authorization": f"Bearer {TOKEN}"},
)
print(res.status_code)  # 204

Özet

Bu öğreticide şunları yaptınız:

  1. Özel bir kişilikle bir AI ikiz oluşturdunuz
  2. İkizin bağlamını kişiselleştirmek için anılar eklediniz
  3. Özet oluşturmak için bir eylem tetiklediniz
  4. İkizin kişiliğini güncellediniz
  5. İkizi sildiniz

Sonraki Adımlar

Built with purpose.