- 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,536 @@
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>بازبینی ششم و راستی‌آزمایی اصلاحات | سامانه xAiApi</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');
:root{
--primary:#1a365d;--primary-light:#2c5282;--accent:#c9a961;--accent-dark:#a8893f;
--bg:#faf9f6;--card-bg:#ffffff;--text:#1a202c;--text-muted:#4a5568;
--border:#e2e8f0;--success:#38a169;--danger:#e53e3e;--warning:#dd6b20;
--info:#3182ce;--shadow:0 4px 6px rgba(0,0,0,0.05),0 10px 30px rgba(26,54,93,0.08);
}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:'Vazirmatn',Tahoma,sans-serif;background:var(--bg);color:var(--text);line-height:1.9;font-size:15px;padding:30px 15px}
.document-container{max-width:1050px;margin:0 auto;background:var(--card-bg);box-shadow:var(--shadow);border-radius:12px;overflow:hidden}
.document-header{background:linear-gradient(135deg,var(--primary) 0%,var(--primary-light) 100%);color:#fff;padding:50px 40px 40px;position:relative;border-bottom:4px solid var(--accent)}
.document-header::before{content:'';position:absolute;top:0;right:0;width:220px;height:220px;background:radial-gradient(circle,rgba(201,169,97,0.18) 0%,transparent 70%);border-radius:50%;transform:translate(50%,-50%)}
.header-top{display:flex;justify-content:space-between;align-items:center;margin-bottom:30px;position:relative;z-index:1}
.company-badge{display:flex;align-items:center;gap:12px}
.company-logo{width:60px;height:60px;background:var(--accent);border-radius:12px;box-shadow:0 4px 12px rgba(0,0,0,0.2)}
.doc-meta{text-align:left;font-size:12px;opacity:0.92}
.doc-meta div{margin-bottom:3px}
.document-title{text-align:center;position:relative;z-index:1;padding:20px 0}
.document-title .label{display:inline-block;background:rgba(201,169,97,0.2);color:var(--accent);padding:4px 16px;border-radius:20px;font-size:12px;font-weight:600;margin-bottom:15px;border:1px solid rgba(201,169,97,0.4)}
.document-title h1{font-size:27px;font-weight:800;margin-bottom:10px;letter-spacing:-0.5px}
.document-title h2{font-size:16px;font-weight:400;opacity:0.9}
.document-body{padding:40px}
.intro-text{background:linear-gradient(to left,#f7fafc,#edf2f7);border-right:4px solid var(--accent);padding:20px 25px;border-radius:8px;margin-bottom:35px;font-size:14px;color:var(--text-muted)}
.section{margin-bottom:40px;page-break-inside:avoid}
.section-header{display:flex;align-items:center;gap:15px;padding-bottom:12px;border-bottom:2px solid var(--border);margin-bottom:20px}
.section-number{width:50px;height:50px;background:linear-gradient(135deg,var(--primary),var(--primary-light));color:#fff;border-radius:12px;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:20px;flex-shrink:0;box-shadow:0 4px 10px rgba(26,54,93,0.2)}
.section-title{flex:1}
.section-title h3{font-size:19px;font-weight:700;color:var(--primary);margin-bottom:2px}
.section-title .subtitle{font-size:12px;color:var(--text-muted)}
.section-content{padding-right:10px}
.section-content p{margin-bottom:12px;text-align:justify;text-indent:20px}
.section-content p.no-indent{text-indent:0}
.highlight-box,.info-box,.success-box,.warning-box,.danger-box{padding:18px 22px;border-radius:8px;margin:20px 0;font-size:14px}
.highlight-box{background:linear-gradient(to left,#fffaf0,#fef5e7);border:1px solid #f6e05e;border-right:4px solid var(--accent)}
.highlight-box strong{color:var(--accent-dark)}
.info-box{background:linear-gradient(to left,#ebf8ff,#e6f6ff);border:1px solid #90cdf4;border-right:4px solid var(--primary-light)}
.success-box{background:linear-gradient(to left,#f0fff4,#e6fffa);border:1px solid #9ae6b4;border-right:4px solid var(--success)}
.warning-box{background:linear-gradient(to left,#fffaf0,#fef5e7);border:1px solid #fbd38d;border-right:4px solid var(--warning)}
.danger-box{background:linear-gradient(to left,#fff5f5,#fed7d7);border:1px solid #feb2b2;border-right:4px solid var(--danger)}
.styled-table{width:100%;border-collapse:collapse;margin:20px 0;background:#fff;border-radius:8px;overflow:hidden;box-shadow:0 2px 8px rgba(0,0,0,0.05)}
.styled-table thead{background:linear-gradient(135deg,var(--primary),var(--primary-light));color:#fff}
.styled-table th{padding:14px 16px;text-align:right;font-weight:600;font-size:13px}
.styled-table td{padding:13px 16px;border-bottom:1px solid var(--border);font-size:13px;vertical-align:top}
.styled-table tbody tr:last-child td{border-bottom:none}
.styled-table tbody tr:nth-child(even){background:#f8fafc}
.styled-table .highlight-row{background:#fffaf0 !important;font-weight:600}
.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:15px;margin:25px 0}
.stat-card{background:linear-gradient(135deg,var(--primary),var(--primary-light));color:#fff;padding:20px;border-radius:10px;text-align:center;box-shadow:0 4px 12px rgba(26,54,93,0.2)}
.stat-card.success{background:linear-gradient(135deg,#276749,var(--success))}
.stat-card.danger{background:linear-gradient(135deg,#9b2c2c,var(--danger))}
.stat-card.warning{background:linear-gradient(135deg,#9c4221,var(--warning))}
.stat-card .stat-value{font-size:26px;font-weight:800;margin-bottom:5px;color:var(--accent);line-height:1.3}
.stat-card.success .stat-value,.stat-card.danger .stat-value,.stat-card.warning .stat-value{color:#fff}
.stat-card .stat-label{font-size:12px;opacity:0.95}
.conclusion-box{background:linear-gradient(135deg,var(--primary),var(--primary-light));color:#fff;padding:30px;border-radius:12px;margin:30px 0;text-align:center;box-shadow:0 8px 20px rgba(26,54,93,0.3)}
.conclusion-box h3{font-size:22px;font-weight:800;margin-bottom:15px;color:var(--accent)}
.conclusion-box p{font-size:14px;line-height:1.8;text-indent:0 !important;margin-bottom:15px}
.conclusion-box .highlight{background:rgba(201,169,97,0.2);padding:15px 20px;border-radius:8px;margin-top:20px;border:1px solid rgba(201,169,97,0.4)}
.document-footer{background:var(--primary);color:#fff;padding:25px 40px;text-align:center;font-size:12px;margin-top:40px}
.document-footer .footer-brand{font-weight:700;color:var(--accent);margin-bottom:5px;font-size:14px}
.footer-divider{width:60px;height:2px;background:var(--accent);margin:10px auto}
.page-info{text-align:center;padding:15px;font-size:11px;color:var(--text-muted);border-top:1px solid var(--border);margin-top:30px}
.badge{display:inline-block;padding:2px 10px;border-radius:12px;font-size:11px;font-weight:600;white-space:nowrap}
.badge-fixed{background:#c6f6d5;color:#22543d}
.badge-partial{background:#feebc8;color:#7b341e}
.badge-open{background:#fed7d7;color:#742a2a}
.badge-new{background:#bee3f8;color:#2a4365}
.badge-doc{background:#e9d8fd;color:#44337a}
code{background:#edf2f7;padding:2px 6px;border-radius:4px;font-family:'Consolas','Monaco',monospace;font-size:12px;direction:ltr;display:inline-block}
pre.code-block{background:#1a202c;color:#e2e8f0;padding:16px 18px;border-radius:8px;direction:ltr;text-align:left;overflow-x:auto;font-family:'Consolas','Monaco',monospace;font-size:12px;line-height:1.6;margin:15px 0;border-left:4px solid var(--accent)}
pre.code-block code{background:transparent;color:inherit;padding:0;display:inline}
ul{padding-right:20px;margin-top:10px}
li{margin-bottom:8px}
@media print{body{background:#fff;padding:0}.document-container{box-shadow:none;border-radius:0}.section{page-break-inside:avoid}}
@media (max-width:768px){.document-body{padding:25px 20px}.document-header{padding:30px 20px}.stats-grid{grid-template-columns:1fr 1fr}.header-top{flex-direction:column;gap:15px}.doc-meta{text-align:center}}
</style>
</head>
<body>
<div class="document-container">
<header class="document-header">
<div class="header-top">
<div class="company-badge"><div class="company-logo"></div></div>
<div class="doc-meta">
<div>شماره مستند: ARCH-REV-1405-006</div>
<div>نسخه: ۶.۰</div>
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
<div>طبقه‌بندی: محرمانه</div>
</div>
</div>
<div class="document-title">
<span class="label">REVIEW #6 — CHANGES VERIFICATION</span>
<h1>بازبینی ششم و راستی‌آزمایی اصلاحات سامانه xAiApi</h1>
<h2>بررسی کدهای به‌روزشده پس از بازبینی پنجم — تأیید رفع N-02، کشف خطای جدید AskWithFiles</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text">
<strong>خلاصه مدیریتی:</strong><br />
این گزارش بر اساس مقایسه کدهای جدید (ارائه‌شده در فایل‌های ضمیمه) با کدهای نسخه قبل و مستند بازبینی چهارم تهیه شده است. <strong>خبر خوب: مورد N-02 برطرف شده است</strong> و مسیر <code>AskStream</code> دیگر با <code>ProjectId/ConversationId</code> تهی کرش نمی‌کند. همچنین قابلیت‌های جدیدی (Knowledge-only Ask، AskWithFilesStream) اضافه شده‌اند. با این حال، <strong>یک خطای جدید بحرانی کشف شد</strong>: متد <code>AskWithFiles</code> فایل‌های آپلودی را نادیده می‌گیرد و آن‌ها را به سرویس پاس نمی‌دهد. علاوه بر این، چند مورد مهم از بازبینی‌های قبلی (N-03، N-04، N-05، N-07، X-01، F-10، F-11) هم‌چنان باز هستند.
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۱</div>
<div class="section-title">
<h3>خلاصه اجرایی و آمار وضعیت</h3>
<div class="subtitle">Executive Summary &amp; Status</div>
</div>
</div>
<div class="section-content">
<p>
نسخه جدید، بازآرایی قابل توجهی در لایه Controller و Interface داشته است: متدهای جدید <code>AskTextFromKnowledge*</code> برای پرسش صرفاً از دانش ذخیره‌شده، متد <code>AskWithFilesStream</code> برای Streaming با فایل، پارامترهای <code>TopK</code>/<code>MinScore</code>/<code>Type</code> در <code>XAiResponseRequest</code>، و حذف ارث‌بری <code>XAiServiceControllerBase</code> از <code>IXAiServiceControllerBase</code>. در کنار این بهبودها، یک خطای جدید مهم در <code>AskWithFiles</code> و همچنین چند مورد باز از قبل شناسایی شد.
</p>
<div class="stats-grid">
<div class="stat-card success">
<div class="stat-value">۱</div>
<div class="stat-label">مورد بحرانی اصلاح شد (N-02)</div>
</div>
<div class="stat-card danger">
<div class="stat-value">۱</div>
<div class="stat-label">خطای جدید بحرانی</div>
</div>
<div class="stat-card warning">
<div class="stat-value">۷</div>
<div class="stat-label">مورد باز از قبل</div>
</div>
<div class="stat-card">
<div class="stat-value">۴</div>
<div class="stat-label">بهبود / قابلیت جدید</div>
</div>
</div>
<div class="success-box">
<strong>مهم‌ترین دستاورد:</strong> مورد <code>N-02</code> اصلاح شد. در <code>XAiServiceControllerBase.AskStream</code> اکنون مقادیر <code>request.ProjectId</code> و <code>request.ConversationId</code> بدون <code>.Value</code> به <code>aiService.AskAsEnumerable</code> پاس داده می‌شوند. همچنین امضای این متد در <code>IXAiServiceBase</code> به <code>Guid?</code> تغییر کرده و در صورت null بودن، خود سرویس Default Project/Conversation را Resolve می‌کند. مورد <code>N-01</code> (RAG در AskAsEnumerable) نیز همچنان برقرار است.
</div>
<div class="danger-box">
<strong>مهم‌ترین خطای جدید (N-10):</strong> در <code>XAiServiceControllerBase.AskWithFiles</code>، پارامتر <code>files</code> که از فرم دریافت می‌شود، به‌اشتباه به‌صورت <code>files: null</code> به <code>aiService.AskAsync</code> پاس داده می‌شود. این یعنی Endpoint <code>AskWithFiles</code> عملاً فایل‌های کاربر را نادیده می‌گیرد و فقط به Prompt پاسخ می‌دهد. این یک نقص عملکردی جدی است که در بازبینی‌های قبلی کشف نشده بود.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۲</div>
<div class="section-title">
<h3>راستی‌آزمایی اصلاحات انجام‌شده</h3>
<div class="subtitle">Verified Fixes</div>
</div>
</div>
<div class="section-content">
<table class="styled-table">
<thead>
<tr><th>#</th><th>مورد بازبینی قبل</th><th>نتیجه راستی‌آزمایی</th><th>وضعیت</th></tr>
</thead>
<tbody>
<tr class="highlight-row">
<td>N-01</td>
<td><code>AskAsEnumerable</code> بدون RAG</td>
<td>
در <code>XAIServiceBase.AskAsEnumerable</code>، فراخوانی <code>ragProvider.RetrieveAsync</code> و پاس دادن <code>context</code> به <code>PrepareMemory</code> تأیید شد. همچنین پارامتر <code>type</code> هم به درخواست RAG اضافه شده است.
</td>
<td><span class="badge badge-fixed">اصلاح شد</span></td>
</tr>
<tr class="highlight-row">
<td>N-02</td>
<td>NullReferenceException در AskStream</td>
<td>
در <code>XAiServiceControllerBase.AskStream</code>، عبارت‌های <code>request.ProjectId.Value</code> و <code>request.ConversationId.Value</code> حذف شده و مستقیم <code>request.ProjectId</code> و <code>request.ConversationId</code> پاس می‌شوند. امضای <code>AskAsEnumerable</code> در <code>IXAiServiceBase</code> نیز با <code>Guid?</code> هماهنگ شده است.
</td>
<td><span class="badge badge-fixed">اصلاح شد</span></td>
</tr>
</tbody>
</table>
<div class="success-box">
<strong>✓ نتیجه راستی‌آزمایی:</strong> هر دو مورد بحرانی N-01 و N-02 به‌طور کامل برطرف شده‌اند. مسیر Streaming اکنون RAG دارد و با ProjectId/ConversationId تهی نیز کرش نمی‌کند.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number danger">۳</div>
<div class="section-title">
<h3>خطای جدید کشف‌شده: AskWithFiles فایل‌ها را نادیده می‌گیرد</h3>
<div class="subtitle">New Issue: AskWithFiles Ignores Files</div>
</div>
</div>
<div class="section-content">
<div class="danger-box">
<strong>N-10 (بحرانی):</strong> در <code>XAiServiceControllerBase.AskWithFiles</code>، پارامتر <code>files</code> دریافت می‌شود اما در فراخوانی سرویس به‌صورت <code>files: null</code> ارسال می‌گردد. نتیجه: Endpoint <code>AskWithFiles</code> عملاً هیچ فایلی را پردازش نمی‌کند و فقط به Prompt متنی پاسخ می‌دهد.
</div>
<p class="no-indent"><strong>کد فعلی (معیوب):</strong></p>
<pre class="code-block"><code>[HttpPost("AskWithFiles")]
[Consumes("multipart/form-data")]
public virtual async Task&lt;ActionResult&lt;string&gt;&gt; AskWithFiles(
[FromForm] XAiResponseRequest request,
[FromForm] IFormFileCollection files,
CancellationToken cancellationToken = default
)
{
try
{
if (!request.IsValid())
XException.InvalidArgs.Throw();
var userInfo = await GetUserInfo();
var connectionId = GetConnectionId();
// ⚠️ BUG: files به‌جای files: files، به‌صورت null پاس داده می‌شود
var result = await aiService.AskAsync(
files: null,
topK: request.TopK,
userInfo: userInfo,
type: request.Type,
prompt: request.Prompt,
minScore: request.MinScore,
connectionId: connectionId,
projectId: request.ProjectId,
cancellationToken: cancellationToken,
conversationId: request.ConversationId
);
return Ok(result);
}
catch (Exception ex)
{
var result = GetExceptionActionResult(ex);
return result;
}
}</code></pre>
<p class="no-indent"><strong>اصلاح پیشنهادی:</strong></p>
<pre class="code-block"><code>var result = await aiService.AskAsync(
files: files, // ← اصلاح این خط
topK: request.TopK,
userInfo: userInfo,
type: request.Type,
prompt: request.Prompt,
minScore: request.MinScore,
connectionId: connectionId,
projectId: request.ProjectId,
cancellationToken: cancellationToken,
conversationId: request.ConversationId
);</code></pre>
<div class="warning-box">
<strong>⚠️ نکته:</strong> متد <code>AskWithFilesStream</code> که هم‌زمان اضافه شده، <code>files: files</code> را به‌درستی پاس می‌دهد. فقط <code>AskWithFiles</code> باگ دارد. این باگ در بازبینی‌های قبلی هم وجود داشته اما کشف نشده بود.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۴</div>
<div class="section-title">
<h3>موارد باز از بازبینی‌های قبلی</h3>
<div class="subtitle">Still Open from Previous Reviews</div>
</div>
</div>
<div class="section-content">
<table class="styled-table">
<thead>
<tr><th>شناسه</th><th>محل</th><th>وضعیت</th><th>توضیح</th></tr>
</thead>
<tbody>
<tr class="highlight-row">
<td>N-03</td>
<td><code>XModelsExtensions.IsValid(XAiDocumentAskRequest)</code></td>
<td><span class="badge badge-open">باز</span></td>
<td>
شرط <code>source.TopK.HasValue &amp;&amp; source.MinScore.HasValue</code> همچنان الزامی است. این یک Regression و شکستن قرارداد با کلاینت‌های فعلی است. باید هر دو اختیاری شوند.
</td>
</tr>
<tr class="highlight-row">
<td>N-04</td>
<td><code>XAIServiceBase.AskAsync / AskAsEnumerable</code></td>
<td><span class="badge badge-open">باز</span></td>
<td>
<code>catch { }</code> در بلوک Ingest همچنان باقی است. در هر دو متد، خطاهای Ingest بی‌صدا بلعیده می‌شوند و <code>ingestResult</code> نیز بدون استفاده رها می‌شود. باید حداقل لاگ شود.
</td>
</tr>
<tr class="highlight-row">
<td>N-05</td>
<td><code>XAiRAGService.IngestAsync</code></td>
<td><span class="badge badge-open">باز</span></td>
<td>
<code>uploadedFile.Id</code> بدون بررسی null استفاده می‌شود. اگر <code>fileProvider.Upload</code> مقدار null برگرداند، <code>NullReferenceException</code> رخ می‌دهد.
</td>
</tr>
<tr class="highlight-row">
<td>N-07</td>
<td><code>XAIServiceBase.AskAsEnumerable</code></td>
<td><span class="badge badge-open">باز</span></td>
<td>
پاسخ نهایی Streaming با <code>XAiChatRole.System</code> ذخیره می‌شود، در حالی که در <code>AskAsync</code> پاسخ با <code>XAiChatRole.Assistant</code> ذخیره می‌شود. این ناسازگاری باید اصلاح شود.
</td>
</tr>
<tr>
<td>X-01</td>
<td><code>XAiDocumentRAGDescriptor.PromptName</code></td>
<td><span class="badge badge-partial">جزئی</span></td>
<td>
در <code>PrepareMemory</code> از <code>XAiApiConstants.XAiApiRagPromptName</code> استفاده می‌شود، اما در <code>GetHistory(string, context)</code> از <code>configuration.RAGDescriptor.PromptName</code>. هر دو مقدار فعلاً برابرند اما دو منبع، ریسک واگرایی دارند.
</td>
</tr>
<tr>
<td>F-10</td>
<td><code>XImageFileContentExtractor</code></td>
<td><span class="badge badge-open">باز</span></td>
<td>
اعتبارسنجی OCR در سازنده انجام می‌شود، حتی اگر <code>EnableOcrFallback = false</code> باشد.
</td>
</tr>
<tr>
<td>F-11</td>
<td><code>XAiEmbeddingServiceBase.GetEmbeddingGenerator</code></td>
<td><span class="badge badge-open">باز</span></td>
<td>
در حالت Ollama، <code>OllamaApiClient</code> با URI ساخته می‌شود و نام مدل (<code>descriptor.LLM</code>) به آن ارسال نمی‌شود.
</td>
</tr>
<tr>
<td>F-16</td>
<td><code>XAiEmbeddingServiceControllerBase</code></td>
<td><span class="badge badge-doc">قابل راستی‌آزمایی نیست</span></td>
<td>
فایل Controller مربوطه در dump کد ارائه‌شده نیست. اما <code>IXAiEmbeddingServiceControllerBase</code> همچنان وجود دارد. اگر Controller نیز موجود است، باید <code>[AllowAnonymous]</code> حذف شود.
</td>
</tr>
<tr>
<td>N-08</td>
<td><code>XAIServiceBase</code></td>
<td><span class="badge badge-open">باز</span></td>
<td>
تکرار منطق RAG بین <code>AskAsync</code> و <code>AskAsEnumerable</code> همچنان باقی است. با اضافه شدن <code>AskTextFromKnowledgeAsync/AsEnumerable</code>، تکرار سه‌گانه شده است.
</td>
</tr>
<tr>
<td>N-09</td>
<td><code>XAIServiceBase.PrepareMemory</code></td>
<td><span class="badge badge-partial">جزئی</span></td>
<td>
متد <code>async</code> است اما هیچ <code>await</code> واقعی ندارد. باید synchronous شود یا با <code>Task.CompletedTask</code> جایگزین گردد.
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۵</div>
<div class="section-title">
<h3>تحلیل قابلیت‌های جدید</h3>
<div class="subtitle">Analysis of New Features</div>
</div>
</div>
<div class="section-content">
<p class="no-indent"><strong>۵-۱. AskTextFromKnowledge (پرسش صرفاً از دانش)</strong></p>
<p>
دو متد جدید <code>AskTextFromKnowledgeAsync</code> و <code>AskTextFromKnowledgeAsEnumerable</code> به <code>IXAiServiceBase</code> اضافه شده‌اند. این متدها در <code>XAIServiceBase</code> پیاده‌سازی شده و از <code>ragProvider.RetrieveAsync</code> با <code>IncludeUser = true</code> و <code>IncludeGlobal = true</code> استفاده می‌کنند.
</p>
<p>
<strong>نکته مهم:</strong> این متدها پیام‌ها را در Conversation ذخیره نمی‌کنند و ProjectId/ConversationId نمی‌گیرند. برای سناریوی «جستجو در دانش بدون ذخیره تاریخچه» مناسب‌اند. اما اگر از این Endpointها در محیط چندکاربره استفاده شود، با توجه به اینکه <code>IncludeUser = true</code> است و userInfo از Context کاربر گرفته می‌شود، جداسازی دانش کاربران حفظ می‌شود.
</p>
<div class="info-box">
<strong>💡 نکته:</strong> در این متدها، <code>GetHistory(prompt, context)</code> فراخوانی می‌شود که از <code>configuration.RAGDescriptor.PromptName</code> استفاده می‌کند. این همان X-01 است که باید با <code>PrepareMemory</code> (که از <code>XAiApiConstants.XAiApiRagPromptName</code> استفاده می‌کند) هم‌راستا شود.
</div>
<p class="no-indent" style="margin-top:25px;"><strong>۵-۲. AskWithFilesStream</strong></p>
<p>
این Endpoint جدید، Streaming با فایل را پشتیبانی می‌کند و <code>files: files</code> را به‌درستی به <code>aiService.AskAsEnumerable</code> پاس می‌دهد. به‌نظر یک قابلیت مثبت و کامل است.
</p>
<p class="no-indent" style="margin-top:25px;"><strong>۵-۳. پارامترهای جدید در XAiResponseRequest</strong></p>
<p>
<code>Type</code>، <code>TopK</code> و <code>MinScore</code> به <code>XAiResponseRequest</code> اضافه شده‌اند. این امکان کنترل دقیق‌تر بازیابی را فراهم می‌کند. اما <code>IsValid()</code> برای <code>XAiResponseRequest</code> همچنان فقط <code>Prompt</code> را بررسی می‌کند و اعتبارسنجی بیشتری روی این فیلدها انجام نمی‌دهد. در <code>XAIServiceBase</code> نرمال‌سازی انجام می‌شود (Clamp)، بنابراین از این نظر امن است.
</p>
<p class="no-indent" style="margin-top:25px;"><strong>۵-۴. تغییر نام AskWithContext* به AskTextByContext*</strong></p>
<p>
این تغییر نام، شفافیت بیشتری به همراه دارد (TextByContext بهتر مشخص می‌کند که پاسخ متنی است و از Context داده‌شده استفاده می‌کند). <code>ChatWithDocumentsController</code> نیز با این تغییرات هماهنگ شده است.
</p>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۶</div>
<div class="section-title">
<h3>پیشنهادهای اصلاحی اولویت‌دار</h3>
<div class="subtitle">Prioritized Recommendations</div>
</div>
</div>
<div class="section-content">
<table class="styled-table">
<thead>
<tr><th>اولویت</th><th>اقدام</th><th>شناسه</th></tr>
</thead>
<tbody>
<tr class="highlight-row">
<td style="color:var(--danger);font-weight:700;">P0</td>
<td>
اصلاح <code>AskWithFiles</code> برای پاس دادن <code>files: files</code> به‌جای <code>files: null</code>.
</td>
<td>N-10</td>
</tr>
<tr class="highlight-row">
<td style="color:var(--danger);font-weight:700;">P0</td>
<td>
اختیاری کردن <code>TopK</code> و <code>MinScore</code> در <code>XAiDocumentAskRequest.IsValid</code>.
</td>
<td>N-03</td>
</tr>
<tr class="highlight-row">
<td style="color:var(--danger);font-weight:700;">P0</td>
<td>
حذف <code>catch { }</code> در بلوک Ingest و لاگ کردن خطا. بهتر است <code>SkippedFiles</code> یا خطا در پاسخ گزارش شود.
</td>
<td>N-04</td>
</tr>
<tr class="highlight-row">
<td style="color:var(--danger);font-weight:700;">P0</td>
<td>
اصلاح نقش پاسخ در <code>AskAsEnumerable</code> از <code>System</code> به <code>Assistant</code> (هم برای Chunk و هم برای پیام نهایی ذخیره‌شده).
</td>
<td>N-07</td>
</tr>
<tr>
<td style="color:var(--warning);font-weight:700;">P1</td>
<td>
بررسی null برای <code>uploadedFile</code> پیش از استفاده از <code>uploadedFile.Id</code> در <code>XAiRAGService</code>.
</td>
<td>N-05</td>
</tr>
<tr>
<td style="color:var(--warning);font-weight:700;">P1</td>
<td>
یکسان‌سازی منبع Prompt RAG بین <code>GetHistory(string, context)</code> و <code>PrepareMemory</code> (استفاده از <code>XAiApiConstants.XAiApiRagPromptName</code> در هر دو).
</td>
<td>X-01</td>
</tr>
<tr>
<td style="color:var(--warning);font-weight:700;">P1</td>
<td>
اصلاح F-10 (اعتبارسنجی OCR در حالت غیرفعال) و F-11 (ارسال نام مدل به <code>OllamaApiClient</code>).
</td>
<td>F-*</td>
</tr>
<tr>
<td style="color:var(--primary-light);font-weight:700;">P2</td>
<td>
حذف یا مستندسازی <code>[AllowAnonymous]</code> روی Embedding/Embeddings (نیازمند بررسی فایل Controller که در dump نیست).
</td>
<td>F-16</td>
</tr>
<tr>
<td style="color:var(--primary-light);font-weight:700;">P2</td>
<td>
ایجاد یک لایه مشترک (مانند <code>IXAiChatOrchestrator</code>) برای حذف تکرار سه‌گانه منطق RAG بین <code>AskAsync</code>، <code>AskAsEnumerable</code> و <code>AskTextFromKnowledge*</code>.
</td>
<td>N-08</td>
</tr>
<tr>
<td style="color:var(--primary-light);font-weight:700;">P2</td>
<td>
Synchronous کردن <code>PrepareMemory</code> یا استفاده از <code>Task.FromResult</code> به‌جای <code>async</code> بدون <code>await</code>.
</td>
<td>N-09</td>
</tr>
</tbody>
</table>
<div class="info-box">
<strong>پیشنهاد بلندمدت:</strong> با اضافه شدن قابلیت‌های جدید (Knowledge-only Ask، AskWithFilesStream)، تکرار منطق RAG بیشتر شده است. ایجاد یک Orchestrator مشترک که جریان «Resolve Project/Conversation → Ingest (اختیاری) → Retrieve → PrepareMemory → Generate» را یک‌جا پیاده‌سازی کند، ضروری به‌نظر می‌رسد.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number">۷</div>
<div class="section-title">
<h3>جمع‌بندی نهایی</h3>
<div class="subtitle">Final Conclusion</div>
</div>
</div>
<div class="section-content">
<p>
نسخه جدید، پیشرفت قابل توجهی داشته است: <code>N-02</code> برطرف شد، قابلیت‌های جدید (Knowledge-only Ask، AskWithFilesStream، کنترل دقیق‌تر RAG با Type/TopK/MinScore) اضافه شدند، و کد Controller تمیزتر شده است. با این حال، یک خطای جدید بحرانی در <code>AskWithFiles</code> کشف شد که باید فوراً اصلاح شود، و چند مورد مهم از بازبینی‌های قبلی (N-03، N-04، N-05، N-07) هم‌چنان باز هستند.
</p>
<div class="conclusion-box">
<h3>🎯 جمع‌بندی اجرایی بازبینی ششم</h3>
<p>
معماری و طراحی بهبود یافته و N-01/N-02 برطرف شده‌اند، اما خطای جدید در AskWithFiles و چند مورد باز از قبل، آمادگی Production را همچنان کاهش می‌دهد.
</p>
<div class="highlight">
<strong>اقدامات ضروری قبل از Production:</strong><br>
اصلاح AskWithFiles (N-10) + اختیاری کردن TopK/MinScore (N-03) + لاگ‌کردن خطاهای Ingest (N-04) + اصلاح نقش پاسخ Streaming (N-07) + بررسی null برای uploadedFile (N-05) + یکسان‌سازی Prompt RAG (X-01)
</div>
</div>
<div class="warning-box">
<strong>ارزیابی کلی:</strong> این نسخه از نظر معماری و قابلیت‌ها پیشرفت کرده است، اما یک خطای جدید بحرانی در AskWithFiles وجود دارد که پاسخ‌های نادرست به کاربران ارائه می‌دهد. توصیه می‌شود قبل از هر استقرار، یک Suite تست End-to-End برای مسیرهای <code>Ask</code>، <code>AskStream</code>، <code>AskWithFiles</code>، <code>AskWithFilesStream</code> و <code>AskTextFromKnowledge*</code> با و بدون فایل، با و بدون ProjectId/ConversationId، و برای کاربر Admin و غیر Admin نوشته شود. این تست‌ها می‌توانند باگ‌هایی مانند N-10 را قبل از رسیدن به Production کشف کنند.
</div>
</div>
</div>
<div class="page-info">
این مستند محرمانه بوده و صرفاً جهت بررسی فنی داخلی تهیه شده است. هرگونه کپی‌برداری یا افشا بدون اجازه کتبی ممنوع است.
</div>
</div>
<footer class="document-footer">
<div class="footer-brand">بازبینی فنی ششم بر اساس کدهای به‌روزشده پروژه xSaherelmWorkspace</div>
<div class="footer-divider"></div>
<div>تاریخ تهیه: آبان ۱۴۰۵ &nbsp;|&nbsp; نسخه: ۶.۰ &nbsp;|&nbsp; طبقه‌بندی: محرمانه</div>
</footer>
</div>
</body>
</html>