Skip to content

Commit edf10d7

Browse files
Merge pull request #55 from BlazorData-Net/codex/add-guid-generation-and-display-on-settings-page
Add persistent installation GUID and display on settings page
2 parents a795a8e + 7d432a6 commit edf10d7

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

RFPResponsePOC/RFPResponsePOC.Client/Pages/Settings.razor

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
<RadzenDropDown @bind-Value="@AIModel" Data="@availableModels" Style="width: 450px;" TValue="string" />
3232
</RadzenFormField>
3333

34+
<RadzenFormField Text="Installation GUID:" Variant="@variant">
35+
<RadzenTextBox Value="@GUID" Style="width:450px;" ReadOnly="true" />
36+
</RadzenFormField>
37+
3438
<div style="display: flex; justify-content: center; align-items: center; gap:10px;">
3539
@if (!IsOpenAISettingsEntered)
3640
{
@@ -124,6 +128,7 @@
124128
private string ApiKey = "";
125129
private string AIModel = "";
126130
private string AIEmbeddingModel = "";
131+
private string GUID = "";
127132
private List<string> availableModels = new List<string> { "o4-mini", "gpt-4o", "gpt-5", "gpt-5-mini" };
128133

129134
bool ZipFileExists = false;
@@ -150,6 +155,7 @@
150155

151156
ApiKey = SettingsService.Settings.ApplicationSettings.ApiKey ?? "";
152157
AIModel = SettingsService.Settings.ApplicationSettings.AIModel;
158+
GUID = SettingsService.Settings.ApplicationSettings.GUID;
153159

154160
IsOpenAISettingsEntered = ApiKey.Length > 1;
155161

RFPResponsePOC/RFPResponsePOC.Client/Services/SettingsService.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Newtonsoft.Json;
33
using OpenAI.Files;
44
using System.Text.Json.Serialization;
5+
using System;
56

67
namespace RFPResponseAPP.Model
78
{
@@ -13,6 +14,7 @@ public class ApplicationSettings
1314
public string AIModel { get; set; }
1415
public string ApiKey { get; set; }
1516
public string AIEmbeddingModel { get; set; }
17+
public string GUID { get; set; }
1618
}
1719

1820
public enum ConnectionType
@@ -105,6 +107,13 @@ public async void LoadSettings()
105107
{
106108
Settings.ConnectionSettings = new List<ConnectionSettings>();
107109
}
110+
111+
// Ensure a GUID exists
112+
if (string.IsNullOrEmpty(Settings.ApplicationSettings.GUID))
113+
{
114+
Settings.ApplicationSettings.GUID = Guid.NewGuid().ToString();
115+
await SaveSettingsAsync();
116+
}
108117
}
109118
catch (Exception ex)
110119
{
@@ -186,7 +195,8 @@ public async Task InitializeDefaultSettingsAsync()
186195
{
187196
ApiKey = "",
188197
AIModel = "gpt-5-mini",
189-
AIEmbeddingModel = "text-embedding-ada-002"
198+
AIEmbeddingModel = "text-embedding-ada-002",
199+
GUID = Guid.NewGuid().ToString()
190200
},
191201
ConnectionSettings = new List<ConnectionSettings>()
192202
};

RFPResponsePOC/RFPResponsePOC/RFPResponsePOC/RFPResponsePOC.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"ApplicationSettings": {
33
"AIModel": "DefaultAIModel",
44
"ApiKey": null,
5+
"GUID": null,
56
"AIType": "OpenAI",
67
"Endpoint": "https://api.openai.com",
78
"ApiVersion": "v1",

0 commit comments

Comments
 (0)