Files
xSaherelmWorkspace/Documents/Docs/Developer/xAiApi-14050807-Overview-7.2.html
saherelm 6b1672536f - 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.
2026-11-02 16:38:13 +03:30

472 lines
28 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.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-007</div>
<div>نسخه: ۷.۰</div>
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
<div>طبقه‌بندی: محرمانه</div>
</div>
</div>
<div class="document-title">
<span class="label">REVIEW #7 — CHANGES VERIFICATION</span>
<h1>بازبینی هفتم و راستی‌آزمایی اصلاحات سامانه xAiApi</h1>
<h2>بررسی کدهای به‌روزشده پس از بازبینی ششم — تأیید رفع N-10 و چند مورد باز، کشف مشاهده جدید N-11</h2>
</div>
</header>
<div class="document-body">
<div class="intro-text">
<strong>خلاصه مدیریتی:</strong><br />
این گزارش بر اساس مقایسه کدهای جدید (فایل‌های ضمیمه <code>xDashboard-xAiApi</code>، <code>xDashboard-xAiModels</code> و <code>xDashboard-xAiService</code>) با موارد بازبینی ششم تهیه شده است. <strong>خبر خوب: باگ بحرانی N-10 برطرف شده است</strong> و <code>AskWithFiles</code> اکنون فایل‌ها را به‌درستی به سرویس پاس می‌دهد. همچنین موارد N-03، N-04، N-05، N-07 و X-01 نیز اصلاح شده‌اند. با این حال، موارد F-10، F-11، N-08 و N-09 همچنان باز هستند و یک <strong>مشاهده جدید N-11</strong> در <code>XAiDataProvider</code> کشف شد که در صورت فراخوانی با <code>projectId</code> تهی، جستجوی Default Conversation را خراب می‌کند.
</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 و سرویس داشته است. مهم‌ترین تغییر، اصلاح <code>AskWithFiles</code> است که پیش‌تر فایل‌ها را نادیده می‌گرفت. علاوه بر آن، اعتبارسنجی <code>XAiDocumentAskRequest</code> دیگر <code>TopK</code> و <code>MinScore</code> را الزامی نمی‌داند، خطاهای Ingest لاگ می‌شوند، بررسی null برای فایل آپلودی انجام می‌شود، نقش پاسخ Streaming به <code>Assistant</code> اصلاح شده و منبع Prompt RAG یکسان‌سازی شده است.
</p>
<div class="stats-grid">
<div class="stat-card success">
<div class="stat-value">۶</div>
<div class="stat-label">مورد اصلاح/تأیید شده</div>
</div>
<div class="stat-card danger">
<div class="stat-value">۱</div>
<div class="stat-label">مشاهده جدید (N-11)</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-10</code> اصلاح شد. در <code>XAiServiceControllerBase.AskWithFiles</code> اکنون <code>files: files</code> به <code>aiService.AskAsync</code> پاس داده می‌شود. مورد <code>N-03</code> نیز با حذف الزام <code>TopK/MinScore</code> از <code>IsValid</code> برطرف شده است. موارد <code>N-04</code>، <code>N-05</code>، <code>N-07</code> و <code>X-01</code> نیز در کد جدید تأیید شدند.
</div>
<div class="warning-box">
<strong>مشاهده جدید N-11:</strong> در <code>XAiDataProvider.HasDefaultConversation</code> و <code>GetDefaultConversation</code>، وقتی <code>projectId</code> تهی یا <code>Guid.Empty</code> باشد، پروژه پیش‌فرض Resolve می‌شود اما در Query نهایی از <code>projectId</code> اصلی (تهی) به‌جای <code>project.Id</code> استفاده می‌شود. این باعث می‌شود Default Conversation پیدا نشود. این مورد در بازبینی‌های قبلی دیده نشده بود.
</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-10</td>
<td><code>AskWithFiles</code> فایل‌ها را نادیده می‌گرفت</td>
<td>
در <code>XAiServiceControllerBase.AskWithFiles</code> فراخوانی سرویس به‌صورت <code>files: files</code> اصلاح شده است. <code>AskWithFilesStream</code> نیز از ابتدا درست بود.
</td>
<td><span class="badge badge-fixed">اصلاح شد</span></td>
</tr>
<tr class="highlight-row">
<td>N-03</td>
<td>الزام نادرست <code>TopK/MinScore</code> در <code>XAiDocumentAskRequest.IsValid</code></td>
<td>
در <code>xAiApi/Extensions/XModelsExtensions.cs</code>، <code>IsValid(this XAiDocumentAskRequest source)</code> فقط <code>Prompt</code> و <code>SessionId</code> را بررسی می‌کند و دیگر <code>TopK.HasValue &amp;&amp; MinScore.HasValue</code> را الزامی نمی‌داند.
</td>
<td><span class="badge badge-fixed">اصلاح شد</span></td>
</tr>
<tr class="highlight-row">
<td>N-04</td>
<td><code>catch { }</code> در بلوک Ingest</td>
<td>
در <code>XAIServiceBase.AskAsync</code> و <code>AskAsEnumerable</code>، خطاهای Ingest با <code>logger.LogError</code> لاگ می‌شوند و <code>ingestResult.SkippedFiles</code> نیز بررسی می‌شود.
</td>
<td><span class="badge badge-fixed">اصلاح شد</span></td>
</tr>
<tr class="highlight-row">
<td>N-05</td>
<td>استفاده از <code>uploadedFile.Id</code> بدون بررسی null</td>
<td>
در <code>XAiRAGService.IngestAsync</code>، شرط <code>!uploadedFile.IsNullOrDefault() &amp;&amp; ... &amp;&amp; !uploadedFile.Id.IsDefaultGuid()</code> پیش از <code>AddReference</code> بررسی می‌شود.
</td>
<td><span class="badge badge-fixed">اصلاح شد</span></td>
</tr>
<tr class="highlight-row">
<td>N-07</td>
<td>نقش پاسخ Streaming به‌جای <code>Assistant</code> با <code>System</code> ذخیره می‌شد</td>
<td>
در <code>XAIServiceBase.AskAsEnumerable</code>، هم Chunkهای yielded و هم پیام نهایی ذخیره‌شده با <code>XAiChatRole.Assistant</code> ساخته می‌شوند.
</td>
<td><span class="badge badge-fixed">اصلاح شد</span></td>
</tr>
<tr class="highlight-row">
<td>X-01</td>
<td>دو منبع متفاوت برای Prompt RAG</td>
<td>
در <code>XAIServiceBase.GetHistory(string, context)</code> و <code>PrepareMemory</code> هر دو از <code>XAiApiConstants.XAiApiRagPromptName</code> استفاده می‌کنند.
</td>
<td><span class="badge badge-fixed">اصلاح شد</span></td>
</tr>
<tr>
<td>N-01/N-02</td>
<td>RAG در AskAsEnumerable و NullReferenceException در AskStream</td>
<td>
<code>AskAsEnumerable</code> از <code>PrepareChatRequirementsAsync</code> با RAG استفاده می‌کند. <code>AskStream</code> نیز <code>ProjectId/ConversationId</code> را بدون <code>.Value</code> پاس می‌دهد و امضاها با <code>Guid?</code> هماهنگ‌اند.
</td>
<td><span class="badge badge-fixed">تأیید شد</span></td>
</tr>
</tbody>
</table>
<div class="success-box">
<strong>✓ نتیجه راستی‌آزمایی:</strong> موارد اصلاحی این دور (N-10، N-03، N-04، N-05، N-07، X-01) به‌طور کامل در کد جدید تأیید شدند. مسیرهای <code>Ask</code>، <code>AskStream</code>، <code>AskWithFiles</code> و <code>AskWithFilesStream</code> از نظر پاس‌دادن فایل و RAG سالم به‌نظر می‌رسند.
</div>
</div>
</div>
<div class="section">
<div class="section-header">
<div class="section-number danger">۳</div>
<div class="section-title">
<h3>مشاهده جدید: N-11 — استفاده از projectId تهی در جستجوی Default Conversation</h3>
<div class="subtitle">New Observation: Default Conversation Lookup Bug</div>
</div>
</div>
<div class="section-content">
<div class="danger-box">
<strong>N-11 (مهم):</strong> در <code>XAiDataProvider.HasDefaultConversation</code> و <code>GetDefaultConversation</code>، اگر <code>projectId</code> تهی یا <code>Guid.Empty</code> باشد، پروژه پیش‌فرض Resolve می‌شود اما Query نهایی همچنان با <code>projectId</code> اصلی (تهی) اجرا می‌شود. نتیجه: Default Conversation پیدا نمی‌شود و ممکن است دوباره ایجاد شود یا خطای NotFound رخ دهد.
</div>
<p class="no-indent"><strong>کد فعلی (نمونه در GetDefaultConversation):</strong></p>
<pre class="code-block"><code>var result = await conversationRepositoryService.FindOneAsync(
cancellationToken: cancellationToken,
predicate: x =&gt;
x.ProjectId == projectId && // ⚠️ باید project.Id باشد
x.Title == resource.ResourceTitle
);</code></pre>
<p class="no-indent"><strong>اصلاح پیشنهادی:</strong></p>
<pre class="code-block"><code>var result = await conversationRepositoryService.FindOneAsync(
cancellationToken: cancellationToken,
predicate: x =&gt;
x.ProjectId == project.Id && // ✅ استفاده از پروژه Resolveشده
x.Title == resource.ResourceTitle
);</code></pre>
<div class="info-box">
<strong>محل‌های نیازمند اصلاح:</strong>
<ul>
<li><code>XAiDataProvider.HasDefaultConversation</code> — در Query نهایی <code>x.ProjectId == projectId</code></li>
<li><code>XAiDataProvider.GetDefaultConversation</code> — در Query نهایی <code>x.ProjectId == projectId</code></li>
</ul>
</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>F-10</td>
<td><code>XImageFileContentExtractor</code></td>
<td><span class="badge badge-open">باز</span></td>
<td>
اعتبارسنجی OCR در سازنده انجام می‌شود، حتی اگر <code>EnableOcrFallback = false</code> باشد. در کد جدید نیز شرط سازنده بدون توجه به فعال بودن Fallback بررسی می‌شود.
</td>
</tr>
<tr class="highlight-row">
<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>) به آن ارسال نمی‌شود:
<code>new OllamaApiClient(new Uri(descriptor.Url))</code>
</td>
</tr>
<tr class="highlight-row">
<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</code> و <code>AskTextFromKnowledgeAsEnumerable</code> همچنان باقی است. پیشنهاد ایجاد Orchestrator مشترک.
</td>
</tr>
<tr class="highlight-row">
<td>N-09</td>
<td><code>XAIServiceBase.PrepareMemory</code></td>
<td><span class="badge badge-open">باز</span></td>
<td>
متد <code>async</code> است اما هیچ <code>await</code> واقعی ندارد. باید synchronous شود یا با <code>Task.FromResult</code> جایگزین گردد.
</td>
</tr>
<tr>
<td>F-16</td>
<td><code>XAiEmbeddingServiceControllerBase</code></td>
<td><span class="badge badge-doc">قابل راستی‌آزمایی نیست</span></td>
<td>
فایل Controller مربوطه در dump کد ارائه‌شده نیست. اما اینترفیس آن همچنان وجود دارد. در صورت وجود Controller، باید وضعیت <code>[AllowAnonymous]</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">Impact Analysis</div>
</div>
</div>
<div class="section-content">
<p><strong>۵-۱. اصلاح AskWithFiles (N-10):</strong> این اصلاح، عملکرد Endpoint <code>AskWithFiles</code> را از حالت «نادیده گرفتن فایل» به «پردازش واقعی فایل» تغییر می‌دهد. این یک اصلاح بحرانی و ضروری بود.</p>
<p><strong>۵-۲. اصلاح اعتبارسنجی XAiDocumentAskRequest (N-03):</strong> با حذف الزام <code>TopK/MinScore</code>، قرارداد قبلی با کلاینت‌ها حفظ می‌شود و مقادیر پیش‌فرض در سرویس اعمال می‌شوند.</p>
<p><strong>۵-۳. بهبود خطای Ingest (N-04):</strong> خطاهای Ingest دیگر بی‌صدا بلعیده نمی‌شوند و در Log ثبت می‌شوند. این برای عیب‌یابی بسیار مهم است.</p>
<p><strong>۵-۴. اصلاح نقش پاسخ Streaming (N-07):</strong> اکنون پیام‌های Streaming با نقش <code>Assistant</code> ذخیره می‌شوند که با <code>AskAsync</code> هم‌راستا است.</p>
<p><strong>۵-۵. یکسان‌سازی Prompt RAG (X-01):</strong> حذف دو منبع متفاوت برای Prompt RAG، ریسک واگرایی را کاهش می‌دهد.</p>
<div class="info-box">
<strong>💡 نکته:</strong> با اصلاح N-10، دیگر خطای بحرانی در مسیرهای اصلی Ask وجود ندارد. اما N-11 یک باگ Latent در مسیر Default Conversation است که در سناریوهای خاص (فراخوانی با <code>projectId</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">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(--warning);font-weight:700;">P1</td>
<td>
اصلاح <code>HasDefaultConversation</code> و <code>GetDefaultConversation</code> برای استفاده از <code>project.Id</code> در Query نهایی.
</td>
<td>N-11</td>
</tr>
<tr class="highlight-row">
<td style="color:var(--warning);font-weight:700;">P1</td>
<td>
اعتبارسنجی OCR در <code>XImageFileContentExtractor</code> فقط در صورت <code>EnableOcrFallback = true</code> انجام شود.
</td>
<td>F-10</td>
</tr>
<tr class="highlight-row">
<td style="color:var(--warning);font-weight:700;">P1</td>
<td>
در <code>XAiEmbeddingServiceBase.GetEmbeddingGenerator</code> برای Ollama، نام مدل (<code>descriptor.LLM</code>) نیز به <code>OllamaApiClient</code> پاس داده شود.
</td>
<td>F-11</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>
<tr>
<td style="color:var(--primary-light);font-weight:700;">P2</td>
<td>
بررسی و مستندسازی وضعیت <code>[AllowAnonymous]</code> روی Controller مربوط به Embedding (در صورت وجود).
</td>
<td>F-16</td>
</tr>
<tr>
<td style="color:var(--primary-light);font-weight:700;">P2</td>
<td>
نوشتن تست End-to-End برای مسیرهای <code>Ask</code>، <code>AskStream</code>، <code>AskWithFiles</code>، <code>AskWithFilesStream</code> و <code>AskTextFromKnowledge*</code> با/بدون فایل و با/بدون ProjectId/ConversationId.
</td>
<td>—</td>
</tr>
</tbody>
</table>
<div class="info-box">
<strong>پیشنهاد بلندمدت:</strong> با اضافه شدن قابلیت‌های جدید، تکرار منطق 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-10</code> (باگ بحرانی AskWithFiles) برطرف شد، <code>N-03</code> اصلاح شد، خطاهای Ingest لاگ می‌شوند، بررسی null برای فایل آپلودی انجام می‌شود، نقش پاسخ Streaming اصلاح شده و منبع Prompt RAG یکسان‌سازی شده است. موارد <code>N-01</code> و <code>N-02</code> نیز همچنان برقرار هستند.
</p>
<p>
با این حال، موارد <code>F-10</code>، <code>F-11</code>، <code>N-08</code> و <code>N-09</code> همچنان باز هستند و مشاهده جدید <code>N-11</code> نیز باید پیش از Production اصلاح شود. هیچ مورد P0 باز در مسیرهای اصلی Ask مشاهده نشد، اما N-11 از نظر پایداری Default Conversation مهم است.
</p>
<div class="conclusion-box">
<h3>🎯 جمع‌بندی اجرایی بازبینی هفتم</h3>
<p>
اصلاحات این دور مثبت و مؤثر بوده‌اند. باگ بحرانی AskWithFiles رفع شده و چند مورد مهم دیگر نیز اصلاح شده‌اند. با این حال، برای Production باید N-11، F-10 و F-11 اصلاح شوند و تست‌های End-to-End برای مسیرهای اصلی اضافه گردند.
</p>
<div class="highlight">
<strong>اقدامات ضروری قبل از Production:</strong><br>
اصلاح N-11 (Default Conversation) + اصلاح F-10 (OCR Fallback) + اصلاح F-11 (مدل Ollama) + افزودن تست End-to-End + در اولویت بعدی: N-08 و N-09
</div>
</div>
<div class="success-box">
<strong>✓ ارزیابی کلی:</strong> این نسخه از نظر عملکرد اصلی Ask و AskWithFiles سالم‌تر از نسخه قبل است. با اصلاح N-11 و موارد باقی‌مانده، آمادگی برای استقرار آزمایشی و سپس 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>