Implement RAG Scopes, Remove ProxyController, Fix Pipeline Order and SSE Format
- RAG: real scopes with identifiers conversation/{id}/, project/{id}/, user/{ownerId}/, global/;
- RAG: ownership checks via GetProject/GetConversation; Global write requires admin role;
- RAG: tiered retrieval Conversation -> Project -> User -> Global (single embedding, dedup, TopK fill);
- RAG: apply Type filter, sanitize file names, enforce MaxFilesPerIngest/MaxFileSizeBytes/MaxDocumentsPerScope;
- RAG: store scope/scopeId/type/ownerId metadata; return it in documents and sources;
- RAG: add MigrateLegacyVectorsAsync + POST /Knowledge/MigrateLegacy ({ownerId}/... -> user/{ownerId}/...);
- Knowledge API: scope/scopeId on Ingest, Documents, DELETE Documents;
- Remove ProxyController (root route "{modelName}/{path}" + AllowAnonymous hijacked all 2-segment paths);
- Startup: ExceptionHandler("/error") + HSTS outside Development; Swagger only in Development;
static files before routing; CORS before model proxy; add /error endpoint;
- SSE: all stream endpoints use xHttpService XSseExtensions; validate before streaming;
pre-stream errors return proper HTTP status; remove "Connection: keep-alive";
- Use xAiModels.Constants for XAiKnowledgeScope / Knowledge constants / XOpenAINoKey;
- Register XAiVectorEntityRegisterar in XAiApiDbContext;
- XCodeFileContentExtractor: actually read stream content; drop hard-coded "book.epub".
BREAKING: AskTextStream emits data: {"text":"..."}; AskStream emits data: {json}; both end with event: done.
This commit is contained in:
+26
-15
@@ -18,6 +18,7 @@ using xStorageService.DI;
|
||||
using xIdentityService.DI;
|
||||
using xDataService.Models;
|
||||
using xCommons.Extensions;
|
||||
using xAiModels.Constants;
|
||||
using xPushService.Helpers;
|
||||
using xCommons.Configurations;
|
||||
using System.Collections.Generic;
|
||||
@@ -204,27 +205,41 @@ namespace xAiApi
|
||||
{
|
||||
//
|
||||
// Configure the HTTP request pipeline.
|
||||
var isDevelopmentEnvironment = false;
|
||||
if (env.IsDevelopment())
|
||||
// Order: Exception Handling -> Https -> Static Files -> Swagger (Dev) -> Cors
|
||||
// -> Model Proxy (Terminal for /{RoutePrefix}) -> Routing -> AuthN -> AuthZ -> Endpoints ...
|
||||
var isDevelopmentEnvironment = env.IsDevelopment();
|
||||
if (isDevelopmentEnvironment)
|
||||
{
|
||||
isDevelopmentEnvironment = true;
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
//
|
||||
// Use Swagger Middleware ...
|
||||
app.UseXSwagger();
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler(XAiModelsConstants.XAiErrorRoute);
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
//
|
||||
// Force Https Redirection ...
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
//
|
||||
// Using Cors ...
|
||||
// Use Storage Service (Prepare Folders + Static Files) ...
|
||||
// Must be before Routing so Static Files Short Circuit Pipeline ...
|
||||
app.UseXStorageService();
|
||||
|
||||
//
|
||||
// Use Swagger Middleware (Only in Development) ...
|
||||
if (isDevelopmentEnvironment)
|
||||
{
|
||||
app.UseXSwagger();
|
||||
}
|
||||
|
||||
//
|
||||
// Using Cors (before Proxy so Browser Requests get CORS Headers) ...
|
||||
app.UseXCors();
|
||||
|
||||
//
|
||||
// Enable Model Proxy ...
|
||||
// Enable Model Proxy (Handles its own Authentication) ...
|
||||
app.UseXAiModelProxy();
|
||||
|
||||
//
|
||||
@@ -232,7 +247,7 @@ namespace xAiApi
|
||||
app.UseRouting();
|
||||
|
||||
//
|
||||
// Use xIdentityService ...
|
||||
// Use xIdentityService (Authentication) ...
|
||||
app.UseXIdentityService();
|
||||
|
||||
//
|
||||
@@ -246,11 +261,7 @@ namespace xAiApi
|
||||
});
|
||||
|
||||
//
|
||||
// Use Storage Service ...
|
||||
app.UseXStorageService();
|
||||
|
||||
//
|
||||
// Use PushService ...
|
||||
// Use PushService (Legacy UseSignalR -> Registers its own Router) ...
|
||||
var pushHelper = new XPushServiceHelper();
|
||||
app.UseXPushService(pushHelper);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user