- 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.
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using xAiModels.Models.Dtos;
|
|
using Microsoft.Extensions.AI;
|
|
using System.Collections.Generic;
|
|
|
|
namespace xAiApi.Models
|
|
{
|
|
/// <summary>
|
|
/// a Shared Context Between Actions for Generation ...
|
|
/// </summary>
|
|
public class XPreparedChatContext
|
|
{
|
|
/// <summary>
|
|
/// Specified Related Project, if Exists ...
|
|
/// </summary>
|
|
public XAiProjectDto Project { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Specified Related Conversation, if Exists ...
|
|
/// </summary>
|
|
public XAiConversationDto Conversation { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Specified Message History, if Exists ...
|
|
/// </summary>
|
|
public IList<ChatMessage> History { get; set; } = [];
|
|
|
|
/// <summary>
|
|
/// Specified Vector Search Conext, if Exists ...
|
|
/// </summary>
|
|
public IList<XAiVectorSearchResult> Context { get; set; } = [];
|
|
|
|
/// <summary>
|
|
/// Specified Persisted Prompt, if Exists ...
|
|
/// </summary>
|
|
public XAiMessageDto PersistedPromptMessage { get; set; } = null;
|
|
}
|
|
} |