This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class ValidationPipeline | |
{ | |
private readonly IEnumerable<IValidationStep> _steps; | |
public ValidationPipeline(IEnumerable<IValidationStep> steps) | |
{ | |
_steps = steps; | |
} | |
public async Task<ValidationResult> ValidateAsync(IFormFile file, CancellationToken token) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class ContentTypeValidationStep : IValidationStep | |
{ | |
private readonly SupportedContentTypes _supportedContentTypes; | |
private readonly ILogger _logger; | |
public ContentTypeValidationStep(SupportedContentTypes supportedContentTypes, ILogger logger) | |
{ | |
_supportedContentTypes = supportedContentTypes; | |
_logger = logger; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IValidationStep | |
{ | |
Task<ValidationResult> ValidateAsync(IFormFile file, CancellationToken token); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var agent = new ChatCompletionAgent | |
{ | |
Name = "TravelAgent", | |
Description = "A travel agent that helps users find good travel locations", | |
Instructions = "Help users to find the perfect holiday location.", | |
Kernel = kernel | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var chatHistory = new List<ChatMessage>(); | |
// Minimal API for chat | |
app.MapPost("/api/chat", async (HttpContext context) => | |
{ | |
//Use the IChatClient instance from Semantic Kernel | |
var chatClient=kernel.GetRequiredService<IChatClient>(); | |
var requestBody = await context.Request.ReadFromJsonAsync<ChatRequest>(); | |
if (requestBody == null || string.IsNullOrWhiteSpace(requestBody.Message)) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var kernelBuilder = Kernel.CreateBuilder(); | |
// Add your IChatClient | |
var chatClient = new OllamaApiClient("http://localhost:11434"); | |
chatClient.SelectedModel = "llama3.1:latest"; | |
kernelBuilder.Services.AddChatClient(sp => | |
{ | |
var client = new ChatClientBuilder(chatClient) | |
.UseFunctionInvocation() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class PrimeService | |
{ | |
public bool IsPrime(int possiblePrimeNumber) | |
{ | |
if (possiblePrimeNumber <= 1) | |
return false; | |
for (int i = 2; i <= (int)Math.Sqrt(possiblePrimeNumber); i++) | |
{ | |
if (possiblePrimeNumber % i == 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class prime_Service | |
{ | |
public bool isPrime(int possible_prime_number) | |
{ | |
if (possible_prime_numbe <= 1) | |
return false; | |
for (int i = 2; i <= (int)Math.Sqrt(possible_prime_numbe); i++) | |
{ | |
if (possible_prime_numbe % i == 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool IsPrime(int num) | |
{ | |
if (num <= 1) | |
return false; | |
for (int i = 2; i <= (int)Math.Sqrt(num); i++) | |
{ | |
if (num % i == 0) | |
return false; | |
} | |
return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_prime(num): | |
if num <= 1: | |
return False | |
for i in range(2, int(num ** 0.5) + 1): | |
if num % i == 0: | |
return False | |
return True |
NewerOlder