- 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:
@@ -0,0 +1,34 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace xAiApi.Interfaces
|
||||
{
|
||||
public interface IXAiEmbeddingServiceControllerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Request For Embedding Specified String ...
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Embedding")]
|
||||
Task<ActionResult<float[]>> Embedding(
|
||||
[FromQuery] string content,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Request For Embedding Specified Batch ...
|
||||
/// </summary>
|
||||
/// <param name="batch"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Embeddings")]
|
||||
Task<ActionResult<IReadOnlyList<float[]>>> Embeddings(
|
||||
[FromQuery] string[] batch,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
||||
using xAiModels.Models;
|
||||
using xAiModels.Constants;
|
||||
|
||||
namespace xAiModels.Configurations
|
||||
{
|
||||
public class XAiApiConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// Model Providers ...
|
||||
/// </summary>
|
||||
public XAiModelDescriptor[] Models { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Each User must Has a Default Project, this is Title Resource Identifier ...
|
||||
/// </summary>
|
||||
public string DefaultProjectTitleResource { get; set; } = XAiModelsConstants.DefaultXAiProjectTitleResourceID;
|
||||
|
||||
/// <summary>
|
||||
/// Each User must Has a Default Project, this is Description Resource Identifier ...
|
||||
/// </summary>
|
||||
public string DefaultProjectDescriptionResource { get; set; } = XAiModelsConstants.DefaultXAiProjectDescriptionResourceID;
|
||||
|
||||
/// <summary>
|
||||
/// Each User must Has a Default Conversation, this is Title Resource Identifier ... ...
|
||||
/// </summary>
|
||||
public string DefaultConversationTitleResource { get; set; } = XAiModelsConstants.DefaultXAiConversationTitleResourceID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Linq;
|
||||
using xAiModels.Models;
|
||||
using xCommons.Extensions;
|
||||
using xAiModels.Configurations;
|
||||
|
||||
namespace xAiModels.Extensions
|
||||
{
|
||||
public static class XAiApiConfigurationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Validate Api Configuration ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XAiApiConfiguration source)
|
||||
{
|
||||
return
|
||||
!source.IsNullOrDefault() &&
|
||||
source.Models.HasChild();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Default Model Descriptor ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static XAiModelDescriptor GetDefaultModel(this XAiApiConfiguration source)
|
||||
{
|
||||
//
|
||||
XAiModelDescriptor result = null;
|
||||
|
||||
//
|
||||
if (source.IsValid())
|
||||
{
|
||||
result = source.Models.First();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,836 @@
|
||||
<!doctype html>
|
||||
<html lang="fa" dir="rtl">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>ChangeLog ۱۴۰۵/۰۸/۱۱ v01 - xSaherelmWorkspace</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 24px;
|
||||
background: #f4f7fb;
|
||||
color: #172033;
|
||||
font-family: Tahoma, 'Segoe UI', sans-serif;
|
||||
line-height: 1.9;
|
||||
}
|
||||
.wrap {
|
||||
max-width: 1180px;
|
||||
margin: auto;
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 12px 40px #20386422;
|
||||
overflow: hidden;
|
||||
}
|
||||
.hero {
|
||||
padding: 38px;
|
||||
background: linear-gradient(135deg, #173b78, #2563eb);
|
||||
color: #fff;
|
||||
}
|
||||
.hero h1 {
|
||||
margin: 0 0 8px;
|
||||
font-size: 1.9em;
|
||||
}
|
||||
.hero p {
|
||||
margin: 4px 0;
|
||||
}
|
||||
.meta {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
flex-wrap: wrap;
|
||||
padding: 16px 30px;
|
||||
background: #f8fafc;
|
||||
color: #53627a;
|
||||
border-bottom: 1px solid #dbe3ef;
|
||||
}
|
||||
.meta strong {
|
||||
color: #173b78;
|
||||
}
|
||||
main {
|
||||
padding: 30px;
|
||||
}
|
||||
.section {
|
||||
margin-bottom: 26px;
|
||||
padding: 22px;
|
||||
background: #f4f7fb;
|
||||
border-right: 5px solid #2563eb;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.section h2 {
|
||||
color: #173b78;
|
||||
border-bottom: 1px solid #dbe3ef;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
.section h3 {
|
||||
color: #1e40af;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
background: #fff;
|
||||
margin: 12px 0;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 10px 12px;
|
||||
border-bottom: 1px solid #dbe3ef;
|
||||
}
|
||||
th {
|
||||
background: #173b78;
|
||||
color: #fff;
|
||||
}
|
||||
code {
|
||||
direction: ltr;
|
||||
display: inline-block;
|
||||
background: #e7edf6;
|
||||
border-radius: 4px;
|
||||
padding: 0 5px;
|
||||
font-family: Consolas, monospace;
|
||||
}
|
||||
pre {
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
overflow: auto;
|
||||
background: #172033;
|
||||
color: #e7eefc;
|
||||
border-radius: 7px;
|
||||
padding: 14px;
|
||||
}
|
||||
.note,
|
||||
.warn,
|
||||
.ok {
|
||||
padding: 13px 16px;
|
||||
border-radius: 7px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.note {
|
||||
background: #eff6ff;
|
||||
border-right: 4px solid #2563eb;
|
||||
}
|
||||
.warn {
|
||||
background: #fff7ed;
|
||||
border-right: 4px solid #b45309;
|
||||
}
|
||||
.ok {
|
||||
background: #ecfdf5;
|
||||
border-right: 4px solid #087f5b;
|
||||
}
|
||||
.badge {
|
||||
display: inline-block;
|
||||
color: #fff;
|
||||
border-radius: 15px;
|
||||
padding: 1px 10px;
|
||||
font-size: 0.8em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.mod {
|
||||
background: #b45309;
|
||||
}
|
||||
.new {
|
||||
background: #087f5b;
|
||||
}
|
||||
.del {
|
||||
background: #b91c1c;
|
||||
}
|
||||
.sub {
|
||||
background: #6d28d9;
|
||||
}
|
||||
footer {
|
||||
text-align: center;
|
||||
color: #68758a;
|
||||
padding: 18px;
|
||||
border-top: 1px solid #dbe3ef;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrap">
|
||||
<header class="hero">
|
||||
<h1>گزارش تغییرات ساختار پروژه</h1>
|
||||
<p>
|
||||
xSaherelmWorkspace | تاریخ: ۱۴۰۵/۰۸/۱۱ (2026-11-02) | نسخه مستند:
|
||||
<strong>v01</strong>
|
||||
</p>
|
||||
<p>
|
||||
موضوع: بازآرایی لایهٔ گفتگو در <code>xAiApi</code> (استخراج
|
||||
<code>PrepareChatRequirementsAsync</code> و
|
||||
<code>XPreparedChatContext</code>)، مقاومسازی
|
||||
<code>XAiRAGService</code> و <code>XInMemoryVectorStore</code>،
|
||||
Nullable شدن <code>projectId</code> در لایهٔ داده و انتقال
|
||||
<code>XAiApiConfiguration</code> از <code>xAiModels</code>
|
||||
</p>
|
||||
</header>
|
||||
<div class="meta">
|
||||
<span
|
||||
><strong>دامنه:</strong> <code>xAiApi</code>,
|
||||
<code>Modules/xAiModels</code>, ریشهٔ Workspace</span
|
||||
>
|
||||
<span
|
||||
><strong>نسخه:</strong> v01 (تاریخ جدید)</span
|
||||
>
|
||||
<span
|
||||
><strong>سند قبلی:</strong>
|
||||
<a href="1405-08-08-v01.html">ChangeLog ۱۴۰۵/۰۸/۰۸</a></span
|
||||
>
|
||||
</div>
|
||||
<main>
|
||||
|
||||
<section class="section">
|
||||
<h2>۱. خلاصهٔ اجرایی</h2>
|
||||
<p>
|
||||
در این نسخه تمرکز اصلی روی بازآرایی لایهٔ گفتگو (
|
||||
<code>XAIServiceBase</code>) و افزایش پایداری سرویس RAG است.
|
||||
منطق تکراری «Normalize پارامترها + Retrieve + ساخت Memory + ذخیرهٔ
|
||||
پیام + فراخوانی LLM» که در چند متد تکرار شده بود، به یک متد واحد
|
||||
<code>PrepareChatRequirementsAsync</code> منتقل شد که خروجی آن در قالب
|
||||
مدل جدید <code>XPreparedChatContext</code> بازگردانده میشود. در
|
||||
<code>xAiModels</code> نیز پارامتر <code>projectId</code> در متدهای
|
||||
Conversation به <code>Guid?</code> تغییر کرد و دو فایل پیکربندی
|
||||
<code>XAiApiConfiguration</code> از این ماژول حذف شدند.
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ماژول</th>
|
||||
<th>فایل تغییریافته</th>
|
||||
<th>افزوده</th>
|
||||
<th>حذفشده</th>
|
||||
<th>شرح</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>Modules/xAiModels</code></td>
|
||||
<td>۶</td>
|
||||
<td>۰</td>
|
||||
<td>۲</td>
|
||||
<td>
|
||||
Nullable شدن <code>projectId</code>، افزودن
|
||||
<code>ToEmbedding</code>، حذف پیکربندیهای API
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>xAiApi</code></td>
|
||||
<td>۹</td>
|
||||
<td>۱</td>
|
||||
<td>۱</td>
|
||||
<td>
|
||||
بازآرایی <code>XAIServiceBase</code>، مقاومسازی RAG و
|
||||
Vector Store، رفع باگ فایلهای پیوست
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ریشهٔ Workspace</td>
|
||||
<td>۳</td>
|
||||
<td>۱۳</td>
|
||||
<td>۳</td>
|
||||
<td>
|
||||
بهروزرسانی Contextهای تولیدشده، افزودن
|
||||
<code>Documents/Codes</code>، مستندات توسعه و
|
||||
<code>X121KIEA</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۲. تغییرات ماژول <code>Modules/xAiModels</code></h2>
|
||||
|
||||
<h3>۲-۱. حذف پیکربندیهای API از ماژول مدل</h3>
|
||||
<p>
|
||||
دو فایل پیکربندی از <code>xAiModels</code> حذف شدند. این کلاسها
|
||||
مربوط به پیکربندی سرویس <code>xAiApi</code> بودند و در ماژول
|
||||
مدل جای نادرستی داشتند؛ نسخهٔ پشتیبان آنها در
|
||||
<code>Documents/Codes/</code> (ریشهٔ Workspace) نگهداری میشود.
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>نوع</th>
|
||||
<th>فایل</th>
|
||||
<th>توضیح</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span class="badge del">حذف</span></td>
|
||||
<td><code>Configurations/XAiApiConfiguration.cs</code></td>
|
||||
<td>
|
||||
کلاس پیکربندی (Models، DefaultProject/Conversation Resource
|
||||
Identifiers) از ماژول مدل حذف شد
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge del">حذف</span></td>
|
||||
<td><code>Extensions/XAiApiConfigurationExtensions.cs</code></td>
|
||||
<td>
|
||||
<code>IsValid</code> و <code>GetDefaultModel</code> مربوط به
|
||||
پیکربندی API از ماژل حذف شد
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="note">
|
||||
<b>نکته:</b> پیش از حذف، از نبود مصرفکننده در
|
||||
<code>xAiApi</code> اطمینان حاصل شد؛ build پروژه با ۰ خطا انجام شد.
|
||||
</div>
|
||||
|
||||
<h3>۲-۲. Nullable شدن <code>projectId</code> در لایهٔ داده</h3>
|
||||
<p>
|
||||
برای پشتیبانی از حالت «پروژه پیشفرض کاربر»، پارامتر
|
||||
<code>projectId</code> در متدهای مرتبط با Conversation از
|
||||
<code>Guid</code> به <code>Guid?</code> تغییر کرد. این تغییر با
|
||||
Nullable شدن <code>ProjectId</code>/<code>ConversationId</code> در
|
||||
<code>XAiResponseRequest</code> (نسخهٔ ۱۴۰۵/۰۸/۰۸) همراستا است.
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>نوع</th>
|
||||
<th>فایل</th>
|
||||
<th>توضیح</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>Interfaces/IXAiDataProvider.cs</code></td>
|
||||
<td>
|
||||
امضای <code>GetDefaultConversation</code>: پارامتر
|
||||
<code>projectId</code> از <code>Guid</code> به
|
||||
<code>Guid?</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>Providers/XAiDataProvider.cs</code></td>
|
||||
<td>
|
||||
<b>۱)</b> <code>GetDefaultConversation</code>،
|
||||
<code>HasDefaultConversation</code> و
|
||||
<code>CreateDefaultConversation</code> با
|
||||
<code>Guid?</code> تطبیق داده شدند؛ بررسی
|
||||
<code>!projectId.HasValue</code> جایگزین
|
||||
<code>projectId.IsNull()</code> شد.
|
||||
<br />
|
||||
<b>۲)</b> در پیشبارگذاری Project از
|
||||
<code>projectId.Value</code> استفاده میشود.
|
||||
<br />
|
||||
<b>۳)</b> اصلاح مهم در پیشبارگذاری Conversation: شرط
|
||||
<code>x.ProjectId == projectId</code> به
|
||||
<code>x.ProjectId == project.Id</code> تغییر کرد (پیشتر با
|
||||
<code>Guid?</code> قابلاعتماد نبود).
|
||||
<br />
|
||||
<b>۴)</b> ذخیرهٔ بردار: <code>item.Embedding.ToJSON()</code> به
|
||||
<code>item.Embedding.ToEmbedding()</code> تغییر کرد.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>۲-۳. افزودن متد تبدیل Embedding و اصلاح نگارشی</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>نوع</th>
|
||||
<th>فایل</th>
|
||||
<th>توضیح</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>Extensions/XEmbeddingExtensions.cs</code></td>
|
||||
<td>
|
||||
افزودن متد Extension
|
||||
<code>ToEmbedding(this ReadOnlyMemory<float>)</code> که
|
||||
بردار را به نمایش JSON تبدیل میکند؛ استفاده در ذخیرهٔ
|
||||
پایدار بردارها در دیتابیس
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>Extensions/XAiModelsExtensions.cs</code></td>
|
||||
<td>
|
||||
اصلاح نگارشی نام متد
|
||||
<code>GetDafualtProject</code> ←
|
||||
<code>GetDafaultProject</code> (رفع typo)
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="note">
|
||||
<b>سازگاری:</b> تغییر نام
|
||||
<code>GetDafualtProject</code> یک تغییر API-شکن است. تمام
|
||||
مصرفکنندهها در <code>xAiApi</code> بهروزرسانی شدند (شامل
|
||||
<code>XAIServiceBase.LoadConversations</code>).
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۳. تغییرات ماژول <code>xAiApi</code></h2>
|
||||
|
||||
<h3>۳-۱. بازآرایی <code>XAIServiceBase</code> (تغییر اصلی)</h3>
|
||||
<p>
|
||||
این فایل با ۹۴۷ خط تغییر (۵۷۲ افزوده / ۷۳۲ حذف) بزرگترین تغییر
|
||||
این نسخه است. منطق تکراری پیشنیازهای گفتگو در متدهای مختلف
|
||||
(<code>AskTextAsync</code>، <code>AskTextAsEnumerable</code>،
|
||||
<code>AskTextByContextAsync</code>،
|
||||
<code>AskTextFromKnowledgeAsync</code>،
|
||||
<code>AskAsync</code>، <code>AskAsEnumerable</code>) تکرار
|
||||
شده بود و به متد واحدی منتقل شد.
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>نوع</th>
|
||||
<th>عضو</th>
|
||||
<th>توضیح</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span class="badge new">افزوده</span></td>
|
||||
<td><code>PrepareChatRequirementsAsync</code></td>
|
||||
<td>
|
||||
متد مرکزی جدید: Normalize پارامترها، حل Project/Conversation
|
||||
پیشفرض، Ingest فایلهای پیوست، Retrieve کانتکست RAG،
|
||||
ساخت History، ذخیرهٔ پیام Prompt و برگرداندن
|
||||
<code>XPreparedChatContext</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">افزوده</span></td>
|
||||
<td><code>NormalizeRagParams</code></td>
|
||||
<td>
|
||||
استخراج منطق Normalize (
|
||||
<code>topK</code>، <code>minScore</code>،
|
||||
<code>type</code>) از ۶ متد به یک متد؛ اکنون
|
||||
<code>minScore</code> در بازهٔ <code>[0,1]</code> نرمال
|
||||
میشود (مطابق اعتبارسنجی)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">افزوده</span></td>
|
||||
<td><code>GetHistory</code></td>
|
||||
<td>
|
||||
بازطراحی امضا: از
|
||||
<code>GetHistory(ChatMessage, bool)</code> به دو Overload
|
||||
<code>GetHistory(prompt, forcePrompt)</code> و
|
||||
<code>GetHistory(prompt, context)</code> تغییر کرد؛ دومی برای
|
||||
مسیر بدونگفتگو (بدون ذخیرهٔ پیام) استفاده میشود
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge del">حذف</span></td>
|
||||
<td><code>AskLLMAsync</code></td>
|
||||
<td>
|
||||
متد فراخوانی LLM حذف شد؛ منطق آن مستقیماً در متدهای
|
||||
<code>Ask*</code> ادغام شد تا جریان History/پاسخ یکپارچه
|
||||
باشد
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>AskAsync</code></td>
|
||||
<td>
|
||||
بازنویسی کامل؛ اکنون از
|
||||
<code>PrepareChatRequirementsAsync</code> استفاده میکند، پیام
|
||||
Assistant را ذخیره میکند و خروجی
|
||||
<code>XAiMessageDto</code> برمیگرداند
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>AskAsEnumerable</code></td>
|
||||
<td>
|
||||
بازنویسی جریان SSE: استفاده از
|
||||
<code>prep.History</code>، پاسخهای
|
||||
<code>XAiResonseMessage</code> با
|
||||
<code>Role = Assistant</code>،
|
||||
<code>RespondTo = prep.PersistedPromptMessage.Id</code>،
|
||||
توالی <code>Sequence++</code> و ذخیرهٔ پیام کامل در پایان
|
||||
جریان
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>PrepareMemory</code></td>
|
||||
<td>
|
||||
پارامترها بازطراحی شد و اکنون با مسیر
|
||||
<code>resolveConversation</code> هماهنگ است
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td>پرامپت RAG</td>
|
||||
<td>
|
||||
<code>configuration.RAGDescriptor.PromptName</code> به ثابت
|
||||
<code>XAiApiConstants.XAiApiRagPromptName</code> تغییر کرد تا
|
||||
نام پرامپت مستقل از Descriptor باشد
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>LoadConversations</code></td>
|
||||
<td>
|
||||
فراخوانی اصلاحشدهٔ
|
||||
<code>GetDafaultProject</code> (مطابق اصلاح typo در
|
||||
<code>xAiModels</code>)
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>۳-۲. مدل مشترک <code>XPreparedChatContext</code></h3>
|
||||
<p>
|
||||
فایل جدید <code>Models/XPreparedChatContext.cs</code> مدل انتقال
|
||||
پیشنیازهای گفتگو بین متدهای داخلی را تعریف میکند.
|
||||
</p>
|
||||
<pre>
|
||||
public class XPreparedChatContext
|
||||
{
|
||||
public XAiProjectDto Project { get; set; }
|
||||
public XAiConversationDto Conversation { get; set; }
|
||||
public IList<ChatMessage> History { get; set; }
|
||||
public IList<XAiVectorSearchResult> Context { get; set; }
|
||||
public XAiMessageDto PersistedPromptMessage { get; set; }
|
||||
}</pre
|
||||
>
|
||||
<div class="ok">
|
||||
<b>اثر:</b> کاهش محسوس تکرار کد و کاهش ریسک ناسازگاری میان مسیرهای
|
||||
<code>Ask</code>، <code>AskStream</code> و
|
||||
<code>AskWithContext</code>.
|
||||
</div>
|
||||
|
||||
<h3>۳-۳. مقاومسازی <code>XAiRAGService</code></h3>
|
||||
<p>
|
||||
حلقهٔ Ingest هر فایل اکنون در یک <code>try/catch</code> مستقل قرار
|
||||
گرفته است؛ خطای یک فایل، کل عملیات Ingest را متوقف نمیکند.
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>تغییر</th>
|
||||
<th>توضیح</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>مدیریت خطای per-file</td>
|
||||
<td>
|
||||
<code>catch (Exception ex)</code> با
|
||||
<code>logger.LogError</code> اضافه شد؛ در صورت شکست
|
||||
Chunk/Embedding، فایل آپلودشده حذف میشود تا فایل
|
||||
یتیم در Storage باقی نماند
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>آپلود و مرجعدهی فایل</td>
|
||||
<td>
|
||||
<code>fileProvider.Upload</code> و
|
||||
<code>fileProvider.AddReference</code> با
|
||||
<code>providedFor</code>/<code>forProvidedId</code> بر اساس
|
||||
Scope اضافه شد (پیشتر فایل صرفاً آپلود میشد)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>حذف بردارهای کهنه</td>
|
||||
<td>
|
||||
<code>RemoveVectorsAsync</code> با
|
||||
<code>identifierPrefix</code> برای حذف بردارهای قبلی همان
|
||||
سند در حالت <code>replaceExisting</code>؛ ترتیب نیز
|
||||
تغییر کرد — اکنون <b>پس از</b> Embed موفق انجام میشود
|
||||
(در صورت شکست Embed، بردارهای قبلی سالم میمانند)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ساختار کد</td>
|
||||
<td>
|
||||
بازچینش پارامترها و بلوکها؛ حذف فاصلههای اضافی و
|
||||
یکسانسازی قالببندی
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3>۳-۴. ایمنی نخ (Thread-Safety) در <code>XInMemoryVectorStore</code></h3>
|
||||
<p>
|
||||
بازیابی Session اکنون داخل <code>lock (found.SyncRoot)</code> انجام
|
||||
میشود و با بررسی
|
||||
<code>ReferenceEquals(current, found)</code> از دسترفتن Session در
|
||||
اثر حذف همزمان جلوگیری میکند.
|
||||
</p>
|
||||
<pre>
|
||||
// قبل: خواندن/بهروزرسانی بدون قفل
|
||||
if (!sessions.TryGetValue(sessionId, out found) || !OwnerMatches(found, ownerId)) return false;
|
||||
found.LastAccessAtUtc = DateTime.UtcNow;
|
||||
|
||||
// بعد: دسترسی اتمیک
|
||||
lock (found.SyncRoot)
|
||||
{
|
||||
if (!sessions.TryGetValue(sessionId, out current) || !ReferenceEquals(current, found))
|
||||
return false;
|
||||
if (!OwnerMatches(found, ownerId)) return false;
|
||||
if (found.IsExpired(DateTime.UtcNow)) { sessions.TryRemove(sessionId, out found); return false; }
|
||||
found.LastAccessAtUtc = DateTime.UtcNow;
|
||||
session = found;
|
||||
}</pre
|
||||
>
|
||||
|
||||
<h3>۳-۵. رفع اشکالات و اصلاحات جزئی</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>نوع</th>
|
||||
<th>فایل</th>
|
||||
<th>توضیح</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span class="badge mod">رفع اشکال</span></td>
|
||||
<td><code>Controllers/XAiServiceControllerBase.cs</code></td>
|
||||
<td>
|
||||
<b>رفع باگ کلیدی:</b> در مسیر <code>Ask</code> مقدار
|
||||
<code>files: null</code> به <code>files</code> تغییر کرد؛
|
||||
پیشتر فایلهای پیوست به سرویس AI منتقل نمیشدند و RAG
|
||||
روی فایلها کار نمیکرد
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">رفع اشکال</span></td>
|
||||
<td><code>Extensions/XModelsExtensions.cs</code></td>
|
||||
<td>
|
||||
اعتبارسنجی درخواست <code>ChatWithDocuments</code> ساده شد؛
|
||||
<code>TopK</code> و <code>MinScore</code> دیگر اجباری
|
||||
نیستند (مقادیر پیشفرض از
|
||||
<code>RAGDescriptor</code> اعمال میشود)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">رفع اشکال</span></td>
|
||||
<td><code>Middlewares/XAiModelProxyMiddleware.cs</code></td>
|
||||
<td>
|
||||
اصلاح اپراتور منطقی
|
||||
<code>(!apiKey.IsNullOrEmpty()) |</code> ←
|
||||
<code>||</code> در بررسی احراز هویت
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>Providers/XAiEmbeddingServiceBase.cs</code></td>
|
||||
<td>
|
||||
<code>using var generator = GetEmbeddingGenerator();</code> ←
|
||||
<code>var generator = ...</code>؛ چون Generator در متد
|
||||
<code>Dispose</code> نمیشود، استفاده از
|
||||
<code>using</code> باعث Dispose زودهنگام میشد
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge mod">تغییر</span></td>
|
||||
<td><code>Controllers/ChatWithDocumentsController.cs</code></td>
|
||||
<td>
|
||||
مرتبسازی پارامترهای فراخوانی
|
||||
<code>EmbedChunks</code> (تغییر صرفاً ظاهری/ترتیبی)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge del">حذف</span></td>
|
||||
<td><code>Interfaces/IXAiEmbeddingServiceControllerBase.cs</code></td>
|
||||
<td>
|
||||
رابط کنترلر Embedding حذف شد؛ نسخهٔ پشتیبان در
|
||||
<code>Documents/Codes/IXAiEmbeddingServiceControllerBase.cs</code>
|
||||
ریشهٔ Workspace موجود است
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۴. تغییرات ریشهٔ Workspace</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>نوع</th>
|
||||
<th>فایل / مسیر</th>
|
||||
<th>توضیح</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><span class="badge del">حذف</span></td>
|
||||
<td>
|
||||
<code>Documents/GeneratedContext/xDashboard-xAiApi-20261031_105908.txt</code>
|
||||
<code
|
||||
>xDashboard-xAiModels-20261031_105909.txt</code
|
||||
>
|
||||
<code>xDashboard-xAiService-20261031_105909.txt</code>
|
||||
</td>
|
||||
<td>
|
||||
Contextهای تولیدشدهٔ قدیمی حذف شدند (مجموعاً حدود
|
||||
۲۳٬۵۰۰ خط)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">افزوده</span></td>
|
||||
<td>
|
||||
<code>Documents/GeneratedContext/xDashboard-xAiApi-20261102_154558.txt</code>
|
||||
<code
|
||||
>xDashboard-xAiModels-20261102_154559.txt</code
|
||||
>
|
||||
<code>xDashboard-xAiService-20261102_154559.txt</code>
|
||||
</td>
|
||||
<td>
|
||||
Contextهای تازهٔ تولیدشده پس از Refactor جایگزین شدند
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">افزوده</span></td>
|
||||
<td>
|
||||
<code>Documents/Codes/XAiApiConfiguration.cs</code>،
|
||||
<code>Documents/Codes/XAiApiConfigurationExtensions.cs</code>
|
||||
</td>
|
||||
<td>
|
||||
نسخهٔ پشتیبان فایلهای حذفشده از
|
||||
<code>xAiModels</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">افزوده</span></td>
|
||||
<td>
|
||||
<code>Documents/Codes/XAIServiceBase.cs</code>،
|
||||
<code>Documents/Codes/IXAiEmbeddingServiceControllerBase.cs</code>
|
||||
</td>
|
||||
<td>
|
||||
نسخهٔ پشتیبان فایلهای بازآراییشده/حذفشده در
|
||||
<code>xAiApi</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">افزوده</span></td>
|
||||
<td>
|
||||
<code>Documents/Docs/X121KIEA/X121XKIEA_Analytics-140412.html</code>
|
||||
<code>X121XKIEA_Analytics-140412.pdf</code>
|
||||
<code>X121XKIEA_Analytics.pdf</code>
|
||||
</td>
|
||||
<td>
|
||||
مستندات تحلیلی X121 (نسخهٔ HTML و PDF)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge new">افزوده</span></td>
|
||||
<td>
|
||||
<code>Documents/Docs/Developer/Fix N08 Issue.html</code>،
|
||||
<code>xAiApi-14050807-Overview-6.html</code>،
|
||||
<code>xAiApi-14050807-Overview-7.html</code>،
|
||||
<code>xAiApi-14050807-Overview-7.1.html</code>،
|
||||
<code>xAiApi-14050807-Overview-7.2.html</code>،
|
||||
<code>xAiApi-14050807-Overview-8.html</code>،
|
||||
<code>xAiApi-14050807-Overview-9.html</code>
|
||||
</td>
|
||||
<td>
|
||||
گزارشهای بازبینی و بررسی اشکال N08
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><span class="badge sub">Submodule</span></td>
|
||||
<td><code>xAiApi</code>، <code>Modules/xAiModels</code></td>
|
||||
<td>
|
||||
Pointerها بهروزرسانی میشوند (محتوای فعلی Working Tree
|
||||
این دو زیرماژول، شامل تغییرات این نسخه)
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۵. اعتبارسنجی</h2>
|
||||
<pre>
|
||||
dotnet build xAiApi/xAiApi.csproj --nologo -v q
|
||||
64 Warning(s) (MSB3277 — از قبل موجود، مربوط به تعارض نسخهٔ NameReference)
|
||||
0 Error(s)</pre
|
||||
>
|
||||
<div class="note">
|
||||
تست Runtime / End-to-End (جریان SSE، Ingest با فایل، Retrieve چندسطحی،
|
||||
انتقال به <code>Guid?</code> در مسیر Conversation پیشفرض) در این
|
||||
مرحله انجام نشده است.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۶. نکات و هشدارها (نیازمند بررسی)</h2>
|
||||
<div class="warn">
|
||||
<b>۱) تغییر API-شکن در <code>xAiModels</code>:</b> حذف
|
||||
<code>XAiApiConfiguration</code> و
|
||||
<code>XAiApiConfigurationExtensions</code> از ماژل مدل. هر پروژه یا
|
||||
سرویس دیگری که به این ماژل وابسته است و از این کلاسها استفاده
|
||||
میکند باید بهروزرسانی شود.
|
||||
</div>
|
||||
<div class="warn">
|
||||
<b>۲) تغییر نام <code>GetDafualtProject</code> ←
|
||||
<code>GetDafaultProject</code>:</b> همهٔ مصرفکنندهها در
|
||||
<code>xAiApi</code> بهروزرسانی شدند، اما در صورت وجود مصرفکننده در
|
||||
سایر ماژولهای Solution باید بررسی شود.
|
||||
</div>
|
||||
<div class="warn">
|
||||
<b>۳) شرط <code>x.ProjectId == project.Id</code>:</b> این اصلاح
|
||||
وابسته به این است که <code>project</code> پیشتر بارگذاری شده باشد. در
|
||||
صورت خالی بودن، <code>project.Id</code> منجر به
|
||||
<code>InvalidOperationException</code> میشود.
|
||||
</div>
|
||||
<div class="warn">
|
||||
<b>۴) نقش پیام در <code>AskAsEnumerable</code>:</b> Role از
|
||||
<code>System</code> به <code>Assistant</code> تغییر کرد؛ در صورتی که
|
||||
مصرفکنندگان SSE به Role وابسته باشند، نیاز به بررسی دارند.
|
||||
</div>
|
||||
<div class="warn">
|
||||
<b>۵) حذف فایل در مسیر خطا:</b> در <code>XAiRAGService</code>، فایل
|
||||
آپلودشده در صورت شکست Chunk/Embedding حذف میشود؛ در صورت خطای
|
||||
دسترسی، این حذف نیز ممکن است با خطا مواجه شود که در
|
||||
<code>catch</code> ثبت میشود.
|
||||
</div>
|
||||
<div class="warn">
|
||||
<b>۶) پرامپت <code>ChatWithDocuments</code>:</b> همچنان باید در
|
||||
<code>appsettings</code> محیط Production موجود باشد؛ در غیر این صورت
|
||||
<code>PrepareMemory</code> خطای <code>InvalidConfiguration</code> میدهد.
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۷. ترتیب پیشنهادی Commit</h2>
|
||||
<ol>
|
||||
<li><code>Modules/xAiModels</code> (وابستگی)</li>
|
||||
<li><code>xAiApi</code></li>
|
||||
<li>مخزن اصلی (Pointerها، مستندات، Contextها)</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<section class="section">
|
||||
<h2>۸. فایلهای مستند این نسخه</h2>
|
||||
<p>
|
||||
گزارش:
|
||||
<code>Documents/Docs/ChangeLogs/1405-08-11-v01.html</code>
|
||||
</p>
|
||||
<p>
|
||||
Commit message:
|
||||
<code>Documents/Docs/ChangeLogs/CommitMessage-1405-08-11-v01.txt</code>
|
||||
</p>
|
||||
<p>
|
||||
برای مستندسازی تغییرات بعدی در همین تاریخ، پسوند را به
|
||||
<code>v02</code> و پس از آن <code>v03</code> افزایش دهید.
|
||||
</p>
|
||||
</section>
|
||||
</main>
|
||||
<footer>
|
||||
تولیدشده در تاریخ ۱۴۰۵/۰۸/۱۱ (2026-11-02) | xSaherelmWorkspace |
|
||||
ChangeLog v01
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,129 @@
|
||||
================================================================================
|
||||
Commit Message - xSaherelmWorkspace
|
||||
تاریخ: ۱۴۰۵/۰۸/۱۱ (2026-11-02)
|
||||
نسخه مستند: v01
|
||||
گزارش کامل: Documents/Docs/ChangeLogs/1405-08-11-v01.html
|
||||
================================================================================
|
||||
|
||||
هدف: بازآرایی لایهٔ گفتگو در xAiApi (استخراج PrepareChatRequirementsAsync و
|
||||
مدل XPreparedChatContext)، مقاومسازی XAiRAGService و XInMemoryVectorStore،
|
||||
Nullable شدن projectId در لایهٔ داده xAiModels و انتقال XAiApiConfiguration
|
||||
به سطح ریشهٔ Workspace.
|
||||
|
||||
ترتیب Commit: [1] xAiModels -> [2] xAiApi -> [3] Root
|
||||
|
||||
[1] Modules/xAiModels
|
||||
Make projectId Nullable in Data Provider and Remove Api Configuration
|
||||
- IXAiDataProvider.GetDefaultConversation: projectId changed from Guid to Guid?;
|
||||
- XAiDataProvider.GetDefaultConversation / HasDefaultConversation /
|
||||
CreateDefaultConversation: adapt to Guid? (use !projectId.HasValue instead of
|
||||
projectId.IsNull(); resolve project via projectId.Value);
|
||||
- XAiDataProvider: conversation lookup predicate fixed to
|
||||
x.ProjectId == project.Id (was x.ProjectId == projectId);
|
||||
- XEmbeddingExtensions: add ToEmbedding(this ReadOnlyMemory<float>) to persist
|
||||
embeddings as JSON;
|
||||
- XAiDataProvider: use item.Embedding.ToEmbedding() instead of ToJSON() when
|
||||
upserting vectors;
|
||||
- XAiModelsExtensions: rename GetDafualtProject -> GetDafaultProject (typo fix);
|
||||
- Remove Configurations/XAiApiConfiguration.cs and
|
||||
Extensions/XAiApiConfigurationExtensions.cs (Api configuration does not belong
|
||||
to the models module).
|
||||
BREAKING: XAiApiConfiguration / XAiApiConfigurationExtensions removed from
|
||||
xAiModels; GetDafualtProject renamed to GetDafaultProject.
|
||||
Files: D Configurations/XAiApiConfiguration.cs;
|
||||
D Extensions/XAiApiConfigurationExtensions.cs;
|
||||
M Extensions/XAiModelsExtensions.cs;
|
||||
M Extensions/XEmbeddingExtensions.cs;
|
||||
M Interfaces/IXAiDataProvider.cs;
|
||||
M Providers/XAiDataProvider.cs
|
||||
|
||||
|
||||
[2] xAiApi
|
||||
Refactor Chat Pipeline into PrepareChatRequirementsAsync and Harden RAG Services
|
||||
- XAIServiceBase: add PrepareChatRequirementsAsync as the single entry point
|
||||
for chat prerequisites (normalize RAG params, resolve default
|
||||
project/conversation, ingest attachments, retrieve RAG context, build history,
|
||||
persist prompt message) and return the new XPreparedChatContext;
|
||||
- XAIServiceBase: add NormalizeRagParams (topK / minScore / type) and use it in
|
||||
all Ask* methods instead of duplicated inline normalization;
|
||||
- XAIServiceBase: rework GetHistory - the single
|
||||
GetHistory(ChatMessage, bool) signature is replaced by two overloads
|
||||
GetHistory(prompt, forcePrompt) and GetHistory(prompt, context); the latter is
|
||||
used by the non-persisted chat path;
|
||||
- XAIServiceBase: remove AskLLMAsync; LLM invocation is now inlined in each
|
||||
Ask* method over prep.History;
|
||||
- XAIServiceBase: rewrite AskAsync and AskAsEnumerable on top of
|
||||
PrepareChatRequirementsAsync; streamed responses now use Role = Assistant,
|
||||
RespondTo = prep.PersistedPromptMessage.Id and Sequence++;
|
||||
- XAIServiceBase: use XAiApiConstants.XAiApiRagPromptName instead of
|
||||
configuration.RAGDescriptor.PromptName;
|
||||
- XAIServiceBase.LoadConversations: call the renamed GetDafaultProject;
|
||||
- Add Models/XPreparedChatContext.cs (Project, Conversation, History, Context,
|
||||
PersistedPromptMessage) as the shared context between actions;
|
||||
- XAiRAGService: wrap each file ingest in its own try/catch with
|
||||
logger.LogError so one bad file no longer aborts the whole ingest;
|
||||
- XAiRAGService: upload the file and add a scope reference
|
||||
(providedFor / forProvidedId) for the ingested scope;
|
||||
- XAiRAGService: remove stale vectors of the same document via
|
||||
RemoveVectorsAsync(identifierPrefix) when replaceExisting is set;
|
||||
- XInMemoryVectorStore: make session retrieval thread-safe via
|
||||
lock (found.SyncRoot) and ReferenceEquals check against concurrent removal;
|
||||
- XAiServiceControllerBase.Ask: pass the attached files to the AI service
|
||||
(was files: null) so RAG works on attachments;
|
||||
- XModelsExtensions: relax ChatWithDocuments ask validation - TopK and
|
||||
MinScore are optional again (defaults come from RAGDescriptor);
|
||||
- XAiModelProxyMiddleware: use logical OR instead of bitwise OR in the
|
||||
authentication check;
|
||||
- XAiEmbeddingServiceBase: do not dispose the embedding generator
|
||||
(removed `using` to avoid premature disposal);
|
||||
- ChatWithDocumentsController: reorder EmbedChunks parameters;
|
||||
- Remove Interfaces/IXAiEmbeddingServiceControllerBase.cs.
|
||||
Files: A Models/XPreparedChatContext.cs;
|
||||
D Interfaces/IXAiEmbeddingServiceControllerBase.cs;
|
||||
M Controllers/ChatWithDocumentsController.cs;
|
||||
M Controllers/XAiServiceControllerBase.cs;
|
||||
M Extensions/XModelsExtensions.cs;
|
||||
M Middlewares/XAiModelProxyMiddleware.cs;
|
||||
M Providers/XAIServiceBase.cs;
|
||||
M Providers/XAiEmbeddingServiceBase.cs;
|
||||
M Providers/XAiRAGService.cs;
|
||||
M Providers/XInMemoryVectorStore.cs
|
||||
|
||||
|
||||
[3] Workspace (root)
|
||||
- Update submodule pointers: xAiApi, Modules/xAiModels;
|
||||
- Replace stale generated contexts: remove
|
||||
Documents/GeneratedContext/xDashboard-xAi{Api,Models,Service}-20261031_*.txt
|
||||
and add the 20261102_1545xx set;
|
||||
- Add Documents/Codes/XAiApiConfiguration.cs,
|
||||
Documents/Codes/XAiApiConfigurationExtensions.cs,
|
||||
Documents/Codes/XAIServiceBase.cs and
|
||||
Documents/Codes/IXAiEmbeddingServiceControllerBase.cs as backups;
|
||||
- Add Documents/Docs/X121KIEA/X121XKIEA_Analytics-140412.html/.pdf and
|
||||
X121XKIEA_Analytics.pdf;
|
||||
- Add Documents/Docs/Developer/Fix N08 Issue.html and
|
||||
xAiApi-14050807-Overview-6/7/7.1/7.2/8/9.html;
|
||||
- Add Documents/Docs/ChangeLogs/1405-08-11-v01.html and this file.
|
||||
|
||||
Validation:
|
||||
- dotnet build xAiApi/xAiApi.csproj --nologo -v q -> 0 Error(s),
|
||||
64 pre-existing warnings (MSB3277);
|
||||
- Runtime / end-to-end tests not performed.
|
||||
|
||||
Known Issues (to fix before release):
|
||||
- Removing XAiApiConfiguration from xAiModels is a breaking change for any
|
||||
other consumer of that module;
|
||||
- GetDafaultProject rename is breaking for out-of-module consumers;
|
||||
- XAiDataProvider now relies on `project` being loaded before the
|
||||
`x.ProjectId == project.Id` predicate;
|
||||
- SSE response Role changed from System to Assistant - verify SSE consumers;
|
||||
- The "ChatWithDocuments" prompt must exist in production appsettings.
|
||||
|
||||
Suggested root commit title:
|
||||
Refactor Chat Pipeline, Harden RAG Services, Nullable projectId (۱۴۰۵/۰۸/۱۱ v01)
|
||||
|
||||
For additional documentation use v02:
|
||||
1405-08-11-v02.html
|
||||
CommitMessage-1405-08-11-v02.txt
|
||||
================================================================================
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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 & 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<ActionResult<string>> 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 && 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>تاریخ تهیه: آبان ۱۴۰۵ | نسخه: ۶.۰ | طبقهبندی: محرمانه</div>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,472 @@
|
||||
<!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 & 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 && 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() && ... && !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 =>
|
||||
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 =>
|
||||
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>تاریخ تهیه: آبان ۱۴۰۵ | نسخه: ۷.۰ | طبقهبندی: محرمانه</div>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+78
-128
@@ -1,35 +1,4 @@
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Configurations\XAiApiConfiguration.cs
|
||||
|
||||
using xAiModels.Models;
|
||||
using xAiModels.Constants;
|
||||
|
||||
namespace xAiModels.Configurations
|
||||
{
|
||||
public class XAiApiConfiguration
|
||||
{
|
||||
/// <summary>
|
||||
/// Model Providers ...
|
||||
/// </summary>
|
||||
public XAiModelDescriptor[] Models { get; set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Each User must Has a Default Project, this is Title Resource Identifier ...
|
||||
/// </summary>
|
||||
public string DefaultProjectTitleResource { get; set; } = XAiModelsConstants.DefaultXAiProjectTitleResourceID;
|
||||
|
||||
/// <summary>
|
||||
/// Each User must Has a Default Project, this is Description Resource Identifier ...
|
||||
/// </summary>
|
||||
public string DefaultProjectDescriptionResource { get; set; } = XAiModelsConstants.DefaultXAiProjectDescriptionResourceID;
|
||||
|
||||
/// <summary>
|
||||
/// Each User must Has a Default Conversation, this is Title Resource Identifier ... ...
|
||||
/// </summary>
|
||||
public string DefaultConversationTitleResource { get; set; } = XAiModelsConstants.DefaultXAiConversationTitleResourceID;
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Configurations\XAiModelMappersProfile.cs
|
||||
|
||||
using AutoMapper;
|
||||
@@ -1164,51 +1133,6 @@ namespace xAiModels.Extensions
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Extensions\XAiApiConfigurationExtensions.cs
|
||||
|
||||
using System.Linq;
|
||||
using xAiModels.Models;
|
||||
using xCommons.Extensions;
|
||||
using xAiModels.Configurations;
|
||||
|
||||
namespace xAiModels.Extensions
|
||||
{
|
||||
public static class XAiApiConfigurationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Validate Api Configuration ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsValid(this XAiApiConfiguration source)
|
||||
{
|
||||
return
|
||||
!source.IsNullOrDefault() &&
|
||||
source.Models.HasChild();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve Default Model Descriptor ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static XAiModelDescriptor GetDefaultModel(this XAiApiConfiguration source)
|
||||
{
|
||||
//
|
||||
XAiModelDescriptor result = null;
|
||||
|
||||
//
|
||||
if (source.IsValid())
|
||||
{
|
||||
result = source.Models.First();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Extensions\XAiModelsExtensions.cs
|
||||
|
||||
using System;
|
||||
@@ -1552,7 +1476,7 @@ namespace xAiModels.Extensions
|
||||
/// <param name="source"></param>
|
||||
/// <param name="ownerId"></param>
|
||||
/// <returns></returns>
|
||||
public static Guid GetDafualtProject(
|
||||
public static Guid GetDafaultProject(
|
||||
this IEnumerable<XAiProjectDto> source,
|
||||
string ownerId
|
||||
)
|
||||
@@ -1712,8 +1636,8 @@ namespace xAiModels.Extensions
|
||||
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Extensions\XEmbeddingExtensions.cs
|
||||
|
||||
using System;
|
||||
using xCommons.Extensions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace xAiModels.Extensions
|
||||
{
|
||||
@@ -1728,7 +1652,8 @@ namespace xAiModels.Extensions
|
||||
{
|
||||
//
|
||||
// Validate ...
|
||||
if (source.IsNullOrEmpty()) {
|
||||
if (source.IsNullOrEmpty())
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -1743,6 +1668,26 @@ namespace xAiModels.Extensions
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts ReadOnly Memory to Embedding Representation ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToEmbedding(this ReadOnlyMemory<float> source)
|
||||
{
|
||||
//
|
||||
var result = string.Empty;
|
||||
|
||||
//
|
||||
if (!source.IsNull() && !source.IsEmpty)
|
||||
{
|
||||
result = source.ToArray().ToJSON();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3120,7 +3065,7 @@ namespace xAiModels.Interfaces
|
||||
/// <returns></returns>
|
||||
Task<XAiConversationDto> GetDefaultConversation(
|
||||
string ownerId,
|
||||
Guid projectId,
|
||||
Guid? projectId,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
);
|
||||
@@ -4393,6 +4338,7 @@ namespace xAiModels.Models
|
||||
### FILE: C:\Users\hkhazaeeasl\Documents\Projets\XProjects\xSaherelmWorkspace\Modules\xAiModels\Models\XAiResponseRequest.cs
|
||||
|
||||
using System;
|
||||
using xAiModels.Constants;
|
||||
|
||||
namespace xAiModels.Models
|
||||
{
|
||||
@@ -4406,6 +4352,21 @@ namespace xAiModels.Models
|
||||
/// </summary>
|
||||
public string Prompt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Knowledge Type ...
|
||||
/// </summary>
|
||||
public string Type { get; set; } = XAiModelsConstants.XAiDefaultKnowledgeType;
|
||||
|
||||
/// <summary>
|
||||
/// Provided TopK in Vector Searchs ...
|
||||
/// </summary>
|
||||
public int? TopK { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Min Score for Vector Searchs ...
|
||||
/// </summary>
|
||||
public float? MinScore { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specified Project Id ...
|
||||
/// </summary>
|
||||
@@ -6084,7 +6045,7 @@ namespace xAiModels.Providers
|
||||
/// <returns></returns>
|
||||
public async Task<XAiConversationDto> GetDefaultConversation(
|
||||
string ownerId,
|
||||
Guid projectId,
|
||||
Guid? projectId,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -6099,8 +6060,8 @@ namespace xAiModels.Providers
|
||||
//
|
||||
// Prepare Project ...
|
||||
XAiProjectDto project = null;
|
||||
if (projectId.IsNull() ||
|
||||
projectId.IsDefaultGuid()
|
||||
if (!projectId.HasValue ||
|
||||
projectId.Value.IsDefaultGuid()
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -6114,7 +6075,7 @@ namespace xAiModels.Providers
|
||||
{
|
||||
//
|
||||
project = await projectRepositoryService.GetAsync(
|
||||
id: projectId,
|
||||
id: projectId.Value,
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken
|
||||
@@ -6145,20 +6106,19 @@ namespace xAiModels.Providers
|
||||
}
|
||||
|
||||
//
|
||||
// Detect Conversation Resource ...
|
||||
// Check Default Owner Exists or not ...
|
||||
var resource = await stringProvider.FindOne(
|
||||
cancellationToken: cancellationToken,
|
||||
predicate: x =>
|
||||
x.ResourceTitle
|
||||
.ToNormalString()
|
||||
.Contains(ownerId.ToNormalString()) &&
|
||||
.Contains(ownerId.ToString().ToNormalString()) &&
|
||||
x.ResourceTitle
|
||||
.ToNormalString()
|
||||
.Contains(XAiModelsConstants.XAiProjectTitleIdentifier
|
||||
.ToNormalString()) &&
|
||||
.Contains(XAiModelsConstants.XAiConversationTitleIdentifier.ToNormalString()) &&
|
||||
x.TranslatedValue
|
||||
.ToNormalString()
|
||||
.Contains(XAiDataProviderConstants.XDefaultAiProjectSuffix)
|
||||
.Contains(XAiDataProviderConstants.XDefaultAiConversationSuffix.ToNormalString())
|
||||
);
|
||||
if (resource.IsNullOrDefault())
|
||||
{
|
||||
@@ -6166,20 +6126,12 @@ namespace xAiModels.Providers
|
||||
}
|
||||
|
||||
//
|
||||
// Find Default Conversation ...
|
||||
var result = await conversationRepositoryService.FindOneAsync(
|
||||
cancellationToken: cancellationToken,
|
||||
predicate: x => x.Title
|
||||
.Equals(
|
||||
resource.ResourceTitle,
|
||||
StringComparison.InvariantCultureIgnoreCase
|
||||
) &&
|
||||
x.ProjectId == project.Id
|
||||
predicate: x =>
|
||||
x.ProjectId == project.Id &&
|
||||
x.Title == resource.ResourceTitle
|
||||
);
|
||||
if (result.IsNullOrDefault())
|
||||
{
|
||||
XException.NotFound.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
@@ -6471,6 +6423,13 @@ namespace xAiModels.Providers
|
||||
XException.InvalidArgs.Throw();
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize ...
|
||||
if (type.IsNullOrEmpty())
|
||||
{
|
||||
type = XAiModelsConstants.XAiDefaultKnowledgeType;
|
||||
}
|
||||
|
||||
//
|
||||
// Converts Question Vector to Vector Array ...
|
||||
var queryVector = queryEmbedding.ToArray();
|
||||
@@ -6610,7 +6569,7 @@ namespace xAiModels.Providers
|
||||
{
|
||||
//
|
||||
exists.Text = item.Text;
|
||||
exists.Embedding = item.Embedding.ToJSON();
|
||||
exists.Embedding = item.Embedding.ToEmbedding();
|
||||
exists.Type = item.Type.IsNullOrEmpty() ? exists.Type : item.Type;
|
||||
exists.Metadata = item.Metadata.IsNullOrDefault() ? exists.Metadata : item.Metadata.ToJSON();
|
||||
toUpdate.Add(exists);
|
||||
@@ -6624,7 +6583,7 @@ namespace xAiModels.Providers
|
||||
Type = item.Type,
|
||||
Identifier = item.Identifier,
|
||||
Metadata = item.Metadata.ToJSON(),
|
||||
Embedding = item.Embedding.ToJSON(),
|
||||
Embedding = item.Embedding.ToEmbedding(),
|
||||
Id = item.Id.IsDefaultGuid() ? Guid.NewGuid() : item.Id,
|
||||
});
|
||||
}
|
||||
@@ -7134,7 +7093,7 @@ namespace xAiModels.Providers
|
||||
/// <returns></returns>
|
||||
private async Task<bool> HasDefaultConversation(
|
||||
string ownerId,
|
||||
Guid projectId,
|
||||
Guid? projectId,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -7150,8 +7109,8 @@ namespace xAiModels.Providers
|
||||
//
|
||||
// Prepare Project ...
|
||||
XAiProjectDto project = null;
|
||||
if (projectId.IsNull() ||
|
||||
projectId.IsDefaultGuid()
|
||||
if (!projectId.HasValue ||
|
||||
projectId.Value.IsDefaultGuid()
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -7165,7 +7124,7 @@ namespace xAiModels.Providers
|
||||
{
|
||||
//
|
||||
project = await projectRepositoryService.GetAsync(
|
||||
id: projectId,
|
||||
id: projectId.Value,
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken
|
||||
@@ -7201,7 +7160,7 @@ namespace xAiModels.Providers
|
||||
var defaultConversation = await conversationRepositoryService.FindOneAsync(
|
||||
cancellationToken: cancellationToken,
|
||||
predicate: x =>
|
||||
x.ProjectId == projectId &&
|
||||
x.ProjectId == project.Id &&
|
||||
x.Title == resource.ResourceTitle
|
||||
);
|
||||
result = !defaultConversation.IsNullOrDefault();
|
||||
@@ -7220,7 +7179,7 @@ namespace xAiModels.Providers
|
||||
/// <returns></returns>
|
||||
private async Task CreateDefaultConversation(
|
||||
string ownerId,
|
||||
Guid projectId,
|
||||
Guid? projectId,
|
||||
string connectionId = null,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
@@ -7239,8 +7198,8 @@ namespace xAiModels.Providers
|
||||
//
|
||||
// Prepare Project ...
|
||||
XAiProjectDto project = null;
|
||||
if (projectId.IsNull() ||
|
||||
projectId.IsDefaultGuid()
|
||||
if (!projectId.HasValue ||
|
||||
projectId.Value.IsDefaultGuid()
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -7254,7 +7213,7 @@ namespace xAiModels.Providers
|
||||
{
|
||||
//
|
||||
project = await projectRepositoryService.GetAsync(
|
||||
id: projectId,
|
||||
id: projectId.Value,
|
||||
includeBuilder: null,
|
||||
ignoreSoftDeleteds: true,
|
||||
cancellationToken: cancellationToken
|
||||
@@ -8751,14 +8710,17 @@ namespace xAiModels.Providers.Enrichers
|
||||
{
|
||||
public class XAiMessageEnricher : IXAiMessageEnricher
|
||||
{
|
||||
private readonly IXPersonService personService;
|
||||
private readonly IXIdentityProvider identityProvider;
|
||||
private readonly IXAiConversationTitleResourceProvider conversationTitleResourceProvider;
|
||||
|
||||
public XAiMessageEnricher(
|
||||
IXPersonService personService,
|
||||
IXIdentityProvider identityProvider,
|
||||
IXAiConversationTitleResourceProvider conversationTitleResourceProvider
|
||||
)
|
||||
{
|
||||
this.personService = personService;
|
||||
this.identityProvider = identityProvider;
|
||||
this.conversationTitleResourceProvider = conversationTitleResourceProvider;
|
||||
}
|
||||
@@ -8804,14 +8766,7 @@ namespace xAiModels.Providers.Enrichers
|
||||
XPersonDto owner = null;
|
||||
if (!source.OwnerId.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
// Try to Retrieve User Info ...
|
||||
var device = identityProvider.GetDevice();
|
||||
var userInfo = await identityProvider.GetUserInfo(
|
||||
device: device,
|
||||
userSelectByParam: source.OwnerId
|
||||
);
|
||||
owner = userInfo.ToXPersonDto();
|
||||
owner = await personService.GetPerson(source.OwnerId);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -8898,7 +8853,6 @@ using System.Threading.Tasks;
|
||||
using xAiModels.Models.Entities;
|
||||
using System.Collections.Generic;
|
||||
using xIdentityService.Interfaces;
|
||||
using xIdentityService.Extensions;
|
||||
using xAiModels.Interfaces.Entities;
|
||||
using xAiModels.Interfaces.Enrichers;
|
||||
|
||||
@@ -8906,6 +8860,7 @@ namespace xAiModels.Providers.Enrichers
|
||||
{
|
||||
public class XAiProjectEnricher : IXAiProjectEnricher
|
||||
{
|
||||
private readonly IXPersonService personService;
|
||||
private readonly IXIdentityProvider identityProvider;
|
||||
private readonly IXAiMessageRepository messageRepository;
|
||||
private readonly IXAiConversationRepository conversationRepository;
|
||||
@@ -8914,6 +8869,7 @@ namespace xAiModels.Providers.Enrichers
|
||||
private readonly IXAiProjectDescriptionResourceProvider projectDescriptionResourceProvider;
|
||||
|
||||
public XAiProjectEnricher(
|
||||
IXPersonService personService,
|
||||
IXIdentityProvider identityProvider,
|
||||
IXAiMessageRepository messageRepository,
|
||||
IXAiConversationRepository conversationRepository,
|
||||
@@ -8923,6 +8879,7 @@ namespace xAiModels.Providers.Enrichers
|
||||
)
|
||||
{
|
||||
//
|
||||
this.personService = personService;
|
||||
this.identityProvider = identityProvider;
|
||||
this.messageRepository = messageRepository;
|
||||
this.conversationRepository = conversationRepository;
|
||||
@@ -8982,14 +8939,7 @@ namespace xAiModels.Providers.Enrichers
|
||||
XPersonDto owner = null;
|
||||
if (!source.OwnerId.IsNullOrEmpty())
|
||||
{
|
||||
//
|
||||
// Try to Retrieve User Info ...
|
||||
var device = identityProvider.GetDevice();
|
||||
var userInfo = await identityProvider.GetUserInfo(
|
||||
device: device,
|
||||
userSelectByParam: source.OwnerId
|
||||
);
|
||||
owner = userInfo.ToXPersonDto();
|
||||
owner = await personService.GetPerson(source.OwnerId);
|
||||
}
|
||||
|
||||
//
|
||||
+1
-1
Submodule Modules/xAiModels updated: c4b7e86174...9e7710e345
+1
-1
Submodule xAiApi updated: 726d6ce827...a870d61e61
Reference in New Issue
Block a user