Changes
Build and Push Docker Images / build (push) Failing after 1s

This commit is contained in:
2026-05-06 19:58:29 +03:00
parent ebe4e449ad
commit bc85a450e5
15 changed files with 50 additions and 45 deletions
+14
View File
@@ -0,0 +1,14 @@
using System.Security.Cryptography;
using System.Text;
namespace CommonHelpers
{
public static class HashHelper
{
public static string Compute(string value)
{
using var sha = SHA256.Create();
return Convert.ToHexString(sha.ComputeHash(Encoding.UTF8.GetBytes(value ?? string.Empty)));
}
}
}
+10
View File
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<RootNamespace>CommonHelpers</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
-13
View File
@@ -1,13 +0,0 @@
using System.Security.Cryptography;
using System.Text;
namespace Api.Clients.Ai;
public static class HashHelper
{
public static string Compute(string value)
{
using var sha = SHA256.Create();
return Convert.ToHexString(sha.ComputeHash(Encoding.UTF8.GetBytes(value ?? string.Empty)));
}
}
@@ -4,6 +4,7 @@ using System.Text.Json;
using System.Text.Json.Serialization;
using Api.Clients.Ai.Contracts;
using Api.Data.Repositories.Contracts;
using CommonHelpers;
using CvMatcher.Models.Settings;
using Microsoft.Extensions.Options;
+2
View File
@@ -5,6 +5,7 @@ WORKDIR /src
COPY cv-matcher-api/cv-matcher-api.csproj cv-matcher-api/
COPY shared-models/shared-models.csproj shared-models/
COPY cv-matcher-api-models/cv-matcher-api-models.csproj cv-matcher-api-models/
COPY common-helpers/ common-helpers/
COPY startup-helpers/startup-helpers.csproj startup-helpers/
RUN dotnet restore cv-matcher-api/cv-matcher-api.csproj
@@ -12,6 +13,7 @@ RUN dotnet restore cv-matcher-api/cv-matcher-api.csproj
COPY cv-matcher-api/ cv-matcher-api/
COPY shared-models/ shared-models/
COPY cv-matcher-api-models/ cv-matcher-api-models/
COPY common-helpers/ common-helpers/
COPY startup-helpers/ startup-helpers/
RUN dotnet publish cv-matcher-api/cv-matcher-api.csproj -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
+1
View File
@@ -77,6 +77,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\common-helpers\common-helpers.csproj" />
<ProjectReference Include="..\cv-matcher-api-models\cv-matcher-api-models.csproj" />
<ProjectReference Include="..\shared-models\shared-models.csproj" />
<ProjectReference Include="..\startup-helpers\startup-helpers.csproj" />
+7
View File
@@ -28,6 +28,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Helpers", "Helpers", "{43E9
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "startup-helpers", "startup-helpers\startup-helpers.csproj", "{7446D193-8636-4E58-96E4-0C8CB8790679}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "common-helpers", "common-helpers\common-helpers.csproj", "{4EDDEE9A-E9C7-4972-9C4A-3177611CCFE3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -74,6 +76,10 @@ Global
{7446D193-8636-4E58-96E4-0C8CB8790679}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7446D193-8636-4E58-96E4-0C8CB8790679}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7446D193-8636-4E58-96E4-0C8CB8790679}.Release|Any CPU.Build.0 = Release|Any CPU
{4EDDEE9A-E9C7-4972-9C4A-3177611CCFE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4EDDEE9A-E9C7-4972-9C4A-3177611CCFE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4EDDEE9A-E9C7-4972-9C4A-3177611CCFE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4EDDEE9A-E9C7-4972-9C4A-3177611CCFE3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -87,6 +93,7 @@ Global
{6A1ADA81-28E9-4A64-A32D-0755876D5EB7} = {E08A1D43-24A3-4F93-B66A-4230FD8261BA}
{185A8BB0-344A-4856-AEB4-213866EB2EE7} = {E08A1D43-24A3-4F93-B66A-4230FD8261BA}
{7446D193-8636-4E58-96E4-0C8CB8790679} = {43E9CD21-25B6-4CB4-B94E-5B953B2E1284}
{4EDDEE9A-E9C7-4972-9C4A-3177611CCFE3} = {43E9CD21-25B6-4CB4-B94E-5B953B2E1284}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6246A67B-299E-4E64-8DBE-1A66771E7C67}
@@ -2,18 +2,19 @@ using Microsoft.Extensions.Options;
using Rag.Models.Settings;
using Api.Data.Repositories.Contracts;
using Api.Clients.Ai.Contracts;
using CommonHelpers;
namespace Api.Clients.Ai;
public sealed class CachedAiClient : IAiClient
public sealed class CachedRagAiClient : IAiClient
{
private readonly RawAiClient _raw;
private readonly RagAiClient _client;
private readonly IRagRepository _repository;
private readonly AiSettings _settings;
public CachedAiClient(RawAiClient raw, IRagRepository repository, IOptions<AiSettings> options)
public CachedRagAiClient(RagAiClient client, IRagRepository repository, IOptions<AiSettings> options)
{
_raw = raw;
_client = client;
_repository = repository;
_settings = options.Value;
}
@@ -26,7 +27,7 @@ public sealed class CachedAiClient : IAiClient
var cached = await _repository.GetEmbeddingAsync(cacheKey, ct);
if (cached is not null) return cached;
var vector = await _raw.CreateEmbeddingAsync(input, ct);
var vector = await _client.CreateEmbeddingAsync(input, ct);
await _repository.SaveEmbeddingAsync(cacheKey, model, textHash, vector, ct);
return vector;
}
@@ -38,7 +39,7 @@ public sealed class CachedAiClient : IAiClient
var cached = await _repository.GetChatCompletionAsync(cacheKey, ct);
if (cached is not null) return cached;
var response = await _raw.CreateChatCompletionAsync(systemPrompt, userPrompt, temperature, ct);
var response = await _client.CreateChatCompletionAsync(systemPrompt, userPrompt, temperature, ct);
await _repository.SaveChatCompletionAsync(cacheKey, model, temperature, response, ct);
return response;
}
-14
View File
@@ -1,14 +0,0 @@
using System.Security.Cryptography;
using System.Text;
namespace Api.Clients.Ai;
public static class HashHelper
{
public static string Compute(string value)
{
using var sha = SHA256.Create();
var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(value ?? string.Empty));
return Convert.ToHexString(bytes);
}
}
@@ -8,7 +8,7 @@ using Api.Clients.Ai.Contracts;
namespace Api.Clients.Ai;
public sealed class RawAiClient : IAiClient
public sealed class RagAiClient : IAiClient
{
private readonly HttpClient _http;
private readonly AiSettings _settings;
@@ -17,7 +17,7 @@ public sealed class RawAiClient : IAiClient
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
public RawAiClient(HttpClient http, IOptions<AiSettings> options)
public RagAiClient(HttpClient http, IOptions<AiSettings> options)
{
_http = http;
_settings = options.Value;
+2
View File
@@ -5,6 +5,7 @@ WORKDIR /src
COPY rag-api/rag-api.csproj rag-api/
COPY shared-models/shared-models.csproj shared-models/
COPY rag-api-models/rag-api-models.csproj rag-api-models/
COPY common-helpers/common-helpers.csproj common-helpers/
COPY startup-helpers/startup-helpers.csproj startup-helpers/
RUN dotnet restore rag-api/rag-api.csproj
@@ -13,6 +14,7 @@ COPY rag-api/ rag-api/
COPY shared-models/ shared-models/
COPY rag-api-models/ rag-api-models/
COPY shared-models/ shared-models/
COPY common-helpers/ common-helpers/
COPY startup-helpers/ startup-helpers/
RUN dotnet publish rag-api/rag-api.csproj -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
+2 -2
View File
@@ -34,9 +34,9 @@ try
options.UseSqlServer(builder.Configuration.GetConnectionString("RagDb")
?? throw new InvalidOperationException("Connection string 'RagDb' is missing.")));
builder.Services.AddHttpClient<RawAiClient>();
builder.Services.AddHttpClient<RagAiClient>();
builder.Services.AddScoped<IRagRepository, EfRagRepository>();
builder.Services.AddScoped<IAiClient, CachedAiClient>();
builder.Services.AddScoped<IAiClient, CachedRagAiClient>();
builder.Services.AddSingleton<ITextExtractor, TextExtractor>();
builder.Services.AddSingleton<ITextChunker, TextChunker>();
builder.Services.AddSingleton<IDocumentClassifier, DocumentClassifier>();
+1 -1
View File
@@ -6,8 +6,8 @@ using Rag.Models.Responses;
using Rag.Models.Settings;
using Api.Data.Repositories.Contracts;
using Api.Clients.Ai.Contracts;
using Api.Clients.Ai;
using Rag.Models;
using CommonHelpers;
namespace Api.Services;
+1
View File
@@ -77,6 +77,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\common-helpers\common-helpers.csproj" />
<ProjectReference Include="..\rag-api-models\rag-api-models.csproj" />
<ProjectReference Include="..\shared-models\shared-models.csproj" />
<ProjectReference Include="..\startup-helpers\startup-helpers.csproj" />
-7
View File
@@ -1,7 +0,0 @@
namespace startup_helpers
{
public class Class1
{
}
}