mirror of
https://github.com/marcominerva/SqlDatabaseVectorSearch.git
synced 2026-06-20 12:23:10 +00:00
Add FluentValidation for Question model validation
- Updated `AskEndpoints.cs` to include `MinimalHelpers.FluentValidation` and standardize endpoint descriptions. - Integrated FluentValidation in `Program.cs` and registered validators. - Modified `SqlDatabaseVectorSearch.csproj` to add necessary package references for FluentValidation. - Created `QuestionValidator` class to enforce validation rules on the `Question` model.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using MinimalHelpers.FluentValidation;
|
||||
using SqlDatabaseVectorSearch.Models;
|
||||
using SqlDatabaseVectorSearch.Services;
|
||||
|
||||
@@ -10,11 +10,12 @@ public class AskEndpoints : IEndpointRouteHandlerBuilder
|
||||
public static void MapEndpoints(IEndpointRouteBuilder endpoints)
|
||||
{
|
||||
endpoints.MapPost("/api/ask", async (Question question, VectorSearchService vectorSearchService, CancellationToken cancellationToken,
|
||||
[Description("If true, the question will be reformulated taking into account the context of the chat identified by the given ConversationId.")] bool reformulate = true) =>
|
||||
[Description("If true, the question will be reformulated taking into account the context of the chat identified by the given ConversationId.")] bool reformulate = true) =>
|
||||
{
|
||||
var response = await vectorSearchService.AskQuestionAsync(question, reformulate, cancellationToken);
|
||||
return TypedResults.Ok(response);
|
||||
})
|
||||
.WithValidation<Question>()
|
||||
.WithSummary("Asks a question")
|
||||
.WithDescription("The question will be reformulated taking into account the context of the chat identified by the given ConversationId.")
|
||||
.WithTags("Ask");
|
||||
@@ -35,6 +36,7 @@ public class AskEndpoints : IEndpointRouteHandlerBuilder
|
||||
|
||||
return Stream();
|
||||
})
|
||||
.WithValidation<Question>()
|
||||
.WithSummary("Asks a question and gets the response as streaming")
|
||||
.WithDescription("The question will be reformulated taking into account the context of the chat identified by the given ConversationId.")
|
||||
.WithTags("Ask");
|
||||
|
||||
Reference in New Issue
Block a user