Skip to content

Commit 0a2781f

Browse files
committed
Bug Fixes
1 parent 9075036 commit 0a2781f

12 files changed

+3724
-58
lines changed

AboutBox.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Drawing;
5-
using System.Linq;
62
using System.Reflection;
7-
using System.Threading.Tasks;
83
using System.Windows.Forms;
94

105
namespace TextForge

Forge.Designer.cs

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

Forge.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,23 @@ namespace TextForge
1919
public partial class Forge
2020
{
2121
// Public
22-
public static SystemChatMessage SystemPrompt { get { return _systemPrompt; } }
22+
public static readonly SystemChatMessage SystemPrompt = new SystemChatMessage("You are an expert writing assistant and editor, specialized in enhancing the clarity, coherence, and impact of text within a document. You analyze text critically and provide constructive feedback to improve the overall quality.");
2323

2424
// Private
25-
private static readonly SystemChatMessage _systemPrompt = new SystemChatMessage("You are an expert writing assistant and editor, specialized in enhancing the clarity, coherence, and impact of text within a document. You analyze text critically and provide constructive feedback to improve the overall quality.");
26-
27-
private CustomTaskPane _generateTaskPane;
28-
private CustomTaskPane _ragControlTaskPane;
29-
3025
private AboutBox _box;
3126
private static RibbonGroup _optionsBox;
3227

33-
private Dictionary<string, string> buttonIdPairs = new Dictionary<string, string>();
28+
private CustomTaskPane _generateTaskPane;
29+
private CustomTaskPane _ragControlTaskPane;
3430

3531
private void Forge_Load(object sender, RibbonUIEventArgs e)
3632
{
3733
try
3834
{
39-
_generateTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(new GenerateUserControl(), this.GenerateButton.Label);
40-
_ragControlTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(ThisAddIn.RagControl, this.RAGControlButton.Label);
35+
if (!ThisAddIn.IsAddinInitialized)
36+
ThisAddIn.InitializeAddin();
4137

42-
ModelClient modelRetriever = new ModelClient(ThisAddIn.ApiKey, ThisAddIn.ClientOptions);
43-
List<string> models = GetModels(modelRetriever);
38+
List<string> models = new List<string>(ThisAddIn.ModelList);
4439

4540
// Remove embedding models from the list
4641
var copyList = new List<string>(models);
@@ -62,12 +57,17 @@ private void Forge_Load(object sender, RibbonUIEventArgs e)
6257
ModelListDropDown.Items.Add(newItem);
6358

6459
if (model == ThisAddIn.Model)
60+
{
6561
ModelListDropDown.SelectedItem = newItem;
62+
UpdateCheckbox();
63+
}
6664
}
67-
UpdateCheckbox();
6865

6966
_box = new AboutBox();
7067
_optionsBox = this.OptionsGroup;
68+
69+
_generateTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(new GenerateUserControl(), this.GenerateButton.Label);
70+
_ragControlTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(ThisAddIn.RagControl, this.RAGControlButton.Label);
7171
} catch (Exception ex)
7272
{
7373
MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -310,7 +310,7 @@ private static AsyncCollectionResult<StreamingChatCompletionUpdate> Review(Word.
310310
UserChatMessage userPrompt = new UserChatMessage($@"Document Content: ""{RAGControl.SubstringWithoutBounds(allText, (int)(ThisAddIn.ContextLength * 0.4))}""{Environment.NewLine}RAG Context: ""{ThisAddIn.RagControl.GetRAGContext(p.Text, (int)(ThisAddIn.ContextLength * 0.3))}""{Environment.NewLine}Please review the following paragraph extracted from the Document: ""{RAGControl.SubstringWithoutBounds(p.Text, (int)(ThisAddIn.ContextLength * 0.2))}""{Environment.NewLine}{prompt}");
311311

312312
ChatClient client = new ChatClient(ThisAddIn.Model, ThisAddIn.ApiKey, ThisAddIn.ClientOptions);
313-
return client.CompleteChatStreamingAsync(new List<ChatMessage> { _systemPrompt, userPrompt }, null, ThisAddIn.CancellationTokenSource.Token);
313+
return client.CompleteChatStreamingAsync(new List<ChatMessage> { SystemPrompt, userPrompt }, null, ThisAddIn.CancellationTokenSource.Token);
314314
}
315315
}
316316
}

0 commit comments

Comments
 (0)