@@ -0,0 +1,7 @@
|
||||
namespace Api.Services.Contracts.Rag;
|
||||
|
||||
public interface IAiRagClient
|
||||
{
|
||||
Task<float[]> CreateEmbeddingAsync(string input, CancellationToken ct);
|
||||
Task<string> CreateChatCompletionAsync(string systemPrompt, string userPrompt, CancellationToken ct);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using Api.Models.Rag;
|
||||
|
||||
namespace api.Services.Contracts.Rag;
|
||||
|
||||
public interface ICvRagService
|
||||
{
|
||||
Task<CvIngestResponse> IngestCvAsync(IFormFile file, bool gdprConsent, CancellationToken ct);
|
||||
Task<JobMatchResponse> MatchJobAsync(JobMatchRequest request, CancellationToken ct);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Api.Services.Contracts.Rag;
|
||||
|
||||
public interface IJobTextExtractor
|
||||
{
|
||||
Task<string> ExtractAsync(string? jobUrl, string? jobDescription, CancellationToken ct);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Api.Services.Contracts.Rag;
|
||||
|
||||
public interface IPdfTextExtractor
|
||||
{
|
||||
string ExtractText(Stream pdfStream);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Api.Services.Contracts.Rag;
|
||||
|
||||
public interface ITextChunker
|
||||
{
|
||||
IReadOnlyList<string> Chunk(string text, int chunkSize, int overlap);
|
||||
}
|
||||
@@ -1,21 +1,17 @@
|
||||
using api.Services.Contracts.Rag;
|
||||
using Api.Models.Rag;
|
||||
using Api.Services.Contracts.Rag;
|
||||
using Api.Settings;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Api.Services.Rag;
|
||||
|
||||
public interface ICvRagService
|
||||
{
|
||||
Task<CvIngestResponse> IngestCvAsync(IFormFile file, bool gdprConsent, CancellationToken ct);
|
||||
Task<JobMatchResponse> MatchJobAsync(JobMatchRequest request, CancellationToken ct);
|
||||
}
|
||||
|
||||
public sealed class CvRagService : ICvRagService
|
||||
{
|
||||
private readonly IPdfTextExtractor _pdfTextExtractor;
|
||||
private readonly ITextChunker _textChunker;
|
||||
private readonly IOpenAiRagClient _openAi;
|
||||
private readonly IAiRagClient _openAi;
|
||||
private readonly ICvVectorStore _store;
|
||||
private readonly IJobTextExtractor _jobTextExtractor;
|
||||
private readonly RagSettings _settings;
|
||||
@@ -24,7 +20,7 @@ public sealed class CvRagService : ICvRagService
|
||||
public CvRagService(
|
||||
IPdfTextExtractor pdfTextExtractor,
|
||||
ITextChunker textChunker,
|
||||
IOpenAiRagClient openAi,
|
||||
IAiRagClient openAi,
|
||||
ICvVectorStore store,
|
||||
IJobTextExtractor jobTextExtractor,
|
||||
IOptions<RagSettings> options,
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using Api.Services.Contracts.Rag;
|
||||
using Api.Settings;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Api.Services.Rag;
|
||||
|
||||
public interface IJobTextExtractor
|
||||
{
|
||||
Task<string> ExtractAsync(string? jobUrl, string? jobDescription, CancellationToken ct);
|
||||
}
|
||||
|
||||
public sealed class JobTextExtractor : IJobTextExtractor
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
@@ -2,18 +2,13 @@ using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Api.Services.Contracts.Rag;
|
||||
using Api.Settings;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Api.Services.Rag;
|
||||
|
||||
public interface IOpenAiRagClient
|
||||
{
|
||||
Task<float[]> CreateEmbeddingAsync(string input, CancellationToken ct);
|
||||
Task<string> CreateChatCompletionAsync(string systemPrompt, string userPrompt, CancellationToken ct);
|
||||
}
|
||||
|
||||
public sealed class OpenAiRagClient : IOpenAiRagClient
|
||||
public sealed class OpenAiRagClient : IAiRagClient
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly OpenAiSettings _settings;
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using Api.Services.Contracts.Rag;
|
||||
using System.Text;
|
||||
using UglyToad.PdfPig;
|
||||
|
||||
namespace Api.Services.Rag;
|
||||
|
||||
public interface IPdfTextExtractor
|
||||
{
|
||||
string ExtractText(Stream pdfStream);
|
||||
}
|
||||
|
||||
public sealed class PdfTextExtractor : IPdfTextExtractor
|
||||
{
|
||||
public string ExtractText(Stream pdfStream)
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
namespace Api.Services.Rag;
|
||||
using Api.Services.Contracts.Rag;
|
||||
|
||||
public interface ITextChunker
|
||||
{
|
||||
IReadOnlyList<string> Chunk(string text, int chunkSize, int overlap);
|
||||
}
|
||||
namespace Api.Services.Rag;
|
||||
|
||||
public sealed class TextChunker : ITextChunker
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user