# save()

Canonical URL: https://developers.iagenify.com/ar/sdk/ref/memory/save/
Language: ar

`api.memory.save(note) → Promise<Memory>`

ينشئ a ملاحظة أو يستبدل مع الاسم الاسم الاسم هو الهوية ليس مُنتقى تحديث.

Status: POST /api/ai/memories · free · upsert by name

## المعاملات {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `name` | string | مطلوب | أي شيء آخر يتم تحويله، ما لا يمكن رفضه. |
| `content` | string | مطلوب | الملاحظة بحد ذاتها، تصل إلى 4 آلاف حرف، الفراغ مرفوض |
| `description` | string |  | وهذا ما يراه الوكيل عند الاختيار — انظر [أولاً-](#description). |
| `type` | string |  | `preference` · `project` · `fact` · `correction` · `other`القيم المجهولة التي أصبحت `other`. |
| `source` | string |  | `user` أو `agent`أي شيء لا يعني `user` & `agent`. |
| `sessionId` | string |  | لقد تعلمت هذه الجلسة عندما كانت هناك واحدة |

## الاسم هو الهوية {#name}

حفظ الاسم الموجود بالفعل محل تلك الملاحظة. هذا هو آلية التحديث بأكملها، ولهذا السبب يستحق الاسم الاختيار حسناً: إنه الشيء الذي يجب أن تتطابق معه لاحقاً.

```javascript
await api.memory.save({ name: "tone-of-voice", content: "Short answers.", source: "user" });
await api.memory.save({ name: "tone-of-voice", content: "Short answers, in French.", source: "user" });
// One note. The second content replaced the first.
```

| ما تمر به | مُز |
| --- | --- |
| طين صوت | )لنغ في المائة |
| user_preferences | المستخدم |
| ! ! ! ! ! | دال - |
| ! ! | رُرِعت - invalid_name |

> **تم تحويل الأسماء، لم يتم التصديق عليها**
>
> اثنان مختلف الاسمان يمكن أن يلتقيا على واحد، والثاني حفظ ثم يستبدل الملاحظة الأولى دون أن يقول ذلك. اختر أسماء بسيطة، مستقرة، واقرأ الاسم الذي يأتي عندما بنيته من مدخل المستخدم.

## اكتب الوصف للعامل {#description}

The content is only opened when a note looks relevant, and relevance is judged on the description alone. So the description should say *when this is worth reading*, not what it contains.

| الوصف الوكِش | مُحسن |
| --- | --- |
| `4` `4` | " كيف يريد هذا المستخدم أن يكتب إلى |
| `قاعدة بيانات | `أي قاعدة بيانات تستخدم، والذي لا يمكن لمسه أبداً` |
| `مذكرات بشأن المشروع` | `قواعد نشر هذا المشروع، بما في ذلك ما هو محظور |

## القيمة المُعادة {#returns}

```javascript
const note = await api.memory.save({
  name: "deploy-rules",
  description: "The deploy rules for this project, including what is forbidden",
  content: "No deploys on Friday. Staging first, always. Migrations run separately.",
  type: "project",
  source: "user",
});

note.name;        // "deploy-rules"
note.type;        // "project"
note.updatedAt;
```

( ١ بطرس ٣ : ١ ) فَٱلْمَحَبَّةُ ٱلْمُخْزَنَةُ ٱلْمُخْزَنَةُ ، بَعْدَمَا يُحَوَّلُ ٱلْأَسْمَ وَيُصَلِّحُ ٱلْنَّصُ إلى حُدِّهَا ، قَرِّئْهَا مُقَدَّمَةً بِأَنَّ مَا أَرْسَلَتَهُ هُوَ مَا حُفِظَ .

## الأخطاء {#errors}

| الرمز | الحالة | متى |
| --- | --- | --- |
| invalid_name | 400 | ولم يترك أي شيء يمكن استخدامه بعد التحويل. |
| content_required | 400 | المحتوى كان فارغ أو فقط أبيض فراغ. |
| too_many_memories | 400 | 200 ملاحظة بالفعل، وهذا سيكون واحد جديد. |

`too_many_memories` تطبيق *الجديدة الجديدة الجديدة* ( ١ تيموثاوس ٣ : ١ ) وَهذَا مَا يَجِبُ أَنْ يَحْدُثَ ٱلْكَلِمَةُ ٱلْمُتَمَسَّةُ بِٱلْمَحَبَّةِ .

```javascript
import { IaGenifyError } from "iagenify";

try {
  await api.memory.save({ name, content, description, type, source: "user" });
} catch (err) {
  if (err instanceof IaGenifyError && err.code === "too_many_memories") {
    // Let the user choose what goes. Do not evict on their behalf.
    return { needsPruning: await api.memory.list() };
  }
  throw err;
}
```

## و لماذا يستحق الأمر أن يُقام {#source}

أي شيء غير موجود `"user"` (أ) `agent`وَبِأَنَّهُ بِأَنَّهُ يَتَحَلَّى بِصِفَةٍ بِٱلْبَشَرِ يَفْتَرِقُهُمْ « أَنْتَ أَنْتَ تَتَعَلَّمَ مِنْهُ » .

- [list()](/ar/sdk/ref/memory/list): كل ما قرأته هو ما قبله، المحتوى ضمنه
- [delete()](/ar/sdk/ref/memory/delete): -إزالة واحدة

```python
api.memory.save(name="tone-of-voice", content="Short answers.", source="user")
api.memory.save(name="tone-of-voice", content="Short answers, in French.", source="user")
# One note. The second content replaced the first.
```

```python
note = api.memory.save(
    name="deploy-rules",
    description="The deploy rules for this project, including what is forbidden",
    content="No deploys on Friday. Staging first, always. Migrations run separately.",
    type="project",
    source="user",
)

note["name"]        # "deploy-rules"
note["type"]        # "project"
note["updatedAt"]
```

```python
from iagenify import IaGenifyError

try:
    api.memory.save(name=name, content=content, description=description, type=kind, source="user")
except IaGenifyError as error:
    if error.code != "too_many_memories":
        raise
    # Let the user choose what goes. Do not evict on their behalf.
    needs_pruning = api.memory.list()
```
