From c95c5bae38b55e631900f9a39d3ebba2605ea2d2 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Fri, 31 Jan 2025 18:49:44 -0800 Subject: [PATCH] feat: prep for agent release --- .gitignore | 2 ++ App.axaml | 18 +++++++++--------- Styles.axaml | 10 ---------- ViewModels/HomeWindowViewModel.cs | 7 +++++++ ViewModels/MainWindowViewModel.cs | 27 +++++++++++++-------------- Views/AgentWindow.axaml | 8 +------- Views/ConfigWindow.axaml.cs | 2 -- Views/HomeWindow.axaml | 13 +++++++++++++ Views/HomeWindow.axaml.cs | 11 +++++++++++ Views/MainWindow.axaml | 14 -------------- linux-voice-assistant.sln | 24 ++++++++++++++++++++++++ 11 files changed, 80 insertions(+), 56 deletions(-) delete mode 100644 Styles.axaml create mode 100644 ViewModels/HomeWindowViewModel.cs create mode 100644 Views/HomeWindow.axaml create mode 100644 Views/HomeWindow.axaml.cs create mode 100644 linux-voice-assistant.sln diff --git a/.gitignore b/.gitignore index e69de29..0a079b6 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,2 @@ +/bin +/obj \ No newline at end of file diff --git a/App.axaml b/App.axaml index c9f3043..722edff 100644 --- a/App.axaml +++ b/App.axaml @@ -1,15 +1,15 @@ - - + - + - + - \ No newline at end of file + diff --git a/Styles.axaml b/Styles.axaml deleted file mode 100644 index b525d2b..0000000 --- a/Styles.axaml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - diff --git a/ViewModels/HomeWindowViewModel.cs b/ViewModels/HomeWindowViewModel.cs new file mode 100644 index 0000000..d30ea02 --- /dev/null +++ b/ViewModels/HomeWindowViewModel.cs @@ -0,0 +1,7 @@ +namespace app.ViewModels; + +public partial class HomeWindowViewModel : ViewModelBase +{ + + +} diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs index c3a6cf5..66781df 100644 --- a/ViewModels/MainWindowViewModel.cs +++ b/ViewModels/MainWindowViewModel.cs @@ -1,9 +1,11 @@ namespace app.ViewModels; using System; +using System.Threading.Tasks; using System.IO; using System.Text.Json; using System.Collections.Generic; +using System.Net.WebSockets; using Avalonia.Controls; using app.Models; using app.Views; @@ -17,6 +19,7 @@ public partial class MainWindowViewModel : ViewModelBase set => SetProperty(ref _currentView, value); } private ConfigModel config { get; set; } + private ClientWebSocket ws { get; set; } public string ActionButtonText { get; set; } = "Start Conversation"; public string ApiKey { get; set; } public string SpeakModel { get; set; } @@ -48,6 +51,7 @@ public partial class MainWindowViewModel : ViewModelBase public MainWindowViewModel() { + ws = new(); config = GetConfig(); ApiKey = config.ApiKey; SpeakModel = config.SpeakModel; @@ -58,7 +62,7 @@ public partial class MainWindowViewModel : ViewModelBase CurrentView = new ConfigWindow(); return; } - CurrentView = new AgentWindow(); + CurrentView = new HomeWindow(); } private static string ConfigPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.config/deepgram-voice-assistant"; private static string ConfigFilePath = ConfigPath + "/config.json"; @@ -115,7 +119,7 @@ public partial class MainWindowViewModel : ViewModelBase ThinkModel = thinkModel }; UpdateConfig(config); - CurrentView = new AgentWindow(); + CurrentView = new HomeWindow(); } public void OpenConfig() @@ -123,19 +127,14 @@ public partial class MainWindowViewModel : ViewModelBase CurrentView = new ConfigWindow(); } - public void ToggleConversation() { - if (ActionButtonText == "Start Conversation") { - StartConversation(); - } else { - EndConversation(); - } + public async Task StartAgent() { + // ws.Options.SetRequestHeader("Authorization", "token " + config.ApiKey); + // await ws.ConnectAsync(new Uri("wss://agent.deepgram.com/agent"), System.Threading.CancellationToken.None); + CurrentView = new AgentWindow(); } - public void StartConversation() { - ActionButtonText = "End Conversation"; - } - - public void EndConversation() { - ActionButtonText = "Start Conversation"; + public async Task EndConversation() { + CurrentView = new HomeWindow(); + // await ws.CloseAsync(WebSocketCloseStatus.NormalClosure, "Conversation ended", System.Threading.CancellationToken.None); } } diff --git a/Views/AgentWindow.axaml b/Views/AgentWindow.axaml index 849e0c5..a8d069c 100644 --- a/Views/AgentWindow.axaml +++ b/Views/AgentWindow.axaml @@ -6,13 +6,7 @@ - - - - - - - + \ No newline at end of file diff --git a/Views/ConfigWindow.axaml.cs b/Views/ConfigWindow.axaml.cs index 29a30a4..abf7171 100644 --- a/Views/ConfigWindow.axaml.cs +++ b/Views/ConfigWindow.axaml.cs @@ -1,6 +1,4 @@ using Avalonia.Controls; -using Avalonia.Interactivity; -using System; namespace app.Views; diff --git a/Views/HomeWindow.axaml b/Views/HomeWindow.axaml new file mode 100644 index 0000000..e88e30e --- /dev/null +++ b/Views/HomeWindow.axaml @@ -0,0 +1,13 @@ + + + + + + + + + \ No newline at end of file diff --git a/Views/HomeWindow.axaml.cs b/Views/HomeWindow.axaml.cs new file mode 100644 index 0000000..bebb255 --- /dev/null +++ b/Views/HomeWindow.axaml.cs @@ -0,0 +1,11 @@ +using Avalonia.Controls; + +namespace app.Views; + +public partial class HomeWindow : UserControl +{ + public HomeWindow() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Views/MainWindow.axaml b/Views/MainWindow.axaml index 9aa6592..7f162c5 100644 --- a/Views/MainWindow.axaml +++ b/Views/MainWindow.axaml @@ -8,20 +8,6 @@ x:DataType="vm:MainWindowViewModel" Icon="/Assets/avalonia-logo.ico" Title="Deepgram Voice Assistant"> - - - - - -