- Update xAiApi Submodule Pointer to Chat With Documents (In-Memory RAG) Implementation; - Add Documents/Docs/ChangeLogs/1405-08-03.html (ChangeLog of Pushed Commits); - Add Documents/Docs/ChangeLogs/1405-08-03-uncommitted.html (ChangeLog of this Commit); - Add Documents/Docs/ChangeLogs/CommitMessage-1405-08-03.txt; - Add Documents/Markdown/plan1.md and plan1.html (Chat With Documents Implementation Plan); - ...
237 lines
21 KiB
HTML
237 lines
21 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="fa" dir="rtl">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>گزارش تغییرات کامیتنشده ۱۴۰۵/۰۸/۰۳ - xSaherelmWorkspace</title>
|
||
<style>
|
||
:root {
|
||
--primary: #1e3a8a;
|
||
--secondary: #3b82f6;
|
||
--accent: #f59e0b;
|
||
--success: #10b981;
|
||
--danger: #ef4444;
|
||
--warning: #f97316;
|
||
--bg-light: #f8fafc;
|
||
--bg-code: #1e293b;
|
||
--text-dark: #0f172a;
|
||
--text-muted: #64748b;
|
||
--border: #e2e8f0;
|
||
}
|
||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||
body { font-family: 'Tahoma', 'Segoe UI', sans-serif; background: linear-gradient(135deg, #f8fafc 0%, #e0e7ff 100%); color: var(--text-dark); line-height: 1.8; padding: 20px; }
|
||
.container { max-width: 1200px; margin: 0 auto; background: white; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.1); overflow: hidden; }
|
||
.header { background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%); color: white; padding: 40px; text-align: center; }
|
||
.header h1 { font-size: 2.1em; margin-bottom: 10px; }
|
||
.header .subtitle { font-size: 1.1em; opacity: 0.95; }
|
||
.meta-bar { display: flex; justify-content: space-between; background: var(--bg-light); padding: 15px 30px; border-bottom: 2px solid var(--border); flex-wrap: wrap; gap: 15px; }
|
||
.meta-item { display: flex; align-items: center; gap: 8px; font-size: 0.9em; color: var(--text-muted); }
|
||
.meta-item strong { color: var(--primary); }
|
||
.content { padding: 40px; }
|
||
.section { margin-bottom: 35px; padding: 25px; background: var(--bg-light); border-radius: 12px; border-right: 5px solid var(--secondary); }
|
||
.section h2 { color: var(--primary); font-size: 1.5em; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 2px solid var(--border); }
|
||
.section h3 { color: var(--secondary); font-size: 1.15em; margin: 22px 0 12px; }
|
||
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 15px; margin-bottom: 10px; }
|
||
.stat-card { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 18px; text-align: center; }
|
||
.stat-card .value { font-size: 1.9em; font-weight: bold; color: var(--primary); }
|
||
.stat-card .label { font-size: 0.85em; color: var(--text-muted); }
|
||
.stat-card.add .value { color: var(--success); }
|
||
.stat-card.del .value { color: var(--danger); }
|
||
table { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; margin: 12px 0; font-size: 0.93em; }
|
||
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: top; }
|
||
th { background: var(--primary); color: white; font-weight: 600; }
|
||
tr:last-child td { border-bottom: none; }
|
||
tr:hover td { background: #f1f5f9; }
|
||
code { font-family: 'Consolas', 'Courier New', monospace; background: #e2e8f0; padding: 2px 6px; border-radius: 4px; font-size: 0.9em; direction: ltr; display: inline-block; }
|
||
pre { background: var(--bg-code); color: #e2e8f0; padding: 16px; border-radius: 8px; direction: ltr; text-align: left; overflow-x: auto; font-family: 'Consolas', 'Courier New', monospace; font-size: 0.88em; line-height: 1.6; }
|
||
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78em; font-weight: bold; color: white; }
|
||
.badge.new { background: var(--success); }
|
||
.badge.mod { background: var(--warning); }
|
||
.badge.sub { background: var(--secondary); }
|
||
.commit { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
|
||
.commit-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
|
||
.commit-head .msg { font-weight: bold; color: var(--primary); font-size: 1.05em; }
|
||
.commit-head .info { color: var(--text-muted); font-size: 0.85em; }
|
||
.diffstat { color: var(--text-muted); font-size: 0.85em; }
|
||
.diffstat .plus { color: var(--success); font-weight: bold; }
|
||
.diffstat .minus { color: var(--danger); font-weight: bold; }
|
||
ul { padding-right: 22px; margin: 8px 0; }
|
||
li { margin-bottom: 6px; }
|
||
.note { background: #fffbeb; border-right: 4px solid var(--accent); padding: 12px 16px; border-radius: 8px; margin-top: 12px; font-size: 0.92em; }
|
||
.warn { background: #fef2f2; border-right: 4px solid var(--danger); padding: 12px 16px; border-radius: 8px; margin-top: 12px; font-size: 0.92em; }
|
||
.footer { background: var(--bg-light); border-top: 2px solid var(--border); padding: 18px 30px; text-align: center; color: var(--text-muted); font-size: 0.85em; }
|
||
a { color: var(--secondary); text-decoration: none; }
|
||
a:hover { text-decoration: underline; }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
|
||
<div class="header">
|
||
<h1>گزارش تغییرات کامیتنشده (Uncommitted ChangeLog)</h1>
|
||
<div class="subtitle">یکشنبه ۳ آبان ۱۴۰۵ | 2026-10-25 | xSaherelmWorkspace</div>
|
||
</div>
|
||
|
||
<div class="meta-bar">
|
||
<div class="meta-item"><strong>نویسنده:</strong> Hadi Khazaee Asl</div>
|
||
<div class="meta-item"><strong>برنچ:</strong> <code>master</code></div>
|
||
<div class="meta-item"><strong>وضعیت:</strong> تغییرات در Working Tree، هنوز کامیت نشدهاند</div>
|
||
<div class="meta-item"><strong>پایهٔ کار:</strong> workspace <code>43f5cc0</code> / xAiApi <code>47d8a19</code></div>
|
||
</div>
|
||
|
||
<div class="content">
|
||
|
||
<!-- خلاصه -->
|
||
<div class="section">
|
||
<h2>خلاصه</h2>
|
||
<div class="stats">
|
||
<div class="stat-card"><div class="value">2</div><div class="label">مخزن تغییریافته</div></div>
|
||
<div class="stat-card"><div class="value">5</div><div class="label">فایل جدید</div></div>
|
||
<div class="stat-card"><div class="value">9</div><div class="label">فایل تغییریافته</div></div>
|
||
<div class="stat-card"><div class="value">5</div><div class="label">Endpoint جدید</div></div>
|
||
<div class="stat-card add"><div class="value">+1,090</div><div class="label">خط اضافهشده (xAiApi)</div></div>
|
||
<div class="stat-card del"><div class="value">-170</div><div class="label">خط حذفشده (xAiApi)</div></div>
|
||
</div>
|
||
<p>
|
||
این گزارش ادامهٔ کارهای ثبتشده در <a href="1405-08-03.html">ChangeLog ۳ آبان ۱۴۰۵</a> است و تکمیل قابلیت
|
||
<strong>Chat With Documents (RAG درونحافظهای)</strong> در پروژهٔ <code>xAiApi</code> را پوشش میدهد:
|
||
تعریف مدلهای DTO، افزودن متدهای <code>AskWithContext</code> به سرویس پایهٔ AI،
|
||
بازنویسی کامل <code>ChatWithDocumentsController</code> با Endpointهای Ingest / Ask / AskStream / Session،
|
||
سرویس پسزمینهٔ پاکسازی Sessionهای منقضی و پیکربندی <code>RAGDescriptor</code>.
|
||
در مخزن اصلی نیز فایلهای مستندات (ChangeLog و طرح <code>plan1</code>) اضافه شدهاند.
|
||
</p>
|
||
</div>
|
||
|
||
<!-- مخزن اصلی -->
|
||
<div class="section">
|
||
<h2>۱. مخزن اصلی: xSaherelmWorkspace</h2>
|
||
<p>ریموت: <a href="https://git.saherelm.ir/saherelm/xSaherelmWorkspace.git">git.saherelm.ir/saherelm/xSaherelmWorkspace.git</a></p>
|
||
|
||
<div class="commit">
|
||
<div class="commit-head">
|
||
<span class="msg">تغییرات کامیتنشده</span>
|
||
<span class="info">بر پایهٔ <code>43f5cc0</code> | <code>git status</code></span>
|
||
</div>
|
||
<div class="diffstat">4 مورد | 3 فایل جدید + 1 سابماژول تغییریافته</div>
|
||
<table>
|
||
<thead><tr><th>نوع</th><th>فایل</th><th>توضیح</th></tr></thead>
|
||
<tbody>
|
||
<tr><td><span class="badge new">جدید</span></td><td><code>Documents/Docs/ChangeLogs/1405-08-03.html</code></td><td>گزارش تغییرات پوششدهٔ ۳ آبان (TextChunker و In-Memory Vector Store)</td></tr>
|
||
<tr><td><span class="badge new">جدید</span></td><td><code>Documents/Markdown/plan1.md</code></td><td>طرح گامبهگام تکمیل Chat With Documents (وضعیت فعلی، گامهای ۱ تا ۸ و نکات تصمیمگیری)</td></tr>
|
||
<tr><td><span class="badge new">جدید</span></td><td><code>Documents/Markdown/plan1.html</code></td><td>نسخهٔ HTML طرح فوق</td></tr>
|
||
<tr><td><span class="badge sub">سابماژول</span></td><td><code>xAiApi</code></td><td>محتوای سابماژول تغییر کرده است (<code>Submodule xAiApi contains modified content</code>)؛ پس از کامیت در xAiApi باید پوینتر بهروزرسانی شود</td></tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- xAiApi -->
|
||
<div class="section">
|
||
<h2>۲. سابماژول: xAiApi</h2>
|
||
<p>ریموت: <a href="https://git.saherelm.ir/saherelm/xSaherElmAiApi.git">git.saherelm.ir/saherelm/xSaherElmAiApi.git</a></p>
|
||
|
||
<div class="commit">
|
||
<div class="commit-head">
|
||
<span class="msg">Implement Chat With Documents (In-Memory RAG) ...</span>
|
||
<span class="info">کامیتنشده | بر پایهٔ <code>47d8a19</code></span>
|
||
</div>
|
||
<div class="diffstat">11 فایل (۲ جدید، ۹ تغییریافته) | <span class="plus">+1,090</span> / <span class="minus">-170</span></div>
|
||
<table>
|
||
<thead><tr><th>نوع</th><th>فایل</th><th>تغییر</th><th>توضیح</th></tr></thead>
|
||
<tbody>
|
||
<tr><td><span class="badge new">جدید</span></td><td><code>Models/XAiDocumentModels.cs</code></td><td>+181</td><td>مدلهای DTO: <code>XAiDocumentIngestResult</code>, <code>XAiDocumentAskRequest</code>, <code>XAiDocumentSource</code>, <code>XAiDocumentAnswer</code>, <code>XAiDocumentAnswerChunk</code> (SSE), <code>XAiDocumentSessionInfo</code>, <code>XAiDocumentRAGDescriptor</code></td></tr>
|
||
<tr><td><span class="badge new">جدید</span></td><td><code>Providers/XInMemoryVectorStoreCleanupService.cs</code></td><td>+77</td><td><code>BackgroundService</code> که هر ۵ دقیقه <code>RemoveExpired()</code> را روی Vector Store اجرا و نتیجه را لاگ میکند</td></tr>
|
||
<tr><td><span class="badge mod">تغییر</span></td><td><code>Controllers/ChatWithDocumentsController.cs</code></td><td>+672</td><td>بازنویسی کامل: اصلاح <code>using</code> به <code>Microsoft.AspNetCore.Mvc</code>، حذف فیلد محلی و <code>IDisposable</code>، تزریق <code>IXTextChunker</code>/<code>IXInMemoryVectorStore</code>/<code>IXDefaultEmbeddingService</code>/<code>IXFileContentExtractor</code>/<code>XAiApiConfiguration</code>، پیادهسازی ۵ Endpoint و متدهای کمکی <code>ExtractText</code>, <code>EmbedChunks</code>, <code>Retrieve</code>, <code>ToSources</code>, <code>GetMetadata</code>, <code>WriteChunk</code></td></tr>
|
||
<tr><td><span class="badge mod">تغییر</span></td><td><code>Providers/XAIServiceBase.cs</code></td><td>+183 / -5</td><td>region جدید «Context Actions»: <code>AskWithContextAsync</code>, <code>AskWithContextAsEnumerable</code>, <code>GetContextHistory</code> (Introduction + پرامپت RAG + بلوک Context + سؤال کاربر) و <code>BuildContextBlock</code>؛ بدون ذخیره در دیتابیس؛ حذف usingهای بلااستفاده</td></tr>
|
||
<tr><td><span class="badge mod">تغییر</span></td><td><code>Interfaces/IXAiServiceBase.cs</code></td><td>+34 / -1</td><td>افزودن امضای <code>AskWithContextAsync</code> و <code>AskWithContextAsEnumerable</code> در region «Context Actions»</td></tr>
|
||
<tr><td><span class="badge mod">تغییر</span></td><td><code>Providers/XInMemoryVectorStore.cs</code></td><td>+62 / -26</td><td>بهینهسازی <code>Search</code>: تبدیل <code>queryEmbedding.ToArray()</code> یکبار قبل از حلقه؛ فرمتدهی امضاها و انتقال متدهای خصوصی به region «Private»</td></tr>
|
||
<tr><td><span class="badge mod">تغییر</span></td><td><code>Extensions/XModelsExtensions.cs</code></td><td>+21 / -1</td><td>افزودن <code>IsValid(this XAiDocumentAskRequest)</code> (بررسی Prompt، SessionId، بازهٔ TopK و MinScore)</td></tr>
|
||
<tr><td><span class="badge mod">تغییر</span></td><td><code>DI/XDIHelperExtension.cs</code></td><td>+11</td><td>ثبت <code>XInMemoryVectorStoreCleanupService</code> بهعنوان HostedService و افزودن <code>AddXAiChatWithDocuments()</code></td></tr>
|
||
<tr><td><span class="badge mod">تغییر</span></td><td><code>Configurations/XAiApiConfiguration.cs</code></td><td>+5</td><td>افزودن پراپرتی <code>RAGDescriptor</code> از نوع <code>XAiDocumentRAGDescriptor</code></td></tr>
|
||
<tr><td><span class="badge mod">تغییر</span></td><td><code>Startup.cs</code></td><td>+3 / -3</td><td>جایگزینی <code>AddXAiInMemoryVectorStore()</code> با <code>AddXAiChatWithDocuments()</code></td></tr>
|
||
<tr><td><span class="badge mod">تغییر</span></td><td><code>appsettings.Development.json</code></td><td>+18 (محتوایی)</td><td>افزودن پرامپت <code>ChatWithDocuments</code> به <code>Prompts</code> و بخش <code>RAGDescriptor</code>؛ دیف خام (+142/-124) ناشی از تغییر فاصله/Line Ending است</td></tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h3>Endpointهای کنترلر <code>ChatWithDocuments</code></h3>
|
||
<table>
|
||
<thead><tr><th>متد</th><th>مسیر</th><th>ورودی</th><th>خروجی / توضیح</th></tr></thead>
|
||
<tbody>
|
||
<tr><td><code>POST</code></td><td><code>/ChatWithDocuments/Ingest</code></td><td><code>multipart/form-data</code> (files, sessionId?, ttlMinutes?)</td><td><code>XAiDocumentIngestResult</code> — Extract → Chunk → Embed (Batch) → Store؛ فایلهای ناسازگار/خالی در <code>SkippedFiles</code></td></tr>
|
||
<tr><td><code>POST</code></td><td><code>/ChatWithDocuments/Ask</code></td><td><code>XAiDocumentAskRequest</code></td><td><code>XAiDocumentAnswer</code> — Embedding سؤال → Search → <code>AskWithContextAsync</code>؛ در نبود Context: <code>NoContextFound = true</code></td></tr>
|
||
<tr><td><code>POST</code></td><td><code>/ChatWithDocuments/AskStream</code></td><td><code>XAiDocumentAskRequest</code></td><td>SSE (<code>text/event-stream</code>) — رویداد اول Sources، سپس Deltaهای متن، رویداد آخر <code>IsFinal = true</code></td></tr>
|
||
<tr><td><code>GET</code></td><td><code>/ChatWithDocuments/Session/{id}</code></td><td>Guid</td><td><code>XAiDocumentSessionInfo</code> (بدون Embedding) یا 404</td></tr>
|
||
<tr><td><code>DELETE</code></td><td><code>/ChatWithDocuments/Session/{id}</code></td><td>Guid</td><td>حذف Session؛ 200 / 404</td></tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h3>پیکربندی جدید در <code>appsettings.Development.json</code></h3>
|
||
<pre>"RAGDescriptor": {
|
||
"MaxTopK": 20,
|
||
"DefaultTopK": 5,
|
||
"DefaultTtlMinutes": 30,
|
||
"EmbeddingBatchSize": 32,
|
||
"SourceSnippetLength": 200,
|
||
"DefaultMinScore": "0.35f",
|
||
"MetadataFileName": "fileName",
|
||
"MetadataMimeType": "mimeType",
|
||
"PromptName": "ChatWithDocuments",
|
||
"MetadataChunkIndex": "chunkIndex"
|
||
}</pre>
|
||
<pre>{
|
||
"Name": "ChatWithDocuments",
|
||
"Template": "You are a document question-answering assistant. Answer the user's question ONLY based on the provided Context chunks below. ...",
|
||
"Description": "System prompt for RAG based Chat With Documents",
|
||
"Params": []
|
||
}</pre>
|
||
</div>
|
||
|
||
<h3>نکات فنی</h3>
|
||
<ul>
|
||
<li>تمام دسترسیها به Session با <code>ownerId = (await GetUserInfo()).UserId</code> محدود میشود و همهٔ Endpointها از الگوی <code>try/catch</code> + <code>GetExceptionActionResult(ex)</code> پیروی میکنند.</li>
|
||
<li>Context بهصورت پیام <strong>System</strong> جداگانه (پرامپت RAG + بلوک Chunkها با Identifier) به مدل ارسال میشود؛ هیچچیز در دیتابیس ذخیره نمیشود.</li>
|
||
<li><code>TopK</code> با <code>Math.Clamp(1, MaxTopK)</code> محدود میشود و مقادیر پیشفرض از <code>RAGDescriptor</code> خوانده میشوند.</li>
|
||
<li>Embedding تکهها بهصورت Batch (<code>EmbeddingBatchSize = 32</code>) انجام میشود و Metadata هر Vector شامل <code>fileName</code>, <code>mimeType</code>, <code>chunkIndex</code> است.</li>
|
||
<li>سرویس پاکسازی بهصورت <code>HostedService</code> داخل <code>AddXAiInMemoryVectorStore()</code> ثبت میشود.</li>
|
||
</ul>
|
||
<div class="warn">
|
||
<strong>هشدار پیکربندی:</strong> مقدار <code>"DefaultMinScore": "0.35f"</code> در <code>appsettings.Development.json</code> بهصورت رشته با پسوند <code>f</code> نوشته شده است.
|
||
بایندر پیکربندی .NET نمیتواند آن را به <code>float</code> تبدیل کند و هنگام Bind خطا میدهد؛ باید قبل از کامیت به <code>0.35</code> (عدد) اصلاح شود.
|
||
</div>
|
||
<div class="note">
|
||
<strong>کارهای باقیمانده طبق طرح (plan1.md):</strong> افزودن <code>RAGDescriptor</code> و پرامپت <code>ChatWithDocuments</code> به <code>appsettings.json</code> (Production)،
|
||
تست دستی جریان Ingest → Ask → AskStream → Delete با یک PDF، تصمیم دربارهٔ پروژهٔ یونیتتست (<code>xAiApi.Tests</code>) و پاکسازی فایلهای موقت <code>tmp.md</code> / <code>tmp.html</code>.
|
||
</div>
|
||
</div>
|
||
|
||
<!-- بدون تغییر -->
|
||
<div class="section">
|
||
<h2>۳. مخازن بدون تغییر</h2>
|
||
<p>در ۳۲ سابماژول زیر تغییر کامیتنشدهای وجود ندارد:</p>
|
||
<ul>
|
||
<li><strong>Modules (۲۸ مورد):</strong> xAiModels, xAiService, xApiSDKHolder, xCategoryService, xCommons, xContentService, xDataService, xEventService, xExceptions, xFileService, xFrameworkComponentsHolder, xFrameworkCoreHolder, xFrameworkIdentitySDKHolder, xFrameworkPushServiceHolder, xFrameworkServicesHolder, xHttpService, xIdentityHelper, xIdentityModels, xIdentityService, xMessageService, xModels, xPushService, xServices, xStorageService, xStringService, xTagService, xTermsAndConditionsService, xWebinarService</li>
|
||
<li><strong>Applications (۴ مورد):</strong> xApi, xClient, xIds, xFrameworkTest</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<!-- دستورات -->
|
||
<div class="section">
|
||
<h2>۴. دستورات استفادهشده برای استخراج تغییرات</h2>
|
||
<pre>git status --porcelain=v1 -uall
|
||
git diff --submodule=log xAiApi
|
||
git -C xAiApi status --porcelain=v1 -uall
|
||
git -C xAiApi diff --stat
|
||
git -C xAiApi diff --ignore-all-space --stat -- appsettings.Development.json</pre>
|
||
<p>پیامهای کامیت پیشنهادی در فایل <code>CommitMessage-1405-08-03.txt</code> کنار همین گزارش قرار دارد.</p>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="footer">
|
||
تولیدشده در تاریخ ۱۴۰۵/۰۸/۰۳ (2026-10-25) | فن آوران ساحر علم
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|
||
|