last ...
This commit is contained in:
@@ -34,7 +34,7 @@ namespace xAiApi.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default AI Service ...
|
/// Default AI Service ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IXDefaultAiService aiService;
|
private readonly IXAiService aiService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Text Chunker Service ...
|
/// Text Chunker Service ...
|
||||||
@@ -62,8 +62,8 @@ namespace xAiApi.Controllers
|
|||||||
private readonly IXFileContentExtractor fileContentExtractor;
|
private readonly IXFileContentExtractor fileContentExtractor;
|
||||||
|
|
||||||
public ChatWithDocumentsController(
|
public ChatWithDocumentsController(
|
||||||
|
IXAiService aiService,
|
||||||
IXTextChunker textChunker,
|
IXTextChunker textChunker,
|
||||||
IXDefaultAiService aiService,
|
|
||||||
IXInMemoryVectorStore vectorStore,
|
IXInMemoryVectorStore vectorStore,
|
||||||
XAppConfiguration appConfiguration,
|
XAppConfiguration appConfiguration,
|
||||||
IXIdentityProvider identityProvider,
|
IXIdentityProvider identityProvider,
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ namespace xAiApi.Controllers
|
|||||||
{
|
{
|
||||||
[Authorize]
|
[Authorize]
|
||||||
[Route("[controller]")]
|
[Route("[controller]")]
|
||||||
public class DefaultAiController : XAiServiceControllerBase<IXDefaultAiService>
|
public class XAiController : XAiServiceControllerBase<IXAiService>
|
||||||
{
|
{
|
||||||
public DefaultAiController(
|
public XAiController(
|
||||||
ILogger<DefaultAiController> logger,
|
ILogger<XAiController> logger,
|
||||||
IXDefaultAiService aiService,
|
IXAiService aiService,
|
||||||
XAppConfiguration appConfiguration,
|
XAppConfiguration appConfiguration,
|
||||||
IXIdentityProvider identityProvider,
|
IXIdentityProvider identityProvider,
|
||||||
XValidationProvider validationProvider
|
XValidationProvider validationProvider
|
||||||
@@ -96,7 +96,7 @@ namespace xAiApi.DI
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
source.AddScoped<IXDefaultAiService, XDefaultAiService>();
|
source.AddScoped<IXAiService, XAiService>();
|
||||||
source.AddScoped<IXDefaultThinkingAiService, XDefaultThinkingAiService>();
|
source.AddScoped<IXDefaultThinkingAiService, XDefaultThinkingAiService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
namespace xAiApi.Interfaces
|
||||||
|
{
|
||||||
|
public interface IXAiService : IXAiServiceBase
|
||||||
|
{ }
|
||||||
|
}
|
||||||
@@ -51,53 +51,46 @@ namespace xAiApi.Interfaces
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prepare a Message History List for LLM Communication based on Prompt ...
|
/// Ask a Question as Prompt and Retrieve Response ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="prompt"></param>
|
/// <param name="prompt"></param>
|
||||||
/// <param name="forcePrompt"></param>
|
/// <param name="ownerId"></param>
|
||||||
/// <returns></returns>
|
/// <param name="projectId"></param>
|
||||||
IList<ChatMessage> GetHistory(
|
/// <param name="conversationId"></param>
|
||||||
string prompt = null,
|
/// <param name="connectionId"></param>
|
||||||
bool forcePrompt = true
|
/// <param name="files"></param>
|
||||||
);
|
/// <param name="userInfo"></param>
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Prepare a Message History List for LLM Communication based on Prompt ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message"></param>
|
|
||||||
/// <param name="forceMessage"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
IList<ChatMessage> GetHistory(
|
|
||||||
ChatMessage message = null,
|
|
||||||
bool forceMessage = true
|
|
||||||
);
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
//
|
|
||||||
#region Context Actions ...
|
|
||||||
/// <summary>
|
|
||||||
/// Ask a Question using Provided Context Chunks (RAG) without Persisting ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="prompt"></param>
|
|
||||||
/// <param name="context"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<string> AskWithContextAsync(
|
Task<XAiMessageDto> AskAsync(
|
||||||
string prompt,
|
string prompt,
|
||||||
IEnumerable<XAiVectorSearchResult> context,
|
string ownerId,
|
||||||
|
Guid? projectId,
|
||||||
|
Guid? conversationId,
|
||||||
|
string connectionId = null,
|
||||||
|
IFormFileCollection files = null,
|
||||||
|
XUserClaimsInfoDto userInfo = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ask a Question using Provided Context Chunks (RAG) and Stream Response ...
|
/// Ask a Question as Prompt and Retrieve Response as Async Enumerable ...
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="prompt"></param>
|
/// <param name="prompt"></param>
|
||||||
/// <param name="context"></param>
|
/// <param name="ownerId"></param>
|
||||||
|
/// <param name="projectId"></param>
|
||||||
|
/// <param name="conversationId"></param>
|
||||||
|
/// <param name="connectionId"></param>
|
||||||
|
/// <param name="files"></param>
|
||||||
/// <param name="cancellationToken"></param>
|
/// <param name="cancellationToken"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
IAsyncEnumerable<string> AskWithContextAsEnumerable(
|
IAsyncEnumerable<XAiResonseMessage> AskAsEnumerable(
|
||||||
string prompt,
|
string prompt,
|
||||||
IEnumerable<XAiVectorSearchResult> context,
|
string ownerId,
|
||||||
|
Guid projectId,
|
||||||
|
Guid conversationId,
|
||||||
|
string connectionId = null,
|
||||||
|
IFormFileCollection files = null,
|
||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
@@ -240,52 +233,5 @@ namespace xAiApi.Interfaces
|
|||||||
CancellationToken cancellationToken = default
|
CancellationToken cancellationToken = default
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
//
|
|
||||||
#region Data Actions ...
|
|
||||||
/// <summary>
|
|
||||||
/// Ask a Question as Prompt and Retrieve Response ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="prompt"></param>
|
|
||||||
/// <param name="ownerId"></param>
|
|
||||||
/// <param name="projectId"></param>
|
|
||||||
/// <param name="conversationId"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <param name="files"></param>
|
|
||||||
/// <param name="userInfo"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
Task<XAiMessageDto> AskAsync(
|
|
||||||
string prompt,
|
|
||||||
string ownerId,
|
|
||||||
Guid? projectId,
|
|
||||||
Guid? conversationId,
|
|
||||||
string connectionId = null,
|
|
||||||
IFormFileCollection files = null,
|
|
||||||
XUserClaimsInfoDto userInfo = null,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Ask a Question as Prompt and Retrieve Response as Async Enumerable ...
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="prompt"></param>
|
|
||||||
/// <param name="ownerId"></param>
|
|
||||||
/// <param name="projectId"></param>
|
|
||||||
/// <param name="conversationId"></param>
|
|
||||||
/// <param name="connectionId"></param>
|
|
||||||
/// <param name="files"></param>
|
|
||||||
/// <param name="cancellationToken"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
IAsyncEnumerable<XAiResonseMessage> AskAsEnumerable(
|
|
||||||
string prompt,
|
|
||||||
string ownerId,
|
|
||||||
Guid projectId,
|
|
||||||
Guid conversationId,
|
|
||||||
string connectionId = null,
|
|
||||||
IFormFileCollection files = null,
|
|
||||||
CancellationToken cancellationToken = default
|
|
||||||
);
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
namespace xAiApi.Interfaces
|
|
||||||
{
|
|
||||||
public interface IXDefaultAiService : IXAiServiceBase
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
+417
-548
File diff suppressed because it is too large
Load Diff
@@ -8,12 +8,12 @@ using xAiApi.Interfaces.Extractors;
|
|||||||
|
|
||||||
namespace xAiApi.Providers
|
namespace xAiApi.Providers
|
||||||
{
|
{
|
||||||
public class XDefaultAiService : XAIServiceBase, IXDefaultAiService
|
public class XAiService : XAIServiceBase, IXAiService
|
||||||
{
|
{
|
||||||
public XDefaultAiService(
|
public XAiService(
|
||||||
IXAiRAGService ragProvider,
|
IXAiRAGService ragProvider,
|
||||||
IXAiDataProvider dataProvider,
|
IXAiDataProvider dataProvider,
|
||||||
ILogger<XDefaultAiService> logger,
|
ILogger<XAiService> logger,
|
||||||
XAiApiConfiguration configuration,
|
XAiApiConfiguration configuration,
|
||||||
XValidationProvider validationProvider,
|
XValidationProvider validationProvider,
|
||||||
IXFileContentExtractor fileContentExtractor
|
IXFileContentExtractor fileContentExtractor
|
||||||
Reference in New Issue
Block a user