- 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.
1325 lines
60 KiB
HTML
1325 lines
60 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>گزارش بررسی تغییرات کد | xAiApi / xAiModels / xAiService</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;
|
||
--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: 1000px;
|
||
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: white;
|
||
padding: 50px 40px 40px;
|
||
position: relative;
|
||
border-bottom: 4px solid var(--accent);
|
||
}
|
||
|
||
.document-header::before {
|
||
content: '';
|
||
position: absolute;
|
||
top: 0; right: 0;
|
||
width: 200px; height: 200px;
|
||
background: radial-gradient(circle, rgba(201,169,97,0.15) 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);
|
||
display: flex; align-items: center; justify-content: center;
|
||
color: white; font-weight: 800; font-size: 22px;
|
||
}
|
||
|
||
.doc-meta { text-align: left; font-size: 12px; opacity: 0.9; }
|
||
.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: 28px;
|
||
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: white;
|
||
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-number.ok { background: linear-gradient(135deg, var(--success), #22543d); }
|
||
.section-number.warn { background: linear-gradient(135deg, var(--warning), #9c4221); }
|
||
|
||
.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; }
|
||
|
||
.section-content h4 {
|
||
color: var(--primary);
|
||
font-size: 16px;
|
||
margin: 20px 0 10px;
|
||
padding-right: 10px;
|
||
border-right: 3px solid var(--accent);
|
||
}
|
||
|
||
.section-content ul, .section-content ol {
|
||
padding-right: 25px;
|
||
margin: 10px 0;
|
||
}
|
||
|
||
.section-content li { margin-bottom: 6px; }
|
||
|
||
.highlight-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #f6e05e;
|
||
border-right: 4px solid var(--accent);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.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);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.success-box {
|
||
background: linear-gradient(to left, #f0fff4, #e6fffa);
|
||
border: 1px solid #9ae6b4;
|
||
border-right: 4px solid var(--success);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.warning-box {
|
||
background: linear-gradient(to left, #fffaf0, #fef5e7);
|
||
border: 1px solid #fbd38d;
|
||
border-right: 4px solid var(--warning);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.danger-box {
|
||
background: linear-gradient(to left, #fff5f5, #fed7d7);
|
||
border: 1px solid #fc8181;
|
||
border-right: 4px solid var(--danger);
|
||
padding: 18px 22px;
|
||
border-radius: 8px;
|
||
margin: 20px 0;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.styled-table {
|
||
width: 100%;
|
||
border-collapse: collapse;
|
||
margin: 20px 0;
|
||
background: white;
|
||
border-radius: 8px;
|
||
overflow: hidden;
|
||
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||
font-size: 13px;
|
||
}
|
||
|
||
.styled-table thead {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
}
|
||
|
||
.styled-table th {
|
||
padding: 14px 16px;
|
||
text-align: right;
|
||
font-weight: 600;
|
||
font-size: 13px;
|
||
}
|
||
|
||
.styled-table td {
|
||
padding: 12px 16px;
|
||
border-bottom: 1px solid var(--border);
|
||
}
|
||
|
||
.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(3, 1fr);
|
||
gap: 15px;
|
||
margin: 25px 0;
|
||
}
|
||
|
||
.stat-card {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
padding: 20px;
|
||
border-radius: 10px;
|
||
text-align: center;
|
||
box-shadow: 0 4px 12px rgba(26,54,93,0.2);
|
||
}
|
||
|
||
.stat-card .stat-value {
|
||
font-size: 24px;
|
||
font-weight: 800;
|
||
margin-bottom: 5px;
|
||
color: var(--accent);
|
||
line-height: 1.3;
|
||
}
|
||
|
||
.stat-card .stat-label {
|
||
font-size: 12px;
|
||
opacity: 0.9;
|
||
}
|
||
|
||
.file-tree {
|
||
background: #f8fafc;
|
||
border: 1px solid var(--border);
|
||
border-radius: 8px;
|
||
padding: 18px 22px;
|
||
margin: 15px 0;
|
||
font-family: Consolas, 'Courier New', monospace;
|
||
font-size: 12.5px;
|
||
direction: ltr;
|
||
text-align: left;
|
||
line-height: 1.85;
|
||
color: var(--text-muted);
|
||
}
|
||
|
||
.file-tree .folder { color: var(--primary); font-weight: 600; }
|
||
.file-tree .new { color: var(--success); font-weight: 600; }
|
||
.file-tree .modify { color: var(--warning); font-weight: 600; }
|
||
.file-tree .file { color: #4a5568; }
|
||
|
||
.badge {
|
||
display: inline-block;
|
||
padding: 2px 10px;
|
||
border-radius: 12px;
|
||
font-size: 11px;
|
||
font-weight: 700;
|
||
}
|
||
|
||
.badge.new { background: #c6f6d5; color: #22543d; }
|
||
.badge.mod { background: #feebc8; color: #7b341e; }
|
||
.badge.fix { background: #fed7d7; color: #9b2c2c; }
|
||
.badge.ok { background: #bee3f8; color: #2a4365; }
|
||
|
||
.checklist { list-style: none; padding: 0; margin: 15px 0; }
|
||
|
||
.checklist li {
|
||
padding: 10px 15px;
|
||
background: #f8fafc;
|
||
border-right: 3px solid var(--primary-light);
|
||
margin-bottom: 8px;
|
||
border-radius: 6px;
|
||
font-size: 13.5px;
|
||
}
|
||
|
||
.checklist li::before {
|
||
content: '✓';
|
||
color: var(--success);
|
||
font-weight: 700;
|
||
margin-left: 10px;
|
||
display: inline-block;
|
||
}
|
||
|
||
.checklist li.warn::before {
|
||
content: '⚠';
|
||
color: var(--warning);
|
||
}
|
||
|
||
.checklist li.fail::before {
|
||
content: '✗';
|
||
color: var(--danger);
|
||
}
|
||
|
||
.conclusion-box {
|
||
background: linear-gradient(135deg, var(--primary), var(--primary-light));
|
||
color: white;
|
||
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: 12px;
|
||
}
|
||
|
||
.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: white;
|
||
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;
|
||
}
|
||
|
||
.module-card {
|
||
background: #f8fafc;
|
||
border: 2px solid var(--border);
|
||
border-radius: 12px;
|
||
padding: 20px 22px;
|
||
margin: 18px 0;
|
||
position: relative;
|
||
}
|
||
|
||
.module-card.new-module { border-color: var(--success); background: linear-gradient(to left, #f0fff4, #e6fffa); }
|
||
.module-card.mod-module { border-color: var(--warning); background: linear-gradient(to left, #fffaf0, #fef5e7); }
|
||
|
||
.module-header {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 12px;
|
||
margin-bottom: 12px;
|
||
padding-bottom: 10px;
|
||
border-bottom: 1px dashed var(--border);
|
||
}
|
||
|
||
.module-icon {
|
||
width: 36px; height: 36px;
|
||
border-radius: 8px;
|
||
background: var(--primary);
|
||
color: white;
|
||
display: flex; align-items: center; justify-content: center;
|
||
font-weight: 800; font-size: 15px;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.module-icon.new { background: var(--success); }
|
||
.module-icon.mod { background: var(--warning); }
|
||
|
||
.module-header h4 {
|
||
font-size: 15px;
|
||
font-weight: 700;
|
||
color: var(--primary);
|
||
margin: 0;
|
||
}
|
||
|
||
.module-header .module-tag {
|
||
font-size: 11px;
|
||
color: var(--text-muted);
|
||
margin-right: 8px;
|
||
}
|
||
|
||
@media print {
|
||
body { background: white; 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; }
|
||
.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">X</div>
|
||
</div>
|
||
<div class="doc-meta">
|
||
<div>شماره مستند: REV-1405-001</div>
|
||
<div>نسخه: ۱.۰</div>
|
||
<div>تاریخ تهیه: آبان ۱۴۰۵</div>
|
||
<div>طبقهبندی: داخلی — فنی</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="document-title">
|
||
<span class="label">CODE REVIEW REPORT</span>
|
||
<h1>گزارش بررسی تغییرات کد</h1>
|
||
<h2>xAiApi / xAiModels / xAiService — تحلیل تغییرات، قابلیتها و کیفیت</h2>
|
||
</div>
|
||
</header>
|
||
|
||
<div class="document-body">
|
||
|
||
<div class="intro-text">
|
||
<strong>هدف مستند:</strong><br>
|
||
این مستند به بررسی جامع تغییرات اعمالشده در ماژولهای <strong>xAiApi</strong>، <strong>xAiModels</strong> و <strong>xAiService</strong> میپردازد. تغییرات شامل افزودن قابلیتهای <strong>RAG (بازیابی و تقویت)</strong>، <strong>Chat With Documents</strong>، <strong>Knowledge Base</strong>، <strong>Model Proxy</strong>، <strong>Text Chunker</strong>، <strong>Embedding Service</strong>، <strong>In-Memory Vector Store</strong> و مجموعهای از <strong>File Content Extractors</strong> است. تحلیل بر اساس مقایسه با الگوهای موجود پروژه و اصول معماری نرمافزار انجام شده است.
|
||
</div>
|
||
|
||
<!-- SECTION 1: خلاصه اجرایی -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number ok">۱</div>
|
||
<div class="section-title">
|
||
<h3>خلاصه اجرایی</h3>
|
||
<div class="subtitle">Executive Summary</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
<p>تغییرات اعمالشده، یک <strong>ارتقاء معماری چشمگیر</strong> در اکوسیستم هوش مصنوعی پروژه محسوب میشود. کدبیس از یک سرویس ساده پرسشوپاسخ، به یک <strong>سامانه چندلایه با قابلیت RAG، Vector Store، Embedding، استخراج محتوا از انواع فایل و پروکسی مدل</strong> تبدیل شده است.</p>
|
||
|
||
<div class="stats-grid">
|
||
<div class="stat-card">
|
||
<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 class="stat-card">
|
||
<div class="stat-value">۳</div>
|
||
<div class="stat-label">قابلیت کلان جدید</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="highlight-box">
|
||
<strong>نتیجه کلیدی:</strong> تغییرات با <strong>کیفیت بالا، انطباق با الگوهای موجود، و رعایت اصول SOLID</strong> پیادهسازی شدهاند. نقاط قوت اصلی عبارتند از: جداسازی دغدغهها (Separation of Concerns)، استفاده از Interface برای توسعهپذیری، و طراحی لایهای صحیح. تنها چند نکته بهبود جزئی شناسایی شده است.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 2: نمای کلی تغییرات -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۲</div>
|
||
<div class="section-title">
|
||
<h3>نمای کلی تغییرات به تفکیک ماژول</h3>
|
||
<div class="subtitle">Changes Overview by Module</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<h4>۲.۱ — ماژول xAiApi (لایه ارائه و زیرساخت)</h4>
|
||
|
||
<div class="file-tree">
|
||
<span class="folder">xAiApi/</span>
|
||
├── <span class="folder">Controllers/</span>
|
||
│ ├── <span class="new">ChatWithDocumentsController.cs</span> ← NEW (RAG درونحافظهای)
|
||
│ ├── <span class="new">KnowledgeController.cs</span> ← NEW (RAG پایدار روی DB)
|
||
│ ├── <span class="modify">XAiServiceControllerBase.cs</span> ← MOD (افزودن AskWithFiles, ExtractContent)
|
||
│ └── <span class="file">AccountController.cs, StartupController.cs, TestIdentity.cs, XAiController.cs</span>
|
||
├── <span class="folder">Providers/</span>
|
||
│ ├── <span class="new">XAiRAGService.cs</span> ← NEW (Persistent RAG)
|
||
│ ├── <span class="new">XAiEmbeddingService.cs</span> ← NEW (تولید Embedding)
|
||
│ ├── <span class="new">XAiEmbeddingServiceBase.cs</span> ← NEW
|
||
│ ├── <span class="new">XInMemoryVectorStore.cs</span> ← NEW (Vector Store با TTL)
|
||
│ ├── <span class="new">XInMemoryVectorStoreCleanupService.cs</span> ← NEW (Background Service)
|
||
│ ├── <span class="new">XTextChunker.cs</span> ← NEW (Chunking سلسلهمراتبی)
|
||
│ ├── <span class="modify">XAIServiceBase.cs</span> ← MOD (پشتیبانی از Context, Memory)
|
||
│ ├── <span class="modify">XAiService.cs, XDefaultThinkingAiService.cs</span>
|
||
│ └── <span class="folder">Extractors/</span>
|
||
│ ├── <span class="new">XPdfFileContentExtractor.cs</span> ← NEW (با Fallback به تصویر)
|
||
│ ├── <span class="new">XRtfFileContentExtractor.cs</span> ← NEW
|
||
│ ├── <span class="new">XEpubFileContentExtractor.cs</span> ← NEW
|
||
│ ├── <span class="new">XDocxFileContentExtractor.cs</span> ← NEW
|
||
│ ├── <span class="new">XHtmlFileContentExtractor.cs</span> ← NEW
|
||
│ ├── <span class="new">XCodeFileContentExtractor.cs</span> ← NEW
|
||
│ ├── <span class="new">XImageFileContentExtractor.cs</span> ← NEW (OCR با Tesseract)
|
||
│ ├── <span class="new">XAudioFileContentExtractor.cs</span> ← NEW (Whisper + FFmpeg)
|
||
│ ├── <span class="new">XExcelFileContentExtractor.cs</span> ← NEW
|
||
│ ├── <span class="new">XVisionFileContentExtractor.cs</span> ← NEW
|
||
│ ├── <span class="new">XPlainTextFileContentExtractor.cs</span> ← NEW
|
||
│ ├── <span class="new">XPowerPointFileContentExtractor.cs</span> ← NEW
|
||
│ ├── <span class="new">XOpenDocumentFileContentExtractor.cs</span> ← NEW
|
||
│ └── <span class="modify">XFileContentExtractor.cs</span> ← MOD (Composite)
|
||
├── <span class="folder">Middlewares/</span>
|
||
│ └── <span class="new">XAiModelProxyMiddleware.cs</span> ← NEW (Proxy برای LLM)
|
||
├── <span class="folder">Models/</span>
|
||
│ ├── <span class="new">XAiDocumentModels.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiDocumentSession.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiKnowledgeModels.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiModelProxyConfiguration.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiOCRDescriptor.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiTransciptDescriptor.cs</span> ← NEW
|
||
│ ├── <span class="new">XPDFToImageDescriptor.cs</span> ← NEW
|
||
│ ├── <span class="new">XPreparedChatContext.cs</span> ← NEW
|
||
│ ├── <span class="new">XTextChunk.cs</span> ← NEW
|
||
│ └── <span class="new">XTextChunkerDescriptor.cs</span> ← NEW
|
||
├── <span class="folder">DI/</span>
|
||
│ └── <span class="modify">XDIHelperExtension.cs</span> ← MOD (ثبت سرویسهای جدید)
|
||
├── <span class="folder">Extensions/</span>
|
||
│ ├── <span class="new">XModelsExtensions.cs</span> ← NEW (کارخانه Client مدلها)
|
||
│ └── <span class="modify">XProgramExtensions.cs</span> ← MOD
|
||
├── <span class="folder">Database/</span>
|
||
│ └── <span class="modify">XAiApiDbContext.cs</span> ← MOD (Registerar جدید)
|
||
├── <span class="folder">Migrations/</span>
|
||
│ └── <span class="new">20261102054538_InitialMigrationAiApi.cs</span> ← NEW
|
||
└── <span class="modify">Startup.cs</span> ← MOD
|
||
</div>
|
||
|
||
<h4>۲.۲ — ماژول xAiModels (لایه دامنه)</h4>
|
||
|
||
<div class="file-tree">
|
||
<span class="folder">xAiModels/</span>
|
||
├── <span class="folder">Constants/</span>
|
||
│ ├── <span class="new">XAiChatRole.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiDataProviderConstants.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiKnowledgeScope.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiModelProviderType.cs</span> ← NEW
|
||
│ └── <span class="modify">XAiModelsConstants.cs</span> ← MOD (Knowledge, Error Route)
|
||
├── <span class="folder">Models/</span>
|
||
│ ├── <span class="new">XAiModelDescriptor.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiPromptDescriptor.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiResonseMessage.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiResponseRequest.cs</span> ← NEW
|
||
│ ├── <span class="new">XFileExtractionResult.cs</span> ← NEW
|
||
│ ├── <span class="folder">Entities/</span>
|
||
│ │ ├── <span class="new">XAiVector.cs</span> ← NEW
|
||
│ │ ├── <span class="modify">XAiMessage.cs</span> ← MOD (Metadata, ConversationId)
|
||
│ │ └── <span class="file">XAiProject.cs, XAiConversation.cs</span>
|
||
│ └── <span class="folder">Dtos/</span>
|
||
│ ├── <span class="new">XAiVectorDto.cs</span> ← NEW
|
||
│ └── <span class="new">XAiVectorSearchResult.cs</span> ← NEW
|
||
├── <span class="folder">Helpers/</span>
|
||
│ ├── <span class="new">VectorHelper.cs</span> ← NEW (Normalize, CosineSimilarity)
|
||
│ └── <span class="modify">XAiModelsHelper.cs</span> ← MOD (Vector Repository Descriptor)
|
||
├── <span class="folder">Extensions/</span>
|
||
│ ├── <span class="new">ChatResponseExtensions.cs</span> ← NEW
|
||
│ ├── <span class="new">ChatRoleExtensions.cs</span> ← NEW
|
||
│ ├── <span class="new">XAiApiConfigurationExtensions.cs</span> ← NEW
|
||
│ ├── <span class="new">XEmbeddingExtensions.cs</span> ← NEW (JSON ↔ float[])
|
||
│ └── <span class="modify">XAiModelsExtensions.cs</span> ← MOD (ToChatMessages, AddModelDescriptorApiKey)
|
||
├── <span class="folder">Interfaces/</span>
|
||
│ ├── <span class="new">IXAiDataProvider.cs</span> ← NEW (Vector Operations)
|
||
│ └── <span class="folder">Entities/</span>
|
||
│ └── <span class="new">IXAiVectorRepository.cs, IXAiVectorKeyGenerator.cs, ...</span>
|
||
├── <span class="folder">Providers/</span>
|
||
│ ├── <span class="modify">XAiDataProvider.cs</span> ← MOD (Vector CRUD + Search)
|
||
│ ├── <span class="folder">Entities/</span>
|
||
│ │ ├── <span class="new">XAiVectorEFRepository.cs</span> ← NEW
|
||
│ │ ├── <span class="new">XAiVectorMongoRepository.cs</span> ← NEW
|
||
│ │ ├── <span class="new">XAiVectorInMemoryRepository.cs</span> ← NEW
|
||
│ │ └── ...
|
||
│ └── <span class="folder">GraphQL/, Hubs/, Enrichers/</span>
|
||
└── <span class="modify">DI/XDIHelperExtension.cs</span> ← MOD
|
||
</div>
|
||
|
||
<h4>۲.۳ — ماژول xAiService (لایه کمکی)</h4>
|
||
|
||
<div class="file-tree">
|
||
<span class="folder">xAiService/</span>
|
||
├── <span class="folder">Constants/</span>
|
||
│ ├── <span class="new">ConfigurationNodeNames.cs</span> ← NEW
|
||
│ └── <span class="new">XAiServiceConstants.cs</span> ← NEW
|
||
├── <span class="folder">Extensions/</span>
|
||
│ └── <span class="new">XAiServiceExtensions.cs</span> ← NEW (اعتبارسنجی UserInfo)
|
||
└── <span class="modify">DI/XDIHelperExtension.cs</span> ← MOD (partial)
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 3: قابلیتهای جدید کلان -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۳</div>
|
||
<div class="section-title">
|
||
<h3>قابلیتهای کلان جدید</h3>
|
||
<div class="subtitle">Major New Capabilities</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<div class="module-card new-module">
|
||
<div class="module-header">
|
||
<div class="module-icon new">۱</div>
|
||
<h4>RAG — بازیابی و تقویت (Retrieval-Augmented Generation)</h4>
|
||
<span class="module-tag">xAiApi / XAiRAGService</span>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:10px;">سرویس <code>XAiRAGService</code> یک پیادهسازی کامل از RAG با <strong>Scope-based Isolation</strong> ارائه میدهد. سطوح ایزولاسیون شامل:</p>
|
||
<ul>
|
||
<li><strong>Conversation</strong> — قابل مشاهده فقط در همان مکالمه</li>
|
||
<li><strong>Project</strong> — قابل مشاهده در تمام مکالمات پروژه</li>
|
||
<li><strong>User</strong> — پایگاه دانش شخصی</li>
|
||
<li><strong>Global</strong> — برای همه (نوشتن نیازمند نقش Admin)</li>
|
||
</ul>
|
||
<p style="text-indent:0;margin-top:10px;">جریان کار: <strong>Extract → Chunk → Embed → Store → Retrieve → Generate</strong> با پشتیبانی از Migration برای Vectorهای قدیمی.</p>
|
||
</div>
|
||
|
||
<div class="module-card new-module">
|
||
<div class="module-header">
|
||
<div class="module-icon new">۲</div>
|
||
<h4>Chat With Documents — RAG درونحافظهای</h4>
|
||
<span class="module-tag">xAiApi / ChatWithDocumentsController + XInMemoryVectorStore</span>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:10px;">کنترلر <code>ChatWithDocumentsController</code> امکان گفتگو با اسناد را در یک <strong>Session موقت</strong> فراهم میکند. مکانیزم:</p>
|
||
<ul>
|
||
<li>Ingest فایلها → تولید <code>SessionId</code> → Ask/AskStream → Delete Session</li>
|
||
<li><code>XInMemoryVectorStore</code> با <strong>TTL</strong> قابل تنظیم و Cleanup Background Service</li>
|
||
<li>پشتیبانی از SSE برای پاسخهای Streaming با ارجاع به منابع</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="module-card new-module">
|
||
<div class="module-header">
|
||
<div class="module-icon new">۳</div>
|
||
<h4>Knowledge Base — RAG پایدار روی جدول XAiVector</h4>
|
||
<span class="module-tag">xAiApi / KnowledgeController</span>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:10px;">کنترلر <code>KnowledgeController</code> مدیریت دانش پایدار را فراهم میکند. امکانات:</p>
|
||
<ul>
|
||
<li>Ingest با Scope مشخص (User / Project / Conversation / Global)</li>
|
||
<li>List Documents با فیلتر بر اساس Scope</li>
|
||
<li>Delete Document بههمراه حذف فایل فیزیکی</li>
|
||
<li>Retrieval سلسلهمراتبی: Conversation → Project → User → Global</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="module-card new-module">
|
||
<div class="module-header">
|
||
<div class="module-icon new">۴</div>
|
||
<h4>AI Model Proxy — پروکسی هوشمند برای LLM</h4>
|
||
<span class="module-tag">xAiApi / XAiModelProxyMiddleware</span>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:10px;">میدلور <code>XAiModelProxyMiddleware</code> یک درگاه امن برای دسترسی به مدلهای زبانی است. ویژگیها:</p>
|
||
<ul>
|
||
<li>مسیریابی بر اساس پیشوند <code>RoutePrefix</code> (پیشفرض: <code>ai-model</code>)</li>
|
||
<li>احراز هویت با API Key یا Bearer Token</li>
|
||
<li>Proxy کردن درخواست به Upstream LLM با حفظ Streaming</li>
|
||
<li>حذف هدرهای حساس قبل از ارسال</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="module-card new-module">
|
||
<div class="module-header">
|
||
<div class="module-icon new">۵</div>
|
||
<h4>File Content Extraction Pipeline</h4>
|
||
<span class="module-tag">xAiApi / Providers/Extractors</span>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:10px;">یک خط لوله کامل برای استخراج محتوا از <strong>۱۳ فرمت مختلف</strong> با الگوی Composite:</p>
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>Extractor</th>
|
||
<th>فرمتهای پشتیبانیشده</th>
|
||
<th>کتابخانه</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>XPdfFileContentExtractor</td><td>PDF (با Fallback به تصویر)</td><td>PdfPig + PDFtoImage</td></tr>
|
||
<tr><td>XDocxFileContentExtractor</td><td>DOCX</td><td>DocumentFormat.OpenXml</td></tr>
|
||
<tr><td>XExcelFileContentExtractor</td><td>XLSX / XLS</td><td>ExcelDataReader</td></tr>
|
||
<tr><td>XPowerPointFileContentExtractor</td><td>PPTX / PPT / PPSX ...</td><td>OpenXml + OfficeIMO</td></tr>
|
||
<tr><td>XOpenDocumentFileContentExtractor</td><td>ODT / ODS / ODP</td><td>OfficeIMO.OpenDocument</td></tr>
|
||
<tr><td>XEpubFileContentExtractor</td><td>EPUB</td><td>VersOne.Epub + HtmlAgilityPack</td></tr>
|
||
<tr><td>XHtmlFileContentExtractor</td><td>HTML / XHTML</td><td>HtmlAgilityPack</td></tr>
|
||
<tr><td>XCodeFileContentExtractor</td><td>Source Code (C#, Python, JS, ...)</td><td>StreamReader UTF-8</td></tr>
|
||
<tr><td>XImageFileContentExtractor</td><td>PNG / JPG / GIF / WEBP</td><td>Tesseract OCR (Fallback)</td></tr>
|
||
<tr><td>XAudioFileContentExtractor</td><td>MP3 / WAV / M4A / OGG</td><td>FFMpegCore + Whisper.net</td></tr>
|
||
<tr><td>XVisionFileContentExtractor</td><td>Image / PDF (Vision Model)</td><td>Microsoft.Extensions.AI</td></tr>
|
||
<tr><td>XPlainTextFileContentExtractor</td><td>TXT / MD / CSV / JSON / XML</td><td>StreamReader</td></tr>
|
||
<tr><td>XRtfFileContentExtractor</td><td>RTF</td><td>RtfPipe</td></tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 4: نقاط قوت -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number ok">۴</div>
|
||
<div class="section-title">
|
||
<h3>نقاط قوت تغییرات</h3>
|
||
<div class="subtitle">Strengths & Positive Observations</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<ul class="checklist">
|
||
<li><strong>انطباق با الگوهای موجود:</strong> سرویسهای جدید از همان الگوهای Repository / Provider / Enricher موجود در پروژه پیروی میکنند. <code>XAiVectorEFRepository</code> دقیقاً مشابه <code>XAiProjectEFRepository</code> طراحی شده است.</li>
|
||
<li><strong>جداسازی دغدغهها (SoC):</strong> تفکیک صحیح بین <code>IXAiRAGService</code> (پایدار)، <code>IXInMemoryVectorStore</code> (موقت)، <code>IXAiEmbeddingService</code> و <code>IXFileContentExtractor</code>.</li>
|
||
<li><strong>استفاده از Interface برای توسعهپذیری:</strong> تمام قابلیتها از طریق Interface (مثل <code>IXFileContentExtractor</code>) ارائه شدهاند و امکان تعویض پیادهسازی وجود دارد.</li>
|
||
<li><strong>طراحی چندلایه (Layered Architecture):</strong> استخراج (Extractors) ← Chunking ← Embedding ← Storage ← Retrieval ← Generation. هر لایه مسئولیت مشخصی دارد.</li>
|
||
<li><strong>الگوی Composite در Extractor:</strong> <code>XFileContentExtractor</code> با دریافت <code>IEnumerable<IXFileContentExtractorBase></code> و انتخاب بر اساس MIME Type، یک Composite صحیح است.</li>
|
||
<li><strong>پشتیبانی از Multiple Provider:</strong> انتزاع <code>IChatClient</code> از <code>Microsoft.Extensions.AI</code> و پشتیبانی از OpenAI / Ollama / DeepSeek / HuggingFace.</li>
|
||
<li><strong>مدیریت چرخه عمر Session:</strong> <code>XInMemoryVectorStoreCleanupService</code> بهصورت Background Service با Interval قابل تنظیم، Sessionهای منقضی را پاک میکند.</li>
|
||
<li><strong>استفاده صحیح از CancellationToken:</strong> در تمام متدهای Async، <code>CancellationToken</code> منتقل میشود.</li>
|
||
<li><strong>Scope-based Isolation در RAG:</strong> طراحی صحیح Identifier Layout برای جلوگیری از تداخل: <code>conversation/{id}/{fileName}#{i}</code></li>
|
||
<li><strong>پشتیبانی از Streaming (SSE):</strong> پاسخهای طولانی از طریق <code>AskStream</code> بهصورت تکهتکه ارسال میشوند و UX بهتری ارائه میدهند.</li>
|
||
<li><strong>Text Chunker سلسلهمراتبی:</strong> <code>XTextChunker</code> از استراتژی Paragraph → Sentence → Word → Hard Cut استفاده میکند و Overlap دارد.</li>
|
||
<li><strong>Normalize کردن Vector:</strong> <code>VectorHelper.Normalize</code> پس از تولید Embedding، شباهت کسینوسی را پایدار میکند.</li>
|
||
<li><strong>دفاع لایهای در Model Proxy:</strong> حذف هدرهای حساس و اعتبارسنجی API Key پیش از ارسال به Upstream.</li>
|
||
</ul>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 5: نکات قابل بهبود -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number warn">۵</div>
|
||
<div class="section-title">
|
||
<h3>نکات قابل بهبود</h3>
|
||
<div class="subtitle">Areas for Improvement</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<h4>۵.۱ — کارایی و مقیاسپذیری</h4>
|
||
|
||
<div class="module-card mod-module">
|
||
<div class="module-header">
|
||
<div class="module-icon mod">!</div>
|
||
<h4>In-Memory Vector Store — Linear Search</h4>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:8px;">در <code>XInMemoryVectorStore.Search</code>، شباهت کسینوسی برای <strong>تمام Vectorهای Session</strong> محاسبه میشود. برای Sessionهای بزرگ (هزاران Chunk) این رویکرد O(n) است و میتواند Performance را تحت تأثیر قرار دهد.</p>
|
||
<p style="text-indent:0;"><strong>پیشنهاد:</strong> استفاده از کتابخانهای مانند <code>HNSWlib</code> یا <code>Facebook Faiss</code> برای Approximate Nearest Neighbor، یا حداقل محدودسازی حجم Session.</p>
|
||
</div>
|
||
|
||
<div class="module-card mod-module">
|
||
<div class="module-header">
|
||
<div class="module-icon mod">!</div>
|
||
<h4>XAiDataProvider.SearchVectorsAsync — Load تمام Candidateها</h4>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:8px;">در <code>XAiDataProvider.SearchVectorsAsync</code>، تمام Vectorهای دارای Prefix به Memory بارگذاری میشوند و سپس شباهت محاسبه میشود. این رویکرد در Datasetهای بزرگ بسیار پرهزینه است.</p>
|
||
<p style="text-indent:0;"><strong>پیشنهاد:</strong> در صورت استفاده از SQL Server، از قابلیت <code>VECTOR_SEARCH</code> یا کتابخانههایی مانند <code>pgvector</code> (در PostgreSQL) استفاده شود. یا حداقل با Pagination و فیلتر Type، تعداد Candidateها کاهش یابد.</p>
|
||
</div>
|
||
|
||
<h4>۵.۲ — امنیت</h4>
|
||
|
||
<div class="module-card mod-module">
|
||
<div class="module-header">
|
||
<div class="module-icon mod">!</div>
|
||
<h4>XAiModelProxyMiddleware — اعتبارسنجی SSL غیرفعال</h4>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:8px;">در <code>XAiModelProxyMiddleware</code>، در صورت تنظیم نبودن، تمام گواهیهای SSL پذیرفته میشوند (در HttpClient که برای ارسال به Upstream استفاده میشود اگر CertificateValidationCallback تنظیم شده باشد). این یک ریسک امنیتی است.</p>
|
||
<p style="text-indent:0;"><strong>پیشنهاد:</strong> در محیط Production، گواهیهای Upstream LLM باید بهصورت پیشفرض معتبر باشند و امکان غیرفعالسازی فقط از طریق Configuration با پرچم صریح (<code>AllowUntrustedCertificates=true</code>) فراهم شود.</p>
|
||
</div>
|
||
|
||
<div class="module-card mod-module">
|
||
<div class="module-header">
|
||
<div class="module-icon mod">!</div>
|
||
<h4>ChatWithDocumentsController — اعتبارسنجی MIME Type</h4>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:8px;">کنترلر از <code>file.ContentType</code> بهعنوان MIME Type استفاده میکند. این مقدار از Client میآید و قابل جعل است.</p>
|
||
<p style="text-indent:0;"><strong>پیشنهاد:</strong> در Production، MIME Type واقعی فایل باید با استفاده از کتابخانههایی مانند <code>MimeMagic</code> یا بررسی Header فایل (Magic Bytes) تأیید شود.</p>
|
||
</div>
|
||
|
||
<h4>۵.۳ — پیکربندی و نگهداری</h4>
|
||
|
||
<div class="module-card mod-module">
|
||
<div class="module-header">
|
||
<div class="module-icon mod">!</div>
|
||
<h4>XTextChunker — وابستگی به XAiApiConfiguration</h4>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:8px;"><code>XTextChunker</code> بهعنوان Singleton ثبت شده و <code>XAiApiConfiguration</code> را از طریق Constructor دریافت میکند. اگرچه Configuration تغییر نمیکند، اما در صورت نیاز به تغییر تنظیمات در زمان اجرا (مثلاً از طریق API)، این طراحی محدودیت ایجاد میکند.</p>
|
||
<p style="text-indent:0;"><strong>پیشنهاد:</strong> در صورت نیاز به تغییر دینامیک، از <code>IOptionsMonitor<XTextChunkerDescriptor></code> استفاده شود.</p>
|
||
</div>
|
||
|
||
<div class="module-card mod-module">
|
||
<div class="module-header">
|
||
<div class="module-icon mod">!</div>
|
||
<h4>XAiDataProvider — Soft Delete نکردن Vectorها</h4>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:8px;">در <code>RemoveVectorsAsync</code>، از <code>softDelete: false</code> استفاده شده است. این تصمیم برای Vectorها منطقی است (داده موقت هستند)، اما برای Audit و Debug ممکن است مفید باشد که حداقل لاگ شوند.</p>
|
||
<p style="text-indent:0;"><strong>پیشنهاد:</strong> لاگ کردن تعداد Vectorهای حذفشده بههمراه Scope، یا استفاده از <code>softDelete: true</code> و پاکسازی دورهای.</p>
|
||
</div>
|
||
|
||
<h4>۵.۴ — پوشش تست</h4>
|
||
|
||
<div class="module-card mod-module">
|
||
<div class="module-header">
|
||
<div class="module-icon mod">!</div>
|
||
<h4>نبود Unit Test برای سرویسهای کلیدی</h4>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:8px;">برای سرویسهای جدید (RAG، Embedding، TextChunker، VectorHelper)، Unit Test اختصاصی مشاهده نشد. با توجه به پیچیدگی منطق Chunking (با Overlap) و Cosine Similarity، تستهای واحد میتوانند از بروز Regression جلوگیری کنند.</p>
|
||
<p style="text-indent:0;"><strong>پیشنهاد:</strong> افزودن تستهای xUnit برای:
|
||
<br>• <code>XTextChunker</code> (با Inputهای مختلف، شامل متن کوتاه، بلند، بدون Whitespace)
|
||
<br>• <code>VectorHelper.CosineSimilarity</code> (با Vectorهای نرمال و غیرنرمال)
|
||
<br>• <code>XInMemoryVectorStore</code> (با TTL، Concurrent Access، Owner Isolation)
|
||
</p>
|
||
</div>
|
||
|
||
<h4>۵.۵ — مستندسازی</h4>
|
||
|
||
<div class="module-card mod-module">
|
||
<div class="module-header">
|
||
<div class="module-icon mod">!</div>
|
||
<h4>XML Documentation</h4>
|
||
</div>
|
||
<p style="text-indent:0;margin-bottom:8px;">بسیاری از کلاسها و متدها XML Doc دارند، اما در برخی فایلها (مثل <code>XAiDataProvider</code> و <code>XAIServiceBase</code>) توضیحات کامل نیست.</p>
|
||
<p style="text-indent:0;"><strong>پیشنهاد:</strong> تکمیل XML Doc برای تمام متدهای Public، بهویژه پارامترها و مقادیر بازگشتی.</p>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 6: بررسی عمیق معماری -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۶</div>
|
||
<div class="section-title">
|
||
<h3>بررسی عمیق معماری</h3>
|
||
<div class="subtitle">Deep Architecture Analysis</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<h4>۶.۱ — جریان داده در RAG پایدار (Persistent)</h4>
|
||
<p>جریان کامل از Ingest تا Generate بهصورت زیر است:</p>
|
||
|
||
<div class="info-box">
|
||
<strong>Ingest Flow:</strong><br>
|
||
<code>KnowledgeController.Ingest</code> →
|
||
<code>XAiRAGService.IngestAsync</code> →
|
||
<code>IXFileContentExtractor.ExtractRichAsync</code> →
|
||
<code>IXTextChunker.Chunk</code> →
|
||
<code>IXAiEmbeddingService.Embeddings</code> →
|
||
<code>IXAiDataProvider.UpsertVectorsAsync</code>
|
||
<br><br>
|
||
<strong>Query Flow:</strong><br>
|
||
<code>KnowledgeController.Documents</code> →
|
||
<code>XAiRAGService.RetrieveAsync</code> →
|
||
<code>IXAiEmbeddingService.Embedding</code> →
|
||
<code>IXAiDataProvider.SearchVectorsAsync</code> →
|
||
(Optional) <code>IXAiService.AskTextByContextAsync</code>
|
||
</div>
|
||
|
||
<h4>۶.۲ — جداسازی دغدغهها</h4>
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>دغدغه</th>
|
||
<th>مسئول</th>
|
||
<th>لایه</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>استخراج متن از فایل</td><td>IXFileContentExtractor</td><td>Infrastructure</td></tr>
|
||
<tr><td>تقسیم متن به Chunk</td><td>IXTextChunker</td><td>Domain Service</td></tr>
|
||
<tr><td>تولید Embedding</td><td>IXAiEmbeddingService</td><td>Domain Service</td></tr>
|
||
<tr><td>ذخیره/بازیابی Vector</td><td>IXAiDataProvider</td><td>Data</td></tr>
|
||
<tr><td>ایزولاسیون Scope</td><td>XAiRAGService</td><td>Application</td></tr>
|
||
<tr><td>تعامل با LLM</td><td>IXAiService</td><td>Application</td></tr>
|
||
<tr><td>مدیریت Session</td><td>IXInMemoryVectorStore</td><td>Infrastructure</td></tr>
|
||
<tr><td>ارائه HTTP</td><td>Controllers</td><td>Presentation</td></tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<h4>۶.۳ — الگوهای طراحی استفادهشده</h4>
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>الگو</th>
|
||
<th>محل استفاده</th>
|
||
<th>ارزیابی</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr><td>Composite</td><td>XFileContentExtractor</td><td style="color: var(--success);">✓ صحیح</td></tr>
|
||
<tr><td>Strategy</td><td>IChatClient (Multiple Providers)</td><td style="color: var(--success);">✓ صحیح</td></tr>
|
||
<tr><td>Repository</td><td>IXAiVectorRepository</td><td style="color: var(--success);">✓ صحیح</td></tr>
|
||
<tr><td>Unit of Work</td><td>IXUnitOfWorks</td><td style="color: var(--success);">✓ صحیح</td></tr>
|
||
<tr><td>Background Service</td><td>XInMemoryVectorStoreCleanupService</td><td style="color: var(--success);">✓ صحیح</td></tr>
|
||
<tr><td>Middleware</td><td>XAiModelProxyMiddleware</td><td style="color: var(--success);">✓ صحیح</td></tr>
|
||
<tr><td>Factory</td><td>XModelsExtensions.GetClient</td><td style="color: var(--success);">✓ صحیح</td></tr>
|
||
<tr><td>Proxy</td><td>XAiModelProxyMiddleware</td><td style="color: var(--success);">✓ صحیح</td></tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 7: بررسی امنیت -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۷</div>
|
||
<div class="section-title">
|
||
<h3>بررسی امنیت</h3>
|
||
<div class="subtitle">Security Review</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>مورد امنیتی</th>
|
||
<th>وضعیت</th>
|
||
<th>توضیح</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>Authorize در Controllerها</td>
|
||
<td><span class="badge ok">✓ صحیح</span></td>
|
||
<td>تمام Controllerهای جدید دارای <code>[Authorize]</code> هستند</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Scope-based Authorization</td>
|
||
<td><span class="badge ok">✓ صحیح</span></td>
|
||
<td>KnowledgeController از <code>XPolicies.EnabledAdmin</code> استفاده میکند</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Owner Isolation در RAG</td>
|
||
<td><span class="badge ok">✓ صحیح</span></td>
|
||
<td>هر User فقط به Vectorهای خودش دسترسی دارد (بر اساس OwnerId)</td>
|
||
</tr>
|
||
<tr>
|
||
<td>API Key در Proxy</td>
|
||
<td><span class="badge ok">✓ صحیح</span></td>
|
||
<td>پشتیبانی از <code>X-Api-Key</code> و Bearer Token با اعتبارسنجی</td>
|
||
</tr>
|
||
<tr>
|
||
<td>حذف هدرهای حساس در Proxy</td>
|
||
<td><span class="badge ok">✓ صحیح</span></td>
|
||
<td><code>Authorization</code>، <code>X-Api-Key</code> و ... قبل از Forward حذف میشوند</td>
|
||
</tr>
|
||
<tr>
|
||
<td>SSL Validation در Proxy</td>
|
||
<td><span class="badge mod">⚠ نیاز به بررسی</span></td>
|
||
<td>در HttpClient پیشفرض، در صورت تنظیم نبودن، تمام گواهیها پذیرفته میشوند</td>
|
||
</tr>
|
||
<tr>
|
||
<td>MIME Type Validation</td>
|
||
<td><span class="badge mod">⚠ نیاز به بررسی</span></td>
|
||
<td>MIME Type از Client گرفته میشود (قابل جعل)</td>
|
||
</tr>
|
||
<tr>
|
||
<td>Rate Limiting در Proxy</td>
|
||
<td><span class="badge mod">⚠ نیاز به بررسی</span></td>
|
||
<td>مکانیزم Rate Limiting اختصاصی برای Proxy مشاهده نشد</td>
|
||
</tr>
|
||
<tr>
|
||
<td>File Size Limit</td>
|
||
<td><span class="badge ok">✓ صحیح</span></td>
|
||
<td><code>XAiDocumentRAGDescriptor.MaxFileSizeBytes</code> پیشبینی شده است</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="warning-box">
|
||
<strong>⚠️ توصیه امنیتی:</strong> در محیط Production، حتماً <code>ServerCertificateCustomValidationCallback</code> را در Proxy بهصورت صریح تنظیم کنید و گواهیهای Upstream را از یک Certificate Store معتبر بارگذاری کنید. همچنین MIME Type را با بررسی Magic Bytes فایل تأیید کنید.
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 8: انطباق با نیازمندیها -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number ok">۸</div>
|
||
<div class="section-title">
|
||
<h3>انطباق با معماری هدف</h3>
|
||
<div class="subtitle">Alignment with Target Architecture</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<p>تغییرات اعمالشده، با معماری کلان سامانه هوش مصنوعی سازمانی (ARCH-1405-001) که در مستندات پروژه تعریف شده است، کاملاً همراستا هستند:</p>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>لایه معماری هدف</th>
|
||
<th>پیادهسازی در کد</th>
|
||
<th>وضعیت</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>L1: تعامل (Interaction)</td>
|
||
<td>کنترلرهای ChatWithDocuments، Knowledge، XAi</td>
|
||
<td><span class="badge ok">✓ پوشش</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td>L2: کنترل دسترسی</td>
|
||
<td><code>[Authorize]</code> + <code>XPolicies</code> + Owner Isolation</td>
|
||
<td><span class="badge ok">✓ پوشش</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td>L3: ارکستراسیون</td>
|
||
<td><code>XAIServiceBase.PrepareChatRequirementsAsync</code>، Memory Management</td>
|
||
<td><span class="badge ok">✓ پوشش نسبی</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td>L4: هوش و مدلها</td>
|
||
<td><code>IXAiService</code>، <code>IXAiEmbeddingService</code>، RAG، Model Proxy</td>
|
||
<td><span class="badge ok">✓ پوشش کامل</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td>L5: داده و منابع</td>
|
||
<td><code>IXAiDataProvider</code>، <code>XAiVector</code>، File Extractors</td>
|
||
<td><span class="badge ok">✓ پوشش کامل</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td>L6: خروجی و گزارش</td>
|
||
<td>Streaming SSE با ارجاع به منابع</td>
|
||
<td><span class="badge ok">✓ پوشش نسبی</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td>X: حاکمیت داده</td>
|
||
<td>Owner Isolation، Scope-based RAG، ApiKey Validation</td>
|
||
<td><span class="badge ok">✓ پوشش</span></td>
|
||
</tr>
|
||
<tr>
|
||
<td>Y: مشاهدهپذیری</td>
|
||
<td>ILogger در سرویسها، Audit Log در ApiKey</td>
|
||
<td><span class="badge mod">⚠ نیاز به تکمیل</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="success-box">
|
||
<strong>✓ نتیجه:</strong> اکثر لایههای معماری هدف پوشش داده شدهاند. تنها لایههای <strong>ارکستراسیون چند-ایجنت</strong> (که نیاز به MCP دارد) و <strong>مشاهدهپذیری پیشرفته</strong> (توزیعشده) هنوز نیاز به تکمیل دارند.
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 9: اولویتبندی اقدامات -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number">۹</div>
|
||
<div class="section-title">
|
||
<h3>اولویتبندی اقدامات پیشنهادی</h3>
|
||
<div class="subtitle">Prioritized Action Items</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>
|
||
<td>۱</td>
|
||
<td>افزودن Rate Limiting برای Model Proxy</td>
|
||
<td style="color: var(--danger); font-weight: 700;">بالا</td>
|
||
<td>جلوگیری از سوءاستفاده و کنترل هزینه</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۲</td>
|
||
<td>اعتبارسنجی MIME Type با Magic Bytes</td>
|
||
<td style="color: var(--danger); font-weight: 700;">بالا</td>
|
||
<td>جلوگیری از آپلود فایلهای مخرب</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۳</td>
|
||
<td>Unit Test برای Text Chunker و Vector Helper</td>
|
||
<td style="color: var(--warning); font-weight: 700;">متوسط</td>
|
||
<td>جلوگیری از Regression</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۴</td>
|
||
<td>بهینهسازی Search در Vector Store</td>
|
||
<td style="color: var(--warning); font-weight: 700;">متوسط</td>
|
||
<td>افزایش مقیاسپذیری</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۵</td>
|
||
<td>افزودن Logging ساختاریافته (Serilog)</td>
|
||
<td style="color: var(--warning); font-weight: 700;">متوسط</td>
|
||
<td>مشاهدهپذیری بهتر</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۶</td>
|
||
<td>SSL Validation صریح در HttpClient</td>
|
||
<td style="color: var(--warning); font-weight: 700;">متوسط</td>
|
||
<td>امنیت در محیط Production</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۷</td>
|
||
<td>پشتیبانی از چند-ایجنت (Multi-Agent)</td>
|
||
<td style="color: var(--info); font-weight: 700;">پایین</td>
|
||
<td>پوشش کامل لایه ارکستراسیون</td>
|
||
</tr>
|
||
<tr>
|
||
<td>۸</td>
|
||
<td>تکمیل XML Documentation</td>
|
||
<td style="color: var(--info); font-weight: 700;">پایین</td>
|
||
<td>نگهداری بهتر</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<!-- SECTION 10: جمعبندی -->
|
||
<div class="section">
|
||
<div class="section-header">
|
||
<div class="section-number ok">۱۰</div>
|
||
<div class="section-title">
|
||
<h3>جمعبندی و ارزیابی کلی</h3>
|
||
<div class="subtitle">Summary & Overall Assessment</div>
|
||
</div>
|
||
</div>
|
||
<div class="section-content">
|
||
|
||
<p>تغییرات اعمالشده، یک <strong>ارتقاء معماری چشمگیر و حرفهای</strong> در اکوسیستم هوش مصنوعی پروژه محسوب میشود. کیفیت کد، انطباق با الگوهای موجود، و پوشش قابلیتها در سطح بالایی قرار دارد.</p>
|
||
|
||
<table class="styled-table">
|
||
<thead>
|
||
<tr>
|
||
<th>معیار ارزیابی</th>
|
||
<th>امتیاز</th>
|
||
<th>توضیح</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>کیفیت معماری</td>
|
||
<td style="color: var(--success); font-weight: 700;">۹ / ۱۰</td>
|
||
<td>جداسازی دغدغهها، لایهبندی صحیح، استفاده از Interface</td>
|
||
</tr>
|
||
<tr>
|
||
<td>انطباق با الگوهای موجود</td>
|
||
<td style="color: var(--success); font-weight: 700;">۱۰ / ۱۰</td>
|
||
<td>پیروی دقیق از الگوی Repository / Provider / Enricher</td>
|
||
</tr>
|
||
<tr>
|
||
<td>پوشش قابلیتها</td>
|
||
<td style="color: var(--success); font-weight: 700;">۹ / ۱۰</td>
|
||
<td>RAG، Embedding، Vector Store، Extractors، Model Proxy</td>
|
||
</tr>
|
||
<tr>
|
||
<td>خوانایی کد</td>
|
||
<td style="color: var(--success); font-weight: 700;">۸ / ۱۰</td>
|
||
<td>نامگذاری مناسب، XML Doc نسبی، برخی فایلهای طولانی</td>
|
||
</tr>
|
||
<tr>
|
||
<td>امنیت</td>
|
||
<td style="color: var(--warning); font-weight: 700;">۷ / ۱۰</td>
|
||
<td>نقاط قوت در Authorization، نیاز به Rate Limit و MIME Validation</td>
|
||
</tr>
|
||
<tr>
|
||
<td>مقیاسپذیری</td>
|
||
<td style="color: var(--warning); font-weight: 700;">۷ / ۱۰</td>
|
||
<td>In-Memory Search خطی، نیاز به ANN برای Datasetهای بزرگ</td>
|
||
</tr>
|
||
<tr>
|
||
<td>پوشش تست</td>
|
||
<td style="color: var(--danger); font-weight: 700;">۵ / ۱۰</td>
|
||
<td>Unit Test اختصاصی برای سرویسهای جدید مشاهده نشد</td>
|
||
</tr>
|
||
<tr class="highlight-row">
|
||
<td><strong>امتیاز کلی</strong></td>
|
||
<td style="color: var(--success); font-weight: 700; font-size: 16px;">۸ / ۱۰</td>
|
||
<td>کیفیت بالا با چند نکته بهبود قابل توجه</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div class="conclusion-box">
|
||
<h3>🎯 نتیجه نهایی</h3>
|
||
<p>تغییرات اعمالشده، یک <strong>ارتقاء معماری بنیادین</strong> در اکوسیستم هوش مصنوعی پروژه است که با کیفیت بالا و انطباق کامل با الگوهای موجود پیادهسازی شده است.</p>
|
||
<p>قابلیتهای جدید (RAG پایدار، RAG درونحافظهای، Model Proxy، ۱۳ Extractor مختلف) پروژه را از یک سرویس ساده پرسشوپاسخ به یک <strong>سامانه چندلایه سازمانی</strong> تبدیل کرده است.</p>
|
||
<div class="highlight">
|
||
<strong>💎 ارزش کلیدی:</strong><br>
|
||
معماری تمیز + قابلیتهای پیشرفته + انطباق کامل با الگوها + توسعهپذیری بالا
|
||
</div>
|
||
</div>
|
||
|
||
<div class="info-box">
|
||
<strong>📞 گام بعدی پیشنهادی:</strong> با توجه به اولویتبندی اقدامات (بخش ۹)، پیشنهاد میشود ابتدا <strong>Rate Limiting در Model Proxy</strong> و <strong>اعتبارسنجی MIME Type</strong> پیادهسازی شوند، سپس Unit Test برای سرویسهای حیاتی افزوده شود. اقدامات دیگر میتوانند در Iterationهای بعدی با توجه به اولویت کسبوکار انجام شوند.
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="page-info">
|
||
این مستند داخلی بوده و صرفاً جهت استفاده تیم فنی xSaherelmWorkspace تهیه شده است.
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<footer class="document-footer">
|
||
<div class="footer-brand">xSaherelmWorkspace — Code Review Report</div>
|
||
<div class="footer-divider"></div>
|
||
<div>تهیهشده توسط تیم فنی | نسخه ۱.۰ | آبان ۱۴۰۵ | طبقهبندی: داخلی — فنی</div>
|
||
</footer>
|
||
|
||
</div>
|
||
|
||
</body>
|
||
</html> |