{"title":"استراتيجية وسوم الذاكرة","slug":"memory-tagging-strategy","category":"llm-cookbook","summary":"كيف تُوسم الذكريات للبحث والتصفية الفعالة — نظام الوسوم القابل للتوسع.","audience":["llm"],"tags":["cookbook","tagging","memory","strategy"],"difficulty":"intermediate","updated":"2026-06-27","word_count":329,"read_minutes":2,"lang":"ar","translated":true,"requested_lang":"ar","content_markdown":"\n# استراتيجية وسوم الذاكرة\n\nالوسوم سر استرجاع الذاكرة القابل للتوسع. يُظهر هذا الدليل كيف تُوسم\nالذكريات حتى تعود الصحيحة في الوقت المناسب.\n\n## لماذا تهم الوسوم\n\nبدون الوسوم، لديك بحث نصي كامل مسطح. مع الوسوم، لديك تنقل\nمنظم:\n\n```bash\n# بدون وسوم: ابحث في كل شيء\nGET /memory/search?q=docker\n\n# مع الوسوم: صفِّ حسب المشروع + التقنية\nGET /memory/search?q=deployment&tag=synapse&tag=docker\n```\n\nتُمكّن الوسوم:\n\n- **تصفية سريعة** — `GET /memory/by-tag?tag=production`\n- **بحث محدود** — `?q=auth&tag=project-x`\n- **تجميع** — أوجد جميع ذكريات \"الأخطاء\" لمشروع\n- **إسناد متبادل** — الذكريات التي تشارك الوسوم مرتبطة\n\n## مخطط الوسوم\n\n### وسوم المشروع\n\nاستخدم أسماء المشاريع كوسوم:\n\n```\nsynapse, synapse-mcp, synapse-chat, synapse-sdk\n```\n\n### وسوم التقنية\n\nاستخدم أسماء التقنيات:\n\n```\ndocker, kubernetes, postgres, fastify, react, typescript\n```\n\n### وسوم المواضيع\n\nاستخدم فئات المواضيع:\n\n```\ndeployment, ci-cd, auth, database, frontend, backend, security\n```\n\n### وسوم الحالة\n\nاستخدم مؤشرات الحالة:\n\n```\nactive, completed, blocked, deprecated\n```\n\n### وسوم النوع\n\nاستخدم مؤشرات النوع:\n\n```\ndecision, mistake, pattern, reference, todo\n```\n\n## قواعد الوسم\n\n### القاعدة 1: 2-5 وسوم لكل ذاكرة\n\nوسوم قليلة جدًا = قابلية اكتشاف ضعيفة. كثيرة جدًا = ضوضاء.\n\n```json\n// جيد: 3 وسوم ذات صلة\n{ \"tags\": [\"synapse\", \"deployment\", \"docker\"] }\n\n// سيء: وسم واحد (ضيق جدًا)\n{ \"tags\": [\"synapse\"] }\n\n// سيء: 10 وسوم (ضوضاء)\n{ \"tags\": [\"synapse\", \"deployment\", \"docker\", \"vps1\", \"2026\", \"june\", \"ssh\", \"git\", \"main\", \"production\"] }\n```\n\n### القاعدة 2: أحرف صغيرة، بوصلات\n\n```\n✅ ci-cd, api-key, mind-key\n❌ CI-CD, APIKey, MindKey\n```\n\n### القاعدة 3: استخدم مفردات متسقة\n\nأنشئ مفردات وسم والتزم بها:\n\n```\n# مفردات المشروع\nsynapse, synapse-mcp, synapse-chat\n\n# لا: synapse_project, synapseProject, SYNAPSE\n```\n\n### القاعدة 4: وسم بنية البحث\n\nاسأل: \"كيف سأبحث عن هذه الذاكرة؟\"\n\n```json\n// تخزين قرار نشر\n{\n  \"content\": \"Decided to use Docker Swarm for Synapse deployment\",\n  \"tags\": [\"synapse\", \"deployment\", \"docker\", \"swarm\", \"decision\"]\n}\n\n// ستبحث غالبًا: ?q=docker+swarm أو ?tag=deployment\n```\n\n## الأنماط\n\n### النمط 1: مشروع + موضوع\n\n```json\n{ \"tags\": [\"synapse\", \"deployment\"] }\n{ \"tags\": [\"synapse\", \"auth\"] }\n{ \"tags\": [\"synapse-mcp\", \"tools\"] }\n```\n\nبحث: `?tag=synapse` (جميع ذكريات مشروع Synapse)\nبحث: `?tag=synapse&q=deployment` (ذكريات النشر في Synapse)\n\n### النمط 2: نوع + مجال\n\n```json\n{ \"tags\": [\"mistake\", \"deployment\"] }\n{ \"tags\": [\"decision\", \"database\"] }\n{ \"tags\": [\"pattern\", \"auth\"] }\n```\n\nبحث: `?tag=mistake` (جميع الأخطاء)\nبحث: `?tag=mistake&q=deployment` (أخطاء النشر)\n\n### النمط 3: هرمي\n\nلمشاريع فرعية ضمن مشروع:\n\n```json\n{ \"tags\": [\"synapse\", \"synapse-docs\", \"markdown\"] }\n{ \"tags\": [\"synapse\", \"synapse-mcp\", \"mcp\"] }\n{ \"tags\": [\"synapse\", \"synapse-admin\", \"ui\"] }\n```\n\nبحث: `?tag=synapse` (كل Synapse)\nبحث: `?tag=synapse-docs` (المشروع الفرعي docs فقط)\n\n### النمط 4: تتبع الحالة\n\n```json\n// مشروع نشط\n{ \"tags\": [\"synapse\", \"active\"], \"priority\": \"high\" }\n\n// مشروع مكتمل\n{ \"tags\": [\"synapse-v1\", \"completed\"], \"priority\": \"low\" }\n\n// محظور\n{ \"tags\": [\"synapse-v2\", \"blocked\"], \"priority\": \"high\" }\n```\n\n## حالات الاستخدام الشائعة\n\n### إيجاد جميع القرارات حول مشروع\n\n```bash\ncurl -H \"Authorization: Bearer $KEY\" \\\n     \".../memory/search?q=decision&tag=synapse\"\n```\n\n### إيجاد جميع الأخطاء في مجال\n\n```bash\ncurl -H \"Authorization: Bearer $KEY\" \\\n     \".../memory/search?q=mistake&tag=deployment\"\n```\n\n### إيجاد العمل النشط\n\n```bash\ncurl -H \"Authorization: Bearer $KEY\" \\\n     \".../memory/by-tag?tag=active\"\n```\n\n### إيجاد ذكريات حول تقنية\n\n```bash\ncurl -H \"Authorization: Bearer $KEY\" \\\n     \".../memory/search?q=postgres+performance&tag=database\"\n```\n\n## صيانة الوسوم\n\n### مراجعة دورية\n\n```python\n# إيجاد الوسوم النادرة الاستخدام (مرشحات للتنظيف)\ntags = requests.get(f\"{URL}/memory/tags\",\n    headers={\"Authorization\": f\"Bearer {KEY}\"}).json()\n\nfor tag, count in tags.items():\n    if count < 2:\n        print(f\"Rare tag: {tag} ({count} memories)\")\n```\n\n### دمج الوسوم\n\nإذا كان لديك وسوم غير متسقة (`docker` و `Docker`)، ادمجها:\n\n```python\n# أوجد جميع الذكريات بالوسم \"Docker\"\nmems = requests.get(f\"{URL}/memory/by-tag?tag=Docker\",\n    headers={\"Authorization\": f\"Bearer {KEY}\"}).json()\n\n# حدّث كل واحدة لاستخدام \"docker\" بدلًا من ذلك\nfor mem in mems[\"results\"]:\n    tags = [t.lower() for t in mem[\"tags\"]]\n    update_memory(mem[\"id\"], tags=list(set(tags)))\n```\n\n## أفضل الممارسات\n\n> [!TIP]\n> - **أنشئ المفردات مبكرًا** — وسوم متسقة من اليوم الأول\n> - **وسم بنية البحث** — كيف ستجد هذا لاحقًا؟\n> - **2-5 وسوم هي النقطة المثلى** — قليلة جدًا أو كثيرة جدًا سيئة\n> - **أحرف صغيرة + وصلات** — `ci-cd` لا `CI/CD`\n> - **راجع دوريًا** — ادمج المكررات، احذف غير المستخدمة\n\n## الخطوات التالية\n\n- [أفضل ممارسات الذاكرة](/docs/guides/memory-best-practices)\n- [بحث FTS5](/docs/concepts/fts5-search)\n- [سير العمل المدفوع بالمهام](/docs/llm-cookbook/task-driven-workflow)\n","content_html":"<h1>استراتيجية وسوم الذاكرة</h1>\n<p>الوسوم سر استرجاع الذاكرة القابل للتوسع. يُظهر هذا الدليل كيف تُوسم\nالذكريات حتى تعود الصحيحة في الوقت المناسب.</p>\n<h2>لماذا تهم الوسوم</h2>\n<p>بدون الوسوم، لديك بحث نصي كامل مسطح. مع الوسوم، لديك تنقل\nمنظم:</p>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># بدون وسوم: ابحث في كل شيء</span>\nGET /memory/search?q=docker\n\n<span class=\"hljs-comment\"># مع الوسوم: صفِّ حسب المشروع + التقنية</span>\nGET /memory/search?q=deployment&amp;tag=synapse&amp;tag=docker</code></pre><p>تُمكّن الوسوم:</p>\n<ul>\n<li><strong>تصفية سريعة</strong> — <code>GET /memory/by-tag?tag=production</code></li>\n<li><strong>بحث محدود</strong> — <code>?q=auth&amp;tag=project-x</code></li>\n<li><strong>تجميع</strong> — أوجد جميع ذكريات &quot;الأخطاء&quot; لمشروع</li>\n<li><strong>إسناد متبادل</strong> — الذكريات التي تشارك الوسوم مرتبطة</li>\n</ul>\n<h2>مخطط الوسوم</h2>\n<h3>وسوم المشروع</h3>\n<p>استخدم أسماء المشاريع كوسوم:</p>\n<pre><code class=\"hljs language-plaintext\">synapse, synapse-mcp, synapse-chat, synapse-sdk</code></pre><h3>وسوم التقنية</h3>\n<p>استخدم أسماء التقنيات:</p>\n<pre><code class=\"hljs language-plaintext\">docker, kubernetes, postgres, fastify, react, typescript</code></pre><h3>وسوم المواضيع</h3>\n<p>استخدم فئات المواضيع:</p>\n<pre><code class=\"hljs language-plaintext\">deployment, ci-cd, auth, database, frontend, backend, security</code></pre><h3>وسوم الحالة</h3>\n<p>استخدم مؤشرات الحالة:</p>\n<pre><code class=\"hljs language-plaintext\">active, completed, blocked, deprecated</code></pre><h3>وسوم النوع</h3>\n<p>استخدم مؤشرات النوع:</p>\n<pre><code class=\"hljs language-plaintext\">decision, mistake, pattern, reference, todo</code></pre><h2>قواعد الوسم</h2>\n<h3>القاعدة 1: 2-5 وسوم لكل ذاكرة</h3>\n<p>وسوم قليلة جدًا = قابلية اكتشاف ضعيفة. كثيرة جدًا = ضوضاء.</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-comment\">// جيد: 3 وسوم ذات صلة</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;deployment&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;docker&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n\n<span class=\"hljs-comment\">// سيء: وسم واحد (ضيق جدًا)</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n\n<span class=\"hljs-comment\">// سيء: 10 وسوم (ضوضاء)</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;deployment&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;docker&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;vps1&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;2026&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;june&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;ssh&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;git&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;main&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;production&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span></code></pre><h3>القاعدة 2: أحرف صغيرة، بوصلات</h3>\n<pre><code class=\"hljs language-plaintext\">✅ ci-cd, api-key, mind-key\n❌ CI-CD, APIKey, MindKey</code></pre><h3>القاعدة 3: استخدم مفردات متسقة</h3>\n<p>أنشئ مفردات وسم والتزم بها:</p>\n<pre><code class=\"hljs language-plaintext\"># مفردات المشروع\nsynapse, synapse-mcp, synapse-chat\n\n# لا: synapse_project, synapseProject, SYNAPSE</code></pre><h3>القاعدة 4: وسم بنية البحث</h3>\n<p>اسأل: &quot;كيف سأبحث عن هذه الذاكرة؟&quot;</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-comment\">// تخزين قرار نشر</span>\n<span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;content&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Decided to use Docker Swarm for Synapse deployment&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;deployment&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;docker&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;swarm&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;decision&quot;</span><span class=\"hljs-punctuation\">]</span>\n<span class=\"hljs-punctuation\">}</span>\n\n<span class=\"hljs-comment\">// ستبحث غالبًا: ?q=docker+swarm أو ?tag=deployment</span></code></pre><h2>الأنماط</h2>\n<h3>النمط 1: مشروع + موضوع</h3>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;deployment&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;auth&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse-mcp&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;tools&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span></code></pre><p>بحث: <code>?tag=synapse</code> (جميع ذكريات مشروع Synapse)\nبحث: <code>?tag=synapse&amp;q=deployment</code> (ذكريات النشر في Synapse)</p>\n<h3>النمط 2: نوع + مجال</h3>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;mistake&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;deployment&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;decision&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;database&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;pattern&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;auth&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span></code></pre><p>بحث: <code>?tag=mistake</code> (جميع الأخطاء)\nبحث: <code>?tag=mistake&amp;q=deployment</code> (أخطاء النشر)</p>\n<h3>النمط 3: هرمي</h3>\n<p>لمشاريع فرعية ضمن مشروع:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;synapse-docs&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;markdown&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;synapse-mcp&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;mcp&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;synapse-admin&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;ui&quot;</span><span class=\"hljs-punctuation\">]</span> <span class=\"hljs-punctuation\">}</span></code></pre><p>بحث: <code>?tag=synapse</code> (كل Synapse)\nبحث: <code>?tag=synapse-docs</code> (المشروع الفرعي docs فقط)</p>\n<h3>النمط 4: تتبع الحالة</h3>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-comment\">// مشروع نشط</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;active&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-attr\">&quot;priority&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;high&quot;</span> <span class=\"hljs-punctuation\">}</span>\n\n<span class=\"hljs-comment\">// مشروع مكتمل</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse-v1&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;completed&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-attr\">&quot;priority&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;low&quot;</span> <span class=\"hljs-punctuation\">}</span>\n\n<span class=\"hljs-comment\">// محظور</span>\n<span class=\"hljs-punctuation\">{</span> <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;synapse-v2&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;blocked&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-attr\">&quot;priority&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;high&quot;</span> <span class=\"hljs-punctuation\">}</span></code></pre><h2>حالات الاستخدام الشائعة</h2>\n<h3>إيجاد جميع القرارات حول مشروع</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$KEY</span>&quot;</span> \\\n     <span class=\"hljs-string\">&quot;.../memory/search?q=decision&amp;tag=synapse&quot;</span></code></pre><h3>إيجاد جميع الأخطاء في مجال</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$KEY</span>&quot;</span> \\\n     <span class=\"hljs-string\">&quot;.../memory/search?q=mistake&amp;tag=deployment&quot;</span></code></pre><h3>إيجاد العمل النشط</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$KEY</span>&quot;</span> \\\n     <span class=\"hljs-string\">&quot;.../memory/by-tag?tag=active&quot;</span></code></pre><h3>إيجاد ذكريات حول تقنية</h3>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$KEY</span>&quot;</span> \\\n     <span class=\"hljs-string\">&quot;.../memory/search?q=postgres+performance&amp;tag=database&quot;</span></code></pre><h2>صيانة الوسوم</h2>\n<h3>مراجعة دورية</h3>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># إيجاد الوسوم النادرة الاستخدام (مرشحات للتنظيف)</span>\ntags = requests.get(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory/tags&quot;</span>,\n    headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{KEY}</span>&quot;</span>}).json()\n\n<span class=\"hljs-keyword\">for</span> tag, count <span class=\"hljs-keyword\">in</span> tags.items():\n    <span class=\"hljs-keyword\">if</span> count &lt; <span class=\"hljs-number\">2</span>:\n        <span class=\"hljs-built_in\">print</span>(<span class=\"hljs-string\">f&quot;Rare tag: <span class=\"hljs-subst\">{tag}</span> (<span class=\"hljs-subst\">{count}</span> memories)&quot;</span>)</code></pre><h3>دمج الوسوم</h3>\n<p>إذا كان لديك وسوم غير متسقة (<code>docker</code> و <code>Docker</code>)، ادمجها:</p>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-comment\"># أوجد جميع الذكريات بالوسم &quot;Docker&quot;</span>\nmems = requests.get(<span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory/by-tag?tag=Docker&quot;</span>,\n    headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{KEY}</span>&quot;</span>}).json()\n\n<span class=\"hljs-comment\"># حدّث كل واحدة لاستخدام &quot;docker&quot; بدلًا من ذلك</span>\n<span class=\"hljs-keyword\">for</span> mem <span class=\"hljs-keyword\">in</span> mems[<span class=\"hljs-string\">&quot;results&quot;</span>]:\n    tags = [t.lower() <span class=\"hljs-keyword\">for</span> t <span class=\"hljs-keyword\">in</span> mem[<span class=\"hljs-string\">&quot;tags&quot;</span>]]\n    update_memory(mem[<span class=\"hljs-string\">&quot;id&quot;</span>], tags=<span class=\"hljs-built_in\">list</span>(<span class=\"hljs-built_in\">set</span>(tags)))</code></pre><h2>أفضل الممارسات</h2>\n<div class=\"callout callout-ok\"></div><h2>الخطوات التالية</h2>\n<ul>\n<li><a href=\"/docs/guides/memory-best-practices\">أفضل ممارسات الذاكرة</a></li>\n<li><a href=\"/docs/concepts/fts5-search\">بحث FTS5</a></li>\n<li><a href=\"/docs/llm-cookbook/task-driven-workflow\">سير العمل المدفوع بالمهام</a></li>\n</ul>\n","urls":{"html":"/docs/llm-cookbook/memory-tagging-strategy","text":"/docs/llm-cookbook/memory-tagging-strategy?format=text","json":"/docs/llm-cookbook/memory-tagging-strategy?format=json","llm":"/docs/llm-cookbook/memory-tagging-strategy?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}