Files
saherelm 5ccf0d31a7 - Add Documents/Docs/ChangeLogs/1405-08-04-v02.html;
- Add this commit message file;
- Document current OwnerId limitation and proposed KnowledgeBaseId design.
2026-10-26 17:51:53 +03:30

3 lines
7.5 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html><html lang="fa" dir="rtl"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>ChangeLog ۱۴۰۵/۰۸/۰۴ v02 - Persistent RAG</title><style>body{margin:0;padding:24px;background:#f4f7fb;color:#172033;font-family:Tahoma,"Segoe UI",sans-serif;line-height:1.9}.wrap{max-width:1180px;margin:auto;background:#fff;border-radius:16px;box-shadow:0 12px 40px #20386422;overflow:hidden}.hero{padding:38px;background:linear-gradient(135deg,#173b78,#2563eb);color:#fff}.meta{display:flex;gap:24px;flex-wrap:wrap;padding:16px 30px;background:#f8fafc;color:#53627a}main{padding:30px}.section{margin-bottom:26px;padding:22px;background:#f4f7fb;border-right:5px solid #2563eb;border-radius:10px}.section h2{color:#173b78;border-bottom:1px solid #dbe3ef;padding-bottom:8px}table{width:100%;border-collapse:collapse;background:#fff;margin:12px 0}th,td{text-align:right;vertical-align:top;padding:10px 12px;border-bottom:1px solid #dbe3ef}th{background:#173b78;color:#fff}code{direction:ltr;display:inline-block;background:#e7edf6;border-radius:4px;padding:0 5px;font-family:Consolas,monospace}pre{direction:ltr;text-align:left;overflow:auto;background:#172033;color:#e7eefc;border-radius:7px;padding:14px}.note,.warn{padding:13px 16px;border-radius:7px;margin-top:12px}.note{background:#eff6ff;border-right:4px solid #2563eb}.warn{background:#fff7ed;border-right:4px solid #b45309}.badge{display:inline-block;color:#fff;border-radius:15px;padding:1px 10px;font-size:.8em}.mod{background:#b45309}.new{background:#087f5b}footer{text-align:center;color:#68758a;padding:18px;border-top:1px solid #dbe3ef}</style></head><body><div class="wrap"><header class="hero"><h1>گزارش تغییرات ساختار پروژه</h1><p>xSaherelmWorkspace | تاریخ: ۱۴۰۵/۰۸/۰۴ (2026-10-26) | نسخه مستند: <strong>v02</strong></p><p>موضوع: پیاده‌سازی Persistent RAG روی جدول <code>XAiVector</code></p></header><div class="meta"><span><strong>دامنه:</strong> workspace، <code>xAiApi</code> و <code>Modules/xAiModels</code></span><span><strong>وضعیت:</strong> commit نشده</span><span><strong>مستند بعدی:</strong> v03</span></div><main><section class="section"><h2>۱. خلاصه اجرایی</h2><p>RAG از حالت صرفاً In-Memory به جریان پایدار مبتنی بر ذخیره و بازیابی بردارها از جدول موجود <code>XAiVector</code> توسعه یافت. فایل‌ها Extract، Chunk و Embed می‌شوند؛ chunkها با شناسه پایدار ذخیره و هنگام سؤال از پایگاه داده بازیابی می‌شوند.</p><table><tr><th>شاخص</th><th>نتیجه</th></tr><tr><td>تاریخ و نسخه</td><td>۱۴۰۵/۰۸/۰۴ — v02</td></tr><tr><td>ذخیره‌سازی</td><td>Schema موجود؛ Migration جدید ایجاد نشده.</td></tr><tr><td>ایزولاسیون فعلی</td><td><code>{ownerId}/{fileName}#{chunkIndex}</code></td></tr><tr><td>اعتبارسنجی</td><td>Build <code>xAiApi</code> موفق؛ هشدار NuGet به علت دسترسی به nuget.org.</td></tr></table></section><section class="section"><h2>۲. تغییرات لایه داده</h2><h3><span class="badge mod">تغییر</span> <code>Modules/xAiModels/Interfaces/IXAiDataProvider.cs</code></h3><ul><li>قرارداد Upsert تکی و دسته‌ای بردارها.</li><li>جستجو با <code>topK</code>، <code>minScore</code> و <code>identifierPrefix</code>.</li><li>بارگذاری و حذف بردارها با پیشوند.</li></ul><h3><span class="badge mod">تغییر</span> <code>Modules/xAiModels/Providers/XAiDataProvider.cs</code></h3><ul><li>ذخیره دسته‌ای با یک ثبت تغییرات.</li><li>فیلتر پیشوند در query و محاسبه Cosine Similarity.</li><li>حذف و بارگذاری محدوده‌ای.</li></ul></section><section class="section"><h2>۳. سرویس Persistent RAG و مدل‌ها</h2><table><tr><th>نوع</th><th>مسیر</th><th>شرح</th></tr><tr><td><span class="badge new">جدید</span></td><td><code>xAiApi/Interfaces/IXAiRAGService.cs</code></td><td>قرارداد Ingest، Retrieve، پاسخ sync/stream، فهرست و حذف.</td></tr><tr><td><span class="badge new">جدید</span></td><td><code>xAiApi/Providers/XAiRAGService.cs</code></td><td>Extract → Chunk → Embed → Store، بازیابی DB، تولید پاسخ و منابع.</td></tr><tr><td><span class="badge new">جدید</span></td><td><code>xAiApi/Models/XAiKnowledgeModels.cs</code></td><td>مدل‌های ingest، سؤال و اطلاعات سند.</td></tr><tr><td><span class="badge mod">تغییر</span></td><td><code>xAiApi/Constants/XAiApiConstants.cs</code></td><td>ثابت‌های جداکننده و metadata.</td></tr></table><p class="note"><strong>Re-ingest:</strong> با <code>replaceExisting=true</code> chunkهای قبلی همان owner و فایل حذف و نسخه جدید ثبت می‌شود.</p></section><section class="section"><h2>۴. API و DI</h2><h3><span class="badge new">جدید</span> <code>xAiApi/Controllers/KnowledgeController.cs</code></h3><table><tr><th>Endpoint</th><th>کارکرد</th></tr><tr><td><code>POST /Knowledge/Ingest</code></td><td>دریافت فایل و ingest پایدار.</td></tr><tr><td><code>POST /Knowledge/Ask</code></td><td>سؤال RAG با منابع.</td></tr><tr><td><code>POST /Knowledge/AskStream</code></td><td>پاسخ SSE.</td></tr><tr><td><code>GET /Knowledge/Documents</code></td><td>فهرست اسناد owner.</td></tr><tr><td><code>DELETE /Knowledge/Documents?fileName=...</code></td><td>حذف chunkهای سند.</td></tr></table><p>در <code>xAiApi/DI/XDIHelperExtension.cs</code> سرویس <code>IXAiRAGService</code> با طول عمر Scoped ثبت شد.</p></section><section class="section"><h2>۵. نکته طراحی و مسیر بعدی</h2><div class="warn"><strong>OwnerId همچنان اجباری است.</strong> طراحی فعلی دانش را بر اساس مالک کاربر ایزوله می‌کند؛ پایگاه دانش مشترک برای Admin و کاربران هنوز پیاده نشده است.</div><p>پیشنهاد مرحله بعد، تبدیل مالک به <code>KnowledgeBaseId</code> است؛ بدون Migration می‌توان از شناسه <code>kb/{knowledgeBaseId}/{fileName}#{chunkIndex}</code> و metadata استفاده کرد. Admin فقط ingest/delete و کاربران فقط Ask/Retrieve انجام دهند.</p><pre>Admin → Ingest/Delete → system Knowledge Base
User → Ask/Retrieve → system Knowledge Base → LLM</pre></section><section class="section"><h2>۶. اعتبارسنجی</h2><ul><li>Build مستقیم <code>xAiApi/xAiApi.csproj</code> موفق شد.</li><li>هشدارهای <code>NU1900</code> به دلیل دسترسی نداشتن به vulnerability service مشاهده شد؛ خطای کامپایل وجود نداشت.</li><li>تست runtime و end-to-end با embedding/LLM واقعی هنوز اجرا نشده است.</li></ul><pre>dotnet build xAiApi/xAiApi.csproj --nologo -v q</pre></section><section class="section"><h2>۷. فایل‌های مستند</h2><p>گزارش: <code>Documents/Docs/ChangeLogs/1405-08-04-v02.html</code></p><p>Commit message: <code>Documents/Docs/ChangeLogs/CommitMessage-1405-08-04-v02.txt</code></p><p>برای تغییرات بعدی همین تاریخ از پسوند <code>v03</code> استفاده شود.</p></section></main><footer>تولیدشده در تاریخ ۱۴۰۵/۰۸/۰۴ (2026-10-26) | xSaherelmWorkspace | ChangeLog v02</footer></div></body></html>