api.memory

save()

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

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

POST /api/ai/memoriesfreeupsert by name
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

المعاملات

namestringمطلوب

أي شيء آخر يتم تحويله، ما لا يمكن رفضه.

contentstringمطلوب

الملاحظة بحد ذاتها، تصل إلى 4 آلاف حرف، الفراغ مرفوض

descriptionstring

وهذا ما يراه الوكيل عند الاختيار — انظر أولاً-.

typestring

preference · project · fact · correction · otherالقيم المجهولة التي أصبحت other.

sourcestring

user أو agentأي شيء لا يعني user & agent.

sessionIdstring

لقد تعلمت هذه الجلسة عندما كانت هناك واحدة

الاسم هو الهوية

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

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.
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.
ما تمر بهمُز
طين صوت)لنغ في المائة
user_preferencesالمستخدم
! ! ! ! !دال -
! !رُرِعت - invalid_name
تم تحويل الأسماء، لم يتم التصديق عليها

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

اكتب الوصف للعامل

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`" كيف يريد هذا المستخدم أن يكتب إلى
`قاعدة بيانات`أي قاعدة بيانات تستخدم، والذي لا يمكن لمسه أبداً`
`مذكرات بشأن المشروع``قواعد نشر هذا المشروع، بما في ذلك ما هو محظور

القيمة المُعادة

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;
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"]

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

الأخطاء

الرمزالحالةمتى
invalid_name400ولم يترك أي شيء يمكن استخدامه بعد التحويل.
content_required400المحتوى كان فارغ أو فقط أبيض فراغ.
too_many_memories400200 ملاحظة بالفعل، وهذا سيكون واحد جديد.

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

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;
}
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()

و لماذا يستحق الأمر أن يُقام

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