- Update submodule pointers: xAiApi, Modules/xAiModels;

- Replace stale generated contexts: remove
  Documents/GeneratedContext/xDashboard-xAi{Api,Models,Service}-20261031_*.txt
  and add the 20261102_1545xx set;
- Add Documents/Codes/XAiApiConfiguration.cs,
  Documents/Codes/XAiApiConfigurationExtensions.cs,
  Documents/Codes/XAIServiceBase.cs and
  Documents/Codes/IXAiEmbeddingServiceControllerBase.cs as backups;
- Add Documents/Docs/X121KIEA/X121XKIEA_Analytics-140412.html/.pdf and
  X121XKIEA_Analytics.pdf;
- Add Documents/Docs/Developer/Fix N08 Issue.html and
  xAiApi-14050807-Overview-6/7/7.1/7.2/8/9.html;
- Add Documents/Docs/ChangeLogs/1405-08-11-v01.html and this file.
This commit is contained in:
2026-11-02 16:38:13 +03:30
parent 58a34dfad1
commit 6b1672536f
22 changed files with 47786 additions and 12878 deletions
@@ -0,0 +1,836 @@
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>ChangeLog ۱۴۰۵/۰۸/۱۱ v01 - xSaherelmWorkspace</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;
}
.hero h1 {
margin: 0 0 8px;
font-size: 1.9em;
}
.hero p {
margin: 4px 0;
}
.meta {
display: flex;
gap: 24px;
flex-wrap: wrap;
padding: 16px 30px;
background: #f8fafc;
color: #53627a;
border-bottom: 1px solid #dbe3ef;
}
.meta strong {
color: #173b78;
}
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;
}
.section h3 {
color: #1e40af;
margin-bottom: 4px;
}
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,
.ok {
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;
}
.ok {
background: #ecfdf5;
border-right: 4px solid #087f5b;
}
.badge {
display: inline-block;
color: #fff;
border-radius: 15px;
padding: 1px 10px;
font-size: 0.8em;
white-space: nowrap;
}
.mod {
background: #b45309;
}
.new {
background: #087f5b;
}
.del {
background: #b91c1c;
}
.sub {
background: #6d28d9;
}
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-11-02) | نسخه مستند:
<strong>v01</strong>
</p>
<p>
موضوع: بازآرایی لایهٔ گفتگو در <code>xAiApi</code> (استخراج
<code>PrepareChatRequirementsAsync</code> و
<code>XPreparedChatContext</code>)، مقاوم‌سازی
<code>XAiRAGService</code> و <code>XInMemoryVectorStore</code>،
Nullable شدن <code>projectId</code> در لایهٔ داده و انتقال
<code>XAiApiConfiguration</code> از <code>xAiModels</code>
</p>
</header>
<div class="meta">
<span
><strong>دامنه:</strong> <code>xAiApi</code>,
<code>Modules/xAiModels</code>, ریشهٔ Workspace</span
>
<span
><strong>نسخه:</strong> v01 (تاریخ جدید)</span
>
<span
><strong>سند قبلی:</strong>
<a href="1405-08-08-v01.html">ChangeLog ۱۴۰۵/۰۸/۰۸</a></span
>
</div>
<main>
<section class="section">
<h2>۱. خلاصهٔ اجرایی</h2>
<p>
در این نسخه تمرکز اصلی روی بازآرایی لایهٔ گفتگو (
<code>XAIServiceBase</code>) و افزایش پایداری سرویس RAG است.
منطق تکراری «Normalize پارامترها + Retrieve + ساخت Memory + ذخیرهٔ
پیام + فراخوانی LLM» که در چند متد تکرار شده بود، به یک متد واحد
<code>PrepareChatRequirementsAsync</code> منتقل شد که خروجی آن در قالب
مدل جدید <code>XPreparedChatContext</code> بازگردانده می‌شود. در
<code>xAiModels</code> نیز پارامتر <code>projectId</code> در متدهای
Conversation به <code>Guid?</code> تغییر کرد و دو فایل پیکربندی
<code>XAiApiConfiguration</code> از این ماژول حذف شدند.
</p>
<table>
<thead>
<tr>
<th>ماژول</th>
<th>فایل تغییریافته</th>
<th>افزوده</th>
<th>حذف‌شده</th>
<th>شرح</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Modules/xAiModels</code></td>
<td>۶</td>
<td>۰</td>
<td>۲</td>
<td>
Nullable شدن <code>projectId</code>، افزودن
<code>ToEmbedding</code>، حذف پیکربندی‌های API
</td>
</tr>
<tr>
<td><code>xAiApi</code></td>
<td>۹</td>
<td>۱</td>
<td>۱</td>
<td>
بازآرایی <code>XAIServiceBase</code>، مقاوم‌سازی RAG و
Vector Store، رفع باگ فایل‌های پیوست
</td>
</tr>
<tr>
<td>ریشهٔ Workspace</td>
<td>۳</td>
<td>۱۳</td>
<td>۳</td>
<td>
به‌روزرسانی Contextهای تولیدشده، افزودن
<code>Documents/Codes</code>، مستندات توسعه و
<code>X121KIEA</code>
</td>
</tr>
</tbody>
</table>
</section>
<section class="section">
<h2>۲. تغییرات ماژول <code>Modules/xAiModels</code></h2>
<h3>۲-۱. حذف پیکربندی‌های API از ماژول مدل</h3>
<p>
دو فایل پیکربندی از <code>xAiModels</code> حذف شدند. این کلاس‌ها
مربوط به پیکربندی سرویس <code>xAiApi</code> بودند و در ماژول
مدل جای نادرستی داشتند؛ نسخهٔ پشتیبان آن‌ها در
<code>Documents/Codes/</code> (ریشهٔ Workspace) نگهداری می‌شود.
</p>
<table>
<thead>
<tr>
<th>نوع</th>
<th>فایل</th>
<th>توضیح</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="badge del">حذف</span></td>
<td><code>Configurations/XAiApiConfiguration.cs</code></td>
<td>
کلاس پیکربندی (Models، DefaultProject/Conversation Resource
Identifiers) از ماژول مدل حذف شد
</td>
</tr>
<tr>
<td><span class="badge del">حذف</span></td>
<td><code>Extensions/XAiApiConfigurationExtensions.cs</code></td>
<td>
<code>IsValid</code> و <code>GetDefaultModel</code> مربوط به
پیکربندی API از ماژل حذف شد
</td>
</tr>
</tbody>
</table>
<div class="note">
<b>نکته:</b> پیش از حذف، از نبود مصرف‌کننده در
<code>xAiApi</code> اطمینان حاصل شد؛ build پروژه با ۰ خطا انجام شد.
</div>
<h3>۲-۲. Nullable شدن <code>projectId</code> در لایهٔ داده</h3>
<p>
برای پشتیبانی از حالت «پروژه پیش‌فرض کاربر»، پارامتر
<code>projectId</code> در متدهای مرتبط با Conversation از
<code>Guid</code> به <code>Guid?</code> تغییر کرد. این تغییر با
Nullable شدن <code>ProjectId</code>/<code>ConversationId</code> در
<code>XAiResponseRequest</code> (نسخهٔ ۱۴۰۵/۰۸/۰۸) هم‌راستا است.
</p>
<table>
<thead>
<tr>
<th>نوع</th>
<th>فایل</th>
<th>توضیح</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>Interfaces/IXAiDataProvider.cs</code></td>
<td>
امضای <code>GetDefaultConversation</code>: پارامتر
<code>projectId</code> از <code>Guid</code> به
<code>Guid?</code>
</td>
</tr>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>Providers/XAiDataProvider.cs</code></td>
<td>
<b>۱)</b> <code>GetDefaultConversation</code>،
<code>HasDefaultConversation</code> و
<code>CreateDefaultConversation</code> با
<code>Guid?</code> تطبیق داده شدند؛ بررسی
<code>!projectId.HasValue</code> جایگزین
<code>projectId.IsNull()</code> شد.
<br />
<b>۲)</b> در پیش‌بارگذاری Project از
<code>projectId.Value</code> استفاده می‌شود.
<br />
<b>۳)</b> اصلاح مهم در پیش‌بارگذاری Conversation: شرط
<code>x.ProjectId == projectId</code> به
<code>x.ProjectId == project.Id</code> تغییر کرد (پیش‌تر با
<code>Guid?</code> قابل‌اعتماد نبود).
<br />
<b>۴)</b> ذخیرهٔ بردار: <code>item.Embedding.ToJSON()</code> به
<code>item.Embedding.ToEmbedding()</code> تغییر کرد.
</td>
</tr>
</tbody>
</table>
<h3>۲-۳. افزودن متد تبدیل Embedding و اصلاح نگارشی</h3>
<table>
<thead>
<tr>
<th>نوع</th>
<th>فایل</th>
<th>توضیح</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>Extensions/XEmbeddingExtensions.cs</code></td>
<td>
افزودن متد Extension
<code>ToEmbedding(this ReadOnlyMemory&lt;float&gt;)</code> که
بردار را به نمایش JSON تبدیل می‌کند؛ استفاده در ذخیرهٔ
پایدار بردارها در دیتابیس
</td>
</tr>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>Extensions/XAiModelsExtensions.cs</code></td>
<td>
اصلاح نگارشی نام متد
<code>GetDafualtProject</code> ←
<code>GetDafaultProject</code> (رفع typo)
</td>
</tr>
</tbody>
</table>
<div class="note">
<b>سازگاری:</b> تغییر نام
<code>GetDafualtProject</code> یک تغییر API-شکن است. تمام
مصرف‌کننده‌ها در <code>xAiApi</code> به‌روزرسانی شدند (شامل
<code>XAIServiceBase.LoadConversations</code>).
</div>
</section>
<section class="section">
<h2>۳. تغییرات ماژول <code>xAiApi</code></h2>
<h3>۳-۱. بازآرایی <code>XAIServiceBase</code> (تغییر اصلی)</h3>
<p>
این فایل با ۹۴۷ خط تغییر (۵۷۲ افزوده / ۷۳۲ حذف) بزرگ‌ترین تغییر
این نسخه است. منطق تکراری پیش‌نیازهای گفتگو در متدهای مختلف
(<code>AskTextAsync</code>، <code>AskTextAsEnumerable</code>،
<code>AskTextByContextAsync</code>،
<code>AskTextFromKnowledgeAsync</code>،
<code>AskAsync</code>، <code>AskAsEnumerable</code>) تکرار
شده بود و به متد واحدی منتقل شد.
</p>
<table>
<thead>
<tr>
<th>نوع</th>
<th>عضو</th>
<th>توضیح</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="badge new">افزوده</span></td>
<td><code>PrepareChatRequirementsAsync</code></td>
<td>
متد مرکزی جدید: Normalize پارامترها، حل Project/Conversation
پیش‌فرض، Ingest فایل‌های پیوست، Retrieve کانتکست RAG،
ساخت History، ذخیرهٔ پیام Prompt و برگرداندن
<code>XPreparedChatContext</code>
</td>
</tr>
<tr>
<td><span class="badge new">افزوده</span></td>
<td><code>NormalizeRagParams</code></td>
<td>
استخراج منطق Normalize (
<code>topK</code>، <code>minScore</code>،
<code>type</code>) از ۶ متد به یک متد؛ اکنون
<code>minScore</code> در بازهٔ <code>[0,1]</code> نرمال
می‌شود (مطابق اعتبارسنجی)
</td>
</tr>
<tr>
<td><span class="badge new">افزوده</span></td>
<td><code>GetHistory</code></td>
<td>
بازطراحی امضا: از
<code>GetHistory(ChatMessage, bool)</code> به دو Overload
<code>GetHistory(prompt, forcePrompt)</code> و
<code>GetHistory(prompt, context)</code> تغییر کرد؛ دومی برای
مسیر بدون‌گفتگو (بدون ذخیرهٔ پیام) استفاده می‌شود
</td>
</tr>
<tr>
<td><span class="badge del">حذف</span></td>
<td><code>AskLLMAsync</code></td>
<td>
متد فراخوانی LLM حذف شد؛ منطق آن مستقیماً در متدهای
<code>Ask*</code> ادغام شد تا جریان History/پاسخ یکپارچه
باشد
</td>
</tr>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>AskAsync</code></td>
<td>
بازنویسی کامل؛ اکنون از
<code>PrepareChatRequirementsAsync</code> استفاده می‌کند، پیام
Assistant را ذخیره می‌کند و خروجی
<code>XAiMessageDto</code> برمی‌گرداند
</td>
</tr>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>AskAsEnumerable</code></td>
<td>
بازنویسی جریان SSE: استفاده از
<code>prep.History</code>، پاسخ‌های
<code>XAiResonseMessage</code> با
<code>Role = Assistant</code>،
<code>RespondTo = prep.PersistedPromptMessage.Id</code>،
توالی <code>Sequence++</code> و ذخیرهٔ پیام کامل در پایان
جریان
</td>
</tr>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>PrepareMemory</code></td>
<td>
پارامترها بازطراحی شد و اکنون با مسیر
<code>resolveConversation</code> هماهنگ است
</td>
</tr>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td>پرامپت RAG</td>
<td>
<code>configuration.RAGDescriptor.PromptName</code> به ثابت
<code>XAiApiConstants.XAiApiRagPromptName</code> تغییر کرد تا
نام پرامپت مستقل از Descriptor باشد
</td>
</tr>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>LoadConversations</code></td>
<td>
فراخوانی اصلاح‌شدهٔ
<code>GetDafaultProject</code> (مطابق اصلاح typo در
<code>xAiModels</code>)
</td>
</tr>
</tbody>
</table>
<h3>۳-۲. مدل مشترک <code>XPreparedChatContext</code></h3>
<p>
فایل جدید <code>Models/XPreparedChatContext.cs</code> مدل انتقال
پیش‌نیازهای گفتگو بین متدهای داخلی را تعریف می‌کند.
</p>
<pre>
public class XPreparedChatContext
{
public XAiProjectDto Project { get; set; }
public XAiConversationDto Conversation { get; set; }
public IList&lt;ChatMessage&gt; History { get; set; }
public IList&lt;XAiVectorSearchResult&gt; Context { get; set; }
public XAiMessageDto PersistedPromptMessage { get; set; }
}</pre
>
<div class="ok">
<b>اثر:</b> کاهش محسوس تکرار کد و کاهش ریسک ناسازگاری میان مسیرهای
<code>Ask</code>، <code>AskStream</code> و
<code>AskWithContext</code>.
</div>
<h3>۳-۳. مقاوم‌سازی <code>XAiRAGService</code></h3>
<p>
حلقهٔ Ingest هر فایل اکنون در یک <code>try/catch</code> مستقل قرار
گرفته است؛ خطای یک فایل، کل عملیات Ingest را متوقف نمی‌کند.
</p>
<table>
<thead>
<tr>
<th>تغییر</th>
<th>توضیح</th>
</tr>
</thead>
<tbody>
<tr>
<td>مدیریت خطای per-file</td>
<td>
<code>catch (Exception ex)</code> با
<code>logger.LogError</code> اضافه شد؛ در صورت شکست
Chunk/Embedding، فایل آپلودشده حذف می‌شود تا فایل
یتیم در Storage باقی نماند
</td>
</tr>
<tr>
<td>آپلود و مرجع‌دهی فایل</td>
<td>
<code>fileProvider.Upload</code> و
<code>fileProvider.AddReference</code> با
<code>providedFor</code>/<code>forProvidedId</code> بر اساس
Scope اضافه شد (پیش‌تر فایل صرفاً آپلود می‌شد)
</td>
</tr>
<tr>
<td>حذف بردارهای کهنه</td>
<td>
<code>RemoveVectorsAsync</code> با
<code>identifierPrefix</code> برای حذف بردارهای قبلی همان
سند در حالت <code>replaceExisting</code>؛ ترتیب نیز
تغییر کرد — اکنون <b>پس از</b> Embed موفق انجام می‌شود
(در صورت شکست Embed، بردارهای قبلی سالم می‌مانند)
</td>
</tr>
<tr>
<td>ساختار کد</td>
<td>
بازچینش پارامترها و بلوک‌ها؛ حذف فاصله‌های اضافی و
یکسان‌سازی قالب‌بندی
</td>
</tr>
</tbody>
</table>
<h3>۳-۴. ایمنی نخ (Thread-Safety) در <code>XInMemoryVectorStore</code></h3>
<p>
بازیابی Session اکنون داخل <code>lock (found.SyncRoot)</code> انجام
می‌شود و با بررسی
<code>ReferenceEquals(current, found)</code> از دست‌رفتن Session در
اثر حذف هم‌زمان جلوگیری می‌کند.
</p>
<pre>
// قبل: خواندن/به‌روزرسانی بدون قفل
if (!sessions.TryGetValue(sessionId, out found) || !OwnerMatches(found, ownerId)) return false;
found.LastAccessAtUtc = DateTime.UtcNow;
// بعد: دسترسی اتمیک
lock (found.SyncRoot)
{
if (!sessions.TryGetValue(sessionId, out current) || !ReferenceEquals(current, found))
return false;
if (!OwnerMatches(found, ownerId)) return false;
if (found.IsExpired(DateTime.UtcNow)) { sessions.TryRemove(sessionId, out found); return false; }
found.LastAccessAtUtc = DateTime.UtcNow;
session = found;
}</pre
>
<h3>۳-۵. رفع اشکالات و اصلاحات جزئی</h3>
<table>
<thead>
<tr>
<th>نوع</th>
<th>فایل</th>
<th>توضیح</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="badge mod">رفع اشکال</span></td>
<td><code>Controllers/XAiServiceControllerBase.cs</code></td>
<td>
<b>رفع باگ کلیدی:</b> در مسیر <code>Ask</code> مقدار
<code>files: null</code> به <code>files</code> تغییر کرد؛
پیش‌تر فایل‌های پیوست به سرویس AI منتقل نمی‌شدند و RAG
روی فایل‌ها کار نمی‌کرد
</td>
</tr>
<tr>
<td><span class="badge mod">رفع اشکال</span></td>
<td><code>Extensions/XModelsExtensions.cs</code></td>
<td>
اعتبارسنجی درخواست <code>ChatWithDocuments</code> ساده شد؛
<code>TopK</code> و <code>MinScore</code> دیگر اجباری
نیستند (مقادیر پیش‌فرض از
<code>RAGDescriptor</code> اعمال می‌شود)
</td>
</tr>
<tr>
<td><span class="badge mod">رفع اشکال</span></td>
<td><code>Middlewares/XAiModelProxyMiddleware.cs</code></td>
<td>
اصلاح اپراتور منطقی
<code>(!apiKey.IsNullOrEmpty()) |</code> ←
<code>||</code> در بررسی احراز هویت
</td>
</tr>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>Providers/XAiEmbeddingServiceBase.cs</code></td>
<td>
<code>using var generator = GetEmbeddingGenerator();</code> ←
<code>var generator = ...</code>؛ چون Generator در متد
<code>Dispose</code> نمی‌شود، استفاده از
<code>using</code> باعث Dispose زودهنگام می‌شد
</td>
</tr>
<tr>
<td><span class="badge mod">تغییر</span></td>
<td><code>Controllers/ChatWithDocumentsController.cs</code></td>
<td>
مرتب‌سازی پارامترهای فراخوانی
<code>EmbedChunks</code> (تغییر صرفاً ظاهری/ترتیبی)
</td>
</tr>
<tr>
<td><span class="badge del">حذف</span></td>
<td><code>Interfaces/IXAiEmbeddingServiceControllerBase.cs</code></td>
<td>
رابط کنترلر Embedding حذف شد؛ نسخهٔ پشتیبان در
<code>Documents/Codes/IXAiEmbeddingServiceControllerBase.cs</code>
ریشهٔ Workspace موجود است
</td>
</tr>
</tbody>
</table>
</section>
<section class="section">
<h2>۴. تغییرات ریشهٔ Workspace</h2>
<table>
<thead>
<tr>
<th>نوع</th>
<th>فایل / مسیر</th>
<th>توضیح</th>
</tr>
</thead>
<tbody>
<tr>
<td><span class="badge del">حذف</span></td>
<td>
<code>Documents/GeneratedContext/xDashboard-xAiApi-20261031_105908.txt</code>
<code
>xDashboard-xAiModels-20261031_105909.txt</code
>
<code>xDashboard-xAiService-20261031_105909.txt</code>
</td>
<td>
Contextهای تولیدشدهٔ قدیمی حذف شدند (مجموعاً حدود
۲۳٬۵۰۰ خط)
</td>
</tr>
<tr>
<td><span class="badge new">افزوده</span></td>
<td>
<code>Documents/GeneratedContext/xDashboard-xAiApi-20261102_154558.txt</code>
<code
>xDashboard-xAiModels-20261102_154559.txt</code
>
<code>xDashboard-xAiService-20261102_154559.txt</code>
</td>
<td>
Contextهای تازهٔ تولیدشده پس از Refactor جایگزین شدند
</td>
</tr>
<tr>
<td><span class="badge new">افزوده</span></td>
<td>
<code>Documents/Codes/XAiApiConfiguration.cs</code>،
<code>Documents/Codes/XAiApiConfigurationExtensions.cs</code>
</td>
<td>
نسخهٔ پشتیبان فایل‌های حذف‌شده از
<code>xAiModels</code>
</td>
</tr>
<tr>
<td><span class="badge new">افزوده</span></td>
<td>
<code>Documents/Codes/XAIServiceBase.cs</code>،
<code>Documents/Codes/IXAiEmbeddingServiceControllerBase.cs</code>
</td>
<td>
نسخهٔ پشتیبان فایل‌های بازآرایی‌شده/حذف‌شده در
<code>xAiApi</code>
</td>
</tr>
<tr>
<td><span class="badge new">افزوده</span></td>
<td>
<code>Documents/Docs/X121KIEA/X121XKIEA_Analytics-140412.html</code>
<code>X121XKIEA_Analytics-140412.pdf</code>
<code>X121XKIEA_Analytics.pdf</code>
</td>
<td>
مستندات تحلیلی X121 (نسخهٔ HTML و PDF)
</td>
</tr>
<tr>
<td><span class="badge new">افزوده</span></td>
<td>
<code>Documents/Docs/Developer/Fix N08 Issue.html</code>،
<code>xAiApi-14050807-Overview-6.html</code>،
<code>xAiApi-14050807-Overview-7.html</code>،
<code>xAiApi-14050807-Overview-7.1.html</code>،
<code>xAiApi-14050807-Overview-7.2.html</code>،
<code>xAiApi-14050807-Overview-8.html</code>،
<code>xAiApi-14050807-Overview-9.html</code>
</td>
<td>
گزارش‌های بازبینی و بررسی اشکال N08
</td>
</tr>
<tr>
<td><span class="badge sub">Submodule</span></td>
<td><code>xAiApi</code>، <code>Modules/xAiModels</code></td>
<td>
Pointerها به‌روزرسانی می‌شوند (محتوای فعلی Working Tree
این دو زیرماژول، شامل تغییرات این نسخه)
</td>
</tr>
</tbody>
</table>
</section>
<section class="section">
<h2>۵. اعتبارسنجی</h2>
<pre>
dotnet build xAiApi/xAiApi.csproj --nologo -v q
64 Warning(s) (MSB3277 — از قبل موجود، مربوط به تعارض نسخهٔ NameReference)
0 Error(s)</pre
>
<div class="note">
تست Runtime / End-to-End (جریان SSE، Ingest با فایل، Retrieve چندسطحی،
انتقال به <code>Guid?</code> در مسیر Conversation پیش‌فرض) در این
مرحله انجام نشده است.
</div>
</section>
<section class="section">
<h2>۶. نکات و هشدارها (نیازمند بررسی)</h2>
<div class="warn">
<b>۱) تغییر API-شکن در <code>xAiModels</code>:</b> حذف
<code>XAiApiConfiguration</code> و
<code>XAiApiConfigurationExtensions</code> از ماژل مدل. هر پروژه یا
سرویس دیگری که به این ماژل وابسته است و از این کلاس‌ها استفاده
می‌کند باید به‌روزرسانی شود.
</div>
<div class="warn">
<b>۲) تغییر نام <code>GetDafualtProject</code> ←
<code>GetDafaultProject</code>:</b> همهٔ مصرف‌کننده‌ها در
<code>xAiApi</code> به‌روزرسانی شدند، اما در صورت وجود مصرف‌کننده در
سایر ماژول‌های Solution باید بررسی شود.
</div>
<div class="warn">
<b>۳) شرط <code>x.ProjectId == project.Id</code>:</b> این اصلاح
وابسته به این است که <code>project</code> پیش‌تر بارگذاری شده باشد. در
صورت خالی بودن، <code>project.Id</code> منجر به
<code>InvalidOperationException</code> می‌شود.
</div>
<div class="warn">
<b>۴) نقش پیام در <code>AskAsEnumerable</code>:</b> Role از
<code>System</code> به <code>Assistant</code> تغییر کرد؛ در صورتی که
مصرف‌کنندگان SSE به Role وابسته باشند، نیاز به بررسی دارند.
</div>
<div class="warn">
<b>۵) حذف فایل در مسیر خطا:</b> در <code>XAiRAGService</code>، فایل
آپلودشده در صورت شکست Chunk/Embedding حذف می‌شود؛ در صورت خطای
دسترسی، این حذف نیز ممکن است با خطا مواجه شود که در
<code>catch</code> ثبت می‌شود.
</div>
<div class="warn">
<b>۶) پرامپت <code>ChatWithDocuments</code>:</b> همچنان باید در
<code>appsettings</code> محیط Production موجود باشد؛ در غیر این صورت
<code>PrepareMemory</code> خطای <code>InvalidConfiguration</code> می‌دهد.
</div>
</section>
<section class="section">
<h2>۷. ترتیب پیشنهادی Commit</h2>
<ol>
<li><code>Modules/xAiModels</code> (وابستگی)</li>
<li><code>xAiApi</code></li>
<li>مخزن اصلی (Pointerها، مستندات، Contextها)</li>
</ol>
</section>
<section class="section">
<h2>۸. فایل‌های مستند این نسخه</h2>
<p>
گزارش:
<code>Documents/Docs/ChangeLogs/1405-08-11-v01.html</code>
</p>
<p>
Commit message:
<code>Documents/Docs/ChangeLogs/CommitMessage-1405-08-11-v01.txt</code>
</p>
<p>
برای مستندسازی تغییرات بعدی در همین تاریخ، پسوند را به
<code>v02</code> و پس از آن <code>v03</code> افزایش دهید.
</p>
</section>
</main>
<footer>
تولیدشده در تاریخ ۱۴۰۵/۰۸/۱۱ (2026-11-02) | xSaherelmWorkspace |
ChangeLog v01
</footer>
</div>
</body>
</html>
@@ -0,0 +1,129 @@
================================================================================
Commit Message - xSaherelmWorkspace
تاریخ: ۱۴۰۵/۰۸/۱۱ (2026-11-02)
نسخه مستند: v01
گزارش کامل: Documents/Docs/ChangeLogs/1405-08-11-v01.html
================================================================================
هدف: بازآرایی لایهٔ گفتگو در xAiApi (استخراج PrepareChatRequirementsAsync و
مدل XPreparedChatContext)، مقاوم‌سازی XAiRAGService و XInMemoryVectorStore،
Nullable شدن projectId در لایهٔ داده xAiModels و انتقال XAiApiConfiguration
به سطح ریشهٔ Workspace.
ترتیب Commit: [1] xAiModels -> [2] xAiApi -> [3] Root
[1] Modules/xAiModels
Make projectId Nullable in Data Provider and Remove Api Configuration
- IXAiDataProvider.GetDefaultConversation: projectId changed from Guid to Guid?;
- XAiDataProvider.GetDefaultConversation / HasDefaultConversation /
CreateDefaultConversation: adapt to Guid? (use !projectId.HasValue instead of
projectId.IsNull(); resolve project via projectId.Value);
- XAiDataProvider: conversation lookup predicate fixed to
x.ProjectId == project.Id (was x.ProjectId == projectId);
- XEmbeddingExtensions: add ToEmbedding(this ReadOnlyMemory<float>) to persist
embeddings as JSON;
- XAiDataProvider: use item.Embedding.ToEmbedding() instead of ToJSON() when
upserting vectors;
- XAiModelsExtensions: rename GetDafualtProject -> GetDafaultProject (typo fix);
- Remove Configurations/XAiApiConfiguration.cs and
Extensions/XAiApiConfigurationExtensions.cs (Api configuration does not belong
to the models module).
BREAKING: XAiApiConfiguration / XAiApiConfigurationExtensions removed from
xAiModels; GetDafualtProject renamed to GetDafaultProject.
Files: D Configurations/XAiApiConfiguration.cs;
D Extensions/XAiApiConfigurationExtensions.cs;
M Extensions/XAiModelsExtensions.cs;
M Extensions/XEmbeddingExtensions.cs;
M Interfaces/IXAiDataProvider.cs;
M Providers/XAiDataProvider.cs
[2] xAiApi
Refactor Chat Pipeline into PrepareChatRequirementsAsync and Harden RAG Services
- XAIServiceBase: add PrepareChatRequirementsAsync as the single entry point
for chat prerequisites (normalize RAG params, resolve default
project/conversation, ingest attachments, retrieve RAG context, build history,
persist prompt message) and return the new XPreparedChatContext;
- XAIServiceBase: add NormalizeRagParams (topK / minScore / type) and use it in
all Ask* methods instead of duplicated inline normalization;
- XAIServiceBase: rework GetHistory - the single
GetHistory(ChatMessage, bool) signature is replaced by two overloads
GetHistory(prompt, forcePrompt) and GetHistory(prompt, context); the latter is
used by the non-persisted chat path;
- XAIServiceBase: remove AskLLMAsync; LLM invocation is now inlined in each
Ask* method over prep.History;
- XAIServiceBase: rewrite AskAsync and AskAsEnumerable on top of
PrepareChatRequirementsAsync; streamed responses now use Role = Assistant,
RespondTo = prep.PersistedPromptMessage.Id and Sequence++;
- XAIServiceBase: use XAiApiConstants.XAiApiRagPromptName instead of
configuration.RAGDescriptor.PromptName;
- XAIServiceBase.LoadConversations: call the renamed GetDafaultProject;
- Add Models/XPreparedChatContext.cs (Project, Conversation, History, Context,
PersistedPromptMessage) as the shared context between actions;
- XAiRAGService: wrap each file ingest in its own try/catch with
logger.LogError so one bad file no longer aborts the whole ingest;
- XAiRAGService: upload the file and add a scope reference
(providedFor / forProvidedId) for the ingested scope;
- XAiRAGService: remove stale vectors of the same document via
RemoveVectorsAsync(identifierPrefix) when replaceExisting is set;
- XInMemoryVectorStore: make session retrieval thread-safe via
lock (found.SyncRoot) and ReferenceEquals check against concurrent removal;
- XAiServiceControllerBase.Ask: pass the attached files to the AI service
(was files: null) so RAG works on attachments;
- XModelsExtensions: relax ChatWithDocuments ask validation - TopK and
MinScore are optional again (defaults come from RAGDescriptor);
- XAiModelProxyMiddleware: use logical OR instead of bitwise OR in the
authentication check;
- XAiEmbeddingServiceBase: do not dispose the embedding generator
(removed `using` to avoid premature disposal);
- ChatWithDocumentsController: reorder EmbedChunks parameters;
- Remove Interfaces/IXAiEmbeddingServiceControllerBase.cs.
Files: A Models/XPreparedChatContext.cs;
D Interfaces/IXAiEmbeddingServiceControllerBase.cs;
M Controllers/ChatWithDocumentsController.cs;
M Controllers/XAiServiceControllerBase.cs;
M Extensions/XModelsExtensions.cs;
M Middlewares/XAiModelProxyMiddleware.cs;
M Providers/XAIServiceBase.cs;
M Providers/XAiEmbeddingServiceBase.cs;
M Providers/XAiRAGService.cs;
M Providers/XInMemoryVectorStore.cs
[3] Workspace (root)
- Update submodule pointers: xAiApi, Modules/xAiModels;
- Replace stale generated contexts: remove
Documents/GeneratedContext/xDashboard-xAi{Api,Models,Service}-20261031_*.txt
and add the 20261102_1545xx set;
- Add Documents/Codes/XAiApiConfiguration.cs,
Documents/Codes/XAiApiConfigurationExtensions.cs,
Documents/Codes/XAIServiceBase.cs and
Documents/Codes/IXAiEmbeddingServiceControllerBase.cs as backups;
- Add Documents/Docs/X121KIEA/X121XKIEA_Analytics-140412.html/.pdf and
X121XKIEA_Analytics.pdf;
- Add Documents/Docs/Developer/Fix N08 Issue.html and
xAiApi-14050807-Overview-6/7/7.1/7.2/8/9.html;
- Add Documents/Docs/ChangeLogs/1405-08-11-v01.html and this file.
Validation:
- dotnet build xAiApi/xAiApi.csproj --nologo -v q -> 0 Error(s),
64 pre-existing warnings (MSB3277);
- Runtime / end-to-end tests not performed.
Known Issues (to fix before release):
- Removing XAiApiConfiguration from xAiModels is a breaking change for any
other consumer of that module;
- GetDafaultProject rename is breaking for out-of-module consumers;
- XAiDataProvider now relies on `project` being loaded before the
`x.ProjectId == project.Id` predicate;
- SSE response Role changed from System to Assistant - verify SSE consumers;
- The "ChatWithDocuments" prompt must exist in production appsettings.
Suggested root commit title:
Refactor Chat Pipeline, Harden RAG Services, Nullable projectId (۱۴۰۵/۰۸/۱۱ v01)
For additional documentation use v02:
1405-08-11-v02.html
CommitMessage-1405-08-11-v02.txt
================================================================================