diff --git a/vrcosc-magicchatbox/App.xaml b/vrcosc-magicchatbox/App.xaml
index f6880ef9..6e6e36c4 100644
--- a/vrcosc-magicchatbox/App.xaml
+++ b/vrcosc-magicchatbox/App.xaml
@@ -1013,11 +1013,11 @@
x:Name="PART_Indicator"
HorizontalAlignment="Left"
RadiusX="5"
- RadiusY="5" >
+ RadiusY="5">
-
-
-
+
+
+
diff --git a/vrcosc-magicchatbox/Classes/Modules/IntelliChatModule.cs b/vrcosc-magicchatbox/Classes/Modules/IntelliChatModule.cs
index f7b470a1..cb0b7e7d 100644
--- a/vrcosc-magicchatbox/Classes/Modules/IntelliChatModule.cs
+++ b/vrcosc-magicchatbox/Classes/Modules/IntelliChatModule.cs
@@ -41,7 +41,7 @@ public static async Task PerformSpellingAndGrammarCheckAsync(
{
new Message(
Role.System,
- "Please detect and correct any spelling and grammar errors in the following text:")
+ "Please detect and correct and return any spelling and grammar errors in the following text:")
};
if(languages != null && languages.Any() && !ViewModel.Instance.IntelliChatAutoLang)
@@ -113,6 +113,113 @@ public static async Task PerformBeautifySentenceAsync(
}
}
+ public static async Task GenerateConversationStarterAsync()
+ {
+ if (!OpenAIModule.Instance.IsInitialized)
+ {
+ ViewModel.Instance.ActivateSetting("Settings_OpenAI");
+ return "OpenAI not initialized.";
+ }
+
+ var prompt = "Please generate a short a creative and engaging conversation starter of max 140 characters (this includes spaces), avoid AI. no '";
+
+ var response = await OpenAIModule.Instance.OpenAIClient.ChatEndpoint
+ .GetCompletionAsync(new ChatRequest(new List
+ {
+ new Message(Role.System, prompt)
+ }, maxTokens: 60));
+
+ return response?.Choices?[0].Message.Content.ValueKind == JsonValueKind.String
+ ? response.Choices[0].Message.Content.GetString()
+ : "Unable to generate conversation starter.";
+ }
+
+ public static async Task ShortenTextAsync(string text, int retryCount = 0)
+ {
+ if (!OpenAIModule.Instance.IsInitialized)
+ {
+ ViewModel.Instance.ActivateSetting("Settings_OpenAI");
+ return "OpenAI not initialized.";
+ }
+
+ if (string.IsNullOrWhiteSpace(text))
+ {
+ ViewModel.Instance.IntelliChatRequesting = false;
+ return string.Empty;
+ }
+
+ if (ViewModel.Instance.IntelliChatPerformModeration)
+ {
+ bool moderationResponse = await PerformModerationCheckAsync(text);
+ if (moderationResponse)
+ return string.Empty;
+ }
+
+ string prompt = retryCount == 0
+ ? $"Shorten the following text to 140 characters or less, including spaces: {text}"
+ : $"Please be more concise. Shorten this text to 140 characters or less, including spaces: {text}";
+
+ var response = await OpenAIModule.Instance.OpenAIClient.ChatEndpoint
+ .GetCompletionAsync(new ChatRequest(new List
+ {
+ new Message(Role.System, prompt)
+ }, maxTokens: 60));
+
+ var shortenedText = response?.Choices?[0].Message.Content.ValueKind == JsonValueKind.String
+ ? response.Choices[0].Message.Content.GetString()
+ : string.Empty;
+
+ // Check if the response is still over 140 characters and retry if necessary
+ if (shortenedText.Length > 140 && retryCount < 1) // Limiting to one retry
+ {
+ return await ShortenTextAsync(shortenedText, retryCount + 1);
+ }
+ else
+ {
+ return shortenedText.Length <= 140 ? shortenedText : string.Empty;
+ }
+ }
+
+
+
+ public static async Task PerformLanguageTranslationAutoDetectAsync(
+ string text,
+ SupportedIntelliChatLanguage targetLanguage = SupportedIntelliChatLanguage.English)
+ {
+ if (!OpenAIModule.Instance.IsInitialized)
+ {
+ ViewModel.Instance.ActivateSetting("Settings_OpenAI");
+ return string.Empty;
+ }
+
+ if (string.IsNullOrWhiteSpace(text))
+ {
+ ViewModel.Instance.IntelliChatRequesting = false;
+ return string.Empty;
+ }
+
+ if (ViewModel.Instance.IntelliChatPerformModeration)
+ {
+ bool moderationResponse = await PerformModerationCheckAsync(text);
+ if (moderationResponse)
+ return string.Empty;
+ }
+
+ var messages = new List
+ {
+ new Message(Role.System, $"Translate this to {targetLanguage}:"),
+ new Message(Role.User, text)
+ };
+
+ var response = await OpenAIModule.Instance.OpenAIClient.ChatEndpoint
+ .GetCompletionAsync(new ChatRequest(messages: messages, maxTokens: 120));
+
+ return response?.Choices?[0].Message.Content.ValueKind == JsonValueKind.String
+ ? response.Choices[0].Message.Content.GetString()
+ : response?.Choices?[0].Message.Content.ToString() ?? string.Empty;
+ }
+
+
public static void AcceptIntelliChatSuggestion()
{
ViewModel.Instance.NewChattingTxt = ViewModel.Instance.IntelliChatTxt;
diff --git a/vrcosc-magicchatbox/Classes/XamlCommunication/CharacterCountToBoolConverter.cs b/vrcosc-magicchatbox/Classes/XamlCommunication/CharacterCountToBoolConverter.cs
new file mode 100644
index 00000000..efe06b28
--- /dev/null
+++ b/vrcosc-magicchatbox/Classes/XamlCommunication/CharacterCountToBoolConverter.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace vrcosc_magicchatbox.Classes
+{
+ public class CharacterCountToBoolConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ int characterCount = (int)value;
+ return characterCount > 140;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/vrcosc-magicchatbox/Img/Icons/Cut_ico.png b/vrcosc-magicchatbox/Img/Icons/Cut_ico.png
new file mode 100644
index 00000000..9b21a8eb
Binary files /dev/null and b/vrcosc-magicchatbox/Img/Icons/Cut_ico.png differ
diff --git a/vrcosc-magicchatbox/Img/Icons/Translate_ico.png b/vrcosc-magicchatbox/Img/Icons/Translate_ico.png
new file mode 100644
index 00000000..2060cfb9
Binary files /dev/null and b/vrcosc-magicchatbox/Img/Icons/Translate_ico.png differ
diff --git a/vrcosc-magicchatbox/Img/Icons/Wand_ico.png b/vrcosc-magicchatbox/Img/Icons/Wand_ico.png
new file mode 100644
index 00000000..a068c69b
Binary files /dev/null and b/vrcosc-magicchatbox/Img/Icons/Wand_ico.png differ
diff --git a/vrcosc-magicchatbox/MagicChatbox.csproj b/vrcosc-magicchatbox/MagicChatbox.csproj
index bd94bfd3..f0f495a8 100644
--- a/vrcosc-magicchatbox/MagicChatbox.csproj
+++ b/vrcosc-magicchatbox/MagicChatbox.csproj
@@ -2,7 +2,7 @@
WinExe
- 0.8.756
+ 0.8.757
net6.0-windows10.0.22000.0
vrcosc_magicchatbox
enable
@@ -45,6 +45,7 @@
+
@@ -73,8 +74,10 @@
+
+
@@ -98,6 +101,7 @@
+
@@ -136,10 +140,12 @@
+
+
diff --git a/vrcosc-magicchatbox/MainWindow.xaml b/vrcosc-magicchatbox/MainWindow.xaml
index 32090ec1..64708912 100644
--- a/vrcosc-magicchatbox/MainWindow.xaml
+++ b/vrcosc-magicchatbox/MainWindow.xaml
@@ -37,6 +37,7 @@
+
@@ -57,6 +58,17 @@
+
+
@@ -4623,6 +4635,37 @@
Foreground="#94CCBF"
Opacity="0.3"
Text="n/a" />
+
+
+
+
+
+
+