add architecture skeleton
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using GymLogAI.Application.DTOs;
|
||||
using GymLogAI.Application.Interfaces;
|
||||
|
||||
namespace GymLogAI.AI;
|
||||
|
||||
public sealed class WorkoutParserAIService(OpenRouterChatClient chatClient) : IWorkoutParser
|
||||
{
|
||||
public async Task<ParsedWorkoutDto?> ParseAsync(string text, CancellationToken cancellationToken)
|
||||
{
|
||||
await chatClient.CompleteAsync($"Parse workout:\n{text}", cancellationToken);
|
||||
|
||||
var lines = text
|
||||
.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||
.ToArray();
|
||||
|
||||
if (lines.Length == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var exercises = lines
|
||||
.Select((line, index) => new ParsedExerciseDto(
|
||||
line,
|
||||
index + 1,
|
||||
null,
|
||||
[new ParsedExerciseSetDto(1, 10, null, null, null, "Stub set")]))
|
||||
.ToArray();
|
||||
|
||||
return new ParsedWorkoutDto(
|
||||
DateTime.UtcNow,
|
||||
"Imported workout",
|
||||
"Stubbed parser result",
|
||||
exercises);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user