Skip to content

Commit b3be849

Browse files
authored
Merge pull request #919 from neozhu/feature/ai-chatbot
feat: Add AI Chatbot Feature with OpenAI Integration
2 parents 65d2381 + a785350 commit b3be849

9 files changed

Lines changed: 412 additions & 14 deletions

File tree

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ services:
1616
- DatabaseSettings__DBProvider=${DB_PROVIDER}
1717
- DatabaseSettings__ConnectionString=${DB_CONNECTION_STRING}
1818
- AISettings__GeminiApiKey=${GEMINI_API_KEY}
19+
- AISettings__OpenAIApiKey=${OPENAI_API_KEY}
1920
- SmtpClientOptions__UserName=${SMTP_USERNAME}
2021
- SmtpClientOptions__Port=${SMTP_PORT}
2122
- SmtpClientOptions__Host=${SMTP_HOST}

src/Application/Common/Interfaces/IAISettings.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace CleanArchitecture.Blazor.Application.Common.Interfaces;
1+
namespace CleanArchitecture.Blazor.Application.Common.Interfaces;
22

33
/// <summary>
44
/// AI configuration settings interface
@@ -9,4 +9,8 @@ public interface IAISettings
99
/// Gets the Gemini API key
1010
/// </summary>
1111
string GeminiApiKey { get; }
12-
}
12+
/// <summary>
13+
/// Gets the API key used to authenticate requests to the OpenAI service.
14+
/// </summary>
15+
string OpenAIApiKey { get; }
16+
}

src/Infrastructure/Configurations/AISettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@ public class AISettings : IAISettings
1919
/// Gets or sets the Gemini API key
2020
/// </summary>
2121
public string GeminiApiKey { get; set; } = string.Empty;
22+
23+
/// <summary>
24+
/// Gets or sets the API key used to authenticate requests to the OpenAI service.
25+
/// </summary>
26+
/// <remarks>The API key must be valid and authorized for the intended OpenAI operations. Storing
27+
/// sensitive credentials such as API keys should be done securely to prevent unauthorized access.</remarks>
28+
public string OpenAIApiKey { get; set; } = string.Empty;
2229
}

src/Server.UI/DependencyInjection.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
using MudBlazor.Services;
2323
using QuestPDF;
2424
using QuestPDF.Infrastructure;
25+
using Betalgo.Ranul.OpenAI.Extensions;
2526

2627

2728

@@ -103,6 +104,9 @@ public static IServiceCollection AddServerUI(this IServiceCollection services, I
103104
c.DefaultRequestHeaders.Add("x-goog-api-key", aiSettings.GeminiApiKey);
104105

105106
});
107+
services.AddOpenAIService(s => {
108+
s.ApiKey = config.GetValue<string>("AISettings:OpenAIApiKey")??string.Empty;
109+
});
106110
services.AddScoped<LocalTimeOffset>();
107111
services.AddScoped<HubClient>();
108112
services

0 commit comments

Comments
 (0)