Skip to content

Commit f2ffcab

Browse files
committed
Locking LogConversation when set centrally
1 parent 6f32fd4 commit f2ffcab

File tree

5 files changed

+51
-6
lines changed

5 files changed

+51
-6
lines changed

FetchXmlBuilder/DockControls/AiChatControl.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public partial class AiChatControl : WeifenLuo.WinFormsUI.Docking.DockContent
3232
private Stopwatch callingstopwatch;
3333
private Dictionary<string, List<MetadataForAIAttribute>> metaAttributes = new Dictionary<string, List<MetadataForAIAttribute>>();
3434
private string logname = "AI";
35+
private bool logconversation = false;
3536
private int manualcalls = 0; // Counts the number of calls made by the user in this session
3637
private static List<AiUser> freeusers;
3738

@@ -108,6 +109,7 @@ internal void Initialize()
108109
{
109110
apikey = fxb.settings.AiSettings.ApiKey;
110111
}
112+
logconversation = model.LogConversation ?? fxb.settings.AiSettings.LogConversation;
111113
chatHistory = new ChatMessageHistory(panAiConversation, supplier?.Name, model?.Endpoint, model?.Name, apikey, fxb.settings.AiSettings.MyName);
112114
metaAttributes.Clear();
113115
SetTitle();
@@ -490,7 +492,7 @@ private void Log(string action, double? count = null, double? duration = null, l
490492
{
491493
ai = new AIAppInsights(fxb, OnlineSettings.Instance.AiSupport.AppRegistrationEndpoint, OnlineSettings.Instance.AiSupport.InstrumentationKey, supplier.Name, model.Name);
492494
}
493-
ai.WriteEvent($"{action}", count ?? msg?.Length, duration, tokensout, tokensin, fxb.settings.AiSettings.LogConversation ? msg : null);
495+
ai.WriteEvent($"{action}", count ?? msg?.Length, duration, tokensout, tokensin, logconversation ? msg : null);
494496
}
495497

496498
#endregion Private Methods

FetchXmlBuilder/Forms/Settings.Designer.cs

Lines changed: 19 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

FetchXmlBuilder/Forms/Settings.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,17 @@ private void cmbAiModel_SelectedIndexChanged(object sender = null, EventArgs e =
379379
LoadAiSettingsKey();
380380
}
381381
txtAiApiKey.Enabled = !supplier.Free;
382+
if (model.LogConversation != null)
383+
{
384+
chkAiLogConversation.Checked = model.LogConversation.Value;
385+
chkAiLogConversation.Enabled = false;
386+
tt.SetToolTip(picAiLogConversation, $"The setting for logging conversations is determined by{Environment.NewLine}Supplier: {supplier} and{Environment.NewLine}Model: {model}{Environment.NewLine}and cannot be changed manually.");
387+
}
388+
else
389+
{
390+
chkAiLogConversation.Enabled = true;
391+
tt.SetToolTip(picAiLogConversation, $"If checked, the conversation will be logged to Application Insights.");
392+
}
382393
}
383394
else
384395
{
@@ -412,9 +423,12 @@ private void linkLogFolder_LinkClicked(object sender, LinkLabelLinkClickedEventA
412423
Process.Start("explorer.exe", linkAiLogFolder.Text);
413424
}
414425

415-
private void picAiLogFolder_Click(object sender, EventArgs e)
426+
private void picAiLog_Click(object sender, EventArgs e)
416427
{
417-
MessageBoxEx.Show(this, tt.GetToolTip(picAiLogFolder), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
428+
if (sender is PictureBox pic)
429+
{
430+
MessageBoxEx.Show(this, tt.GetToolTip(pic), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
431+
}
418432
}
419433
}
420434
}

FetchXmlBuilder/Forms/Settings.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@
120120
<metadata name="tt.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121121
<value>17, 17</value>
122122
</metadata>
123+
<data name="picAiLogConversation.ToolTip" xml:space="preserve">
124+
<value>Every session in the conversation to the AI is stored in this folder.
125+
The conversation is not only what you can see in the UI,
126+
but also internal messages back and forth, e.g. the metadata
127+
that the AI may need.
128+
This logging is not used by the tool, you may clean the
129+
folder whenever you want to, this is just to give you the
130+
opportunity to learn even more, to see what the AI is asking
131+
the tool about.
132+
Note that this type of detail logs are only stored locally, not
133+
in any external system!</value>
134+
</data>
123135
<data name="picAiLogFolder.ToolTip" xml:space="preserve">
124136
<value>Every session in the conversation to the AI is stored in this folder.
125137
The conversation is not only what you can see in the UI,

Rappen.XTB.Helper

0 commit comments

Comments
 (0)