-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add simple repl for testing blyss chat Move to AI folder Remove config
- Loading branch information
1 parent
7cdbda3
commit 296fb21
Showing
74 changed files
with
4,422 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
root = true | ||
|
||
[*.cs] | ||
|
||
charset = utf-8 | ||
|
||
# Use hard tabs for indentation | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# Disable all .NET analyzers | ||
dotnet_analyzer_diagnostic.severity = none | ||
|
||
dotnet_diagnostic.CS8600.severity = none | ||
dotnet_diagnostic.CS8601.severity = none | ||
dotnet_diagnostic.CS8603.severity = none | ||
dotnet_diagnostic.CS8604.severity = none | ||
dotnet_diagnostic.CS8618.severity = none | ||
dotnet_diagnostic.CS8625.severity = none | ||
dotnet_diagnostic.CS8765.severity = none | ||
dotnet_diagnostic.CS8767.severity = none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using AI.Model.Services; | ||
using AI.Services; | ||
using ChatGPT.Model.Services; | ||
using ChatGPT.Services; | ||
using ChatGPT.ViewModels.Chat; | ||
using ChatGPT.ViewModels.Settings; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace ChatGPT; | ||
|
||
public static class Defaults | ||
{ | ||
public const string WelcomeMessage = "Hi! I'm Clippy, your Windows Assistant. Would you like to get some assistance?"; | ||
|
||
public const decimal DefaultTemperature = 0.7m; | ||
|
||
public const decimal DefaultTopP = 1m; | ||
|
||
public const decimal DefaultPresencePenalty = 0m; | ||
|
||
public const decimal DefaultFrequencyPenalty = 0m; | ||
|
||
public const int DefaultMaxTokens = 2000; | ||
|
||
public const string DefaultModel = "gpt-3.5-turbo"; | ||
|
||
public const string DefaultDirections = "You are a helpful assistant named Clippy. Write answers in Markdown blocks. For code blocks always define used language."; | ||
|
||
public const string DefaultMessageFormat = "Markdown"; | ||
|
||
public const string TextMessageFormat = "Text"; | ||
|
||
public const string MarkdownMessageFormat = "Markdown"; | ||
|
||
public const string HtmlMessageTextFormat = "Html"; | ||
|
||
public static Ioc Locator = Ioc.Default; | ||
|
||
public static IServiceProvider ConfigureDefaultServices() | ||
{ | ||
IServiceCollection serviceCollection = new ServiceCollection(); | ||
|
||
serviceCollection.AddSingleton<IChatSerializer, SystemTextJsonChatSerializer>(); | ||
serviceCollection.AddSingleton<IStorageFactory, IsolatedStorageFactory>(); | ||
serviceCollection.AddSingleton<IChatService, ChatService>(); | ||
|
||
serviceCollection.AddTransient<ChatMessageViewModel>(); | ||
serviceCollection.AddTransient<ChatSettingsViewModel>(); | ||
serviceCollection.AddTransient<ChatResultViewModel>(); | ||
serviceCollection.AddTransient<ChatViewModel>(); | ||
serviceCollection.AddTransient<PromptViewModel>(); | ||
|
||
IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider(); | ||
|
||
Locator.ConfigureServices(serviceProvider); | ||
|
||
return serviceProvider; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
WalletWasabi.Fluent/AI/ChatGPT.Core/Model/Plugins/IChatPlugin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace ChatGPT.Model.Plugins; | ||
|
||
public interface IChatPlugin | ||
{ | ||
string Id { get; } | ||
string Name { get; } | ||
Task StartAsync(); | ||
Task StopAsync(); | ||
Task InitializeAsync(IPluginContext context); | ||
Task ShutdownAsync(); | ||
} |
10 changes: 10 additions & 0 deletions
10
WalletWasabi.Fluent/AI/ChatGPT.Core/Model/Plugins/IPluginContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.ObjectModel; | ||
using ChatGPT.ViewModels.Chat; | ||
|
||
namespace ChatGPT.Model.Plugins; | ||
|
||
public interface IPluginContext | ||
{ | ||
ObservableCollection<ChatViewModel> Chats { get; set; } | ||
ChatViewModel? CurrentChat { get; set; } | ||
} |
16 changes: 16 additions & 0 deletions
16
WalletWasabi.Fluent/AI/ChatGPT.Core/Model/Services/IApplicationService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
|
||
namespace ChatGPT.Model.Services; | ||
|
||
public interface IApplicationService | ||
{ | ||
Task OpenFileAsync(Func<Stream, Task> callback, List<string> fileTypes, string title); | ||
Task SaveFileAsync(Func<Stream, Task> callback, List<string> fileTypes, string title, string fileName, string defaultExtension); | ||
void ToggleTheme(); | ||
void ToggleTopmost(); | ||
Task SetClipboardTextAsync(string text); | ||
void Exit(); | ||
} |
9 changes: 9 additions & 0 deletions
9
WalletWasabi.Fluent/AI/ChatGPT.Core/Model/Services/IPluginsService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace ChatGPT.Model.Services; | ||
|
||
public interface IPluginsService | ||
{ | ||
void DiscoverPlugins(); | ||
void InitPlugins(); | ||
void StartPlugins(); | ||
void ShutdownPlugins(); | ||
} |
6 changes: 6 additions & 0 deletions
6
WalletWasabi.Fluent/AI/ChatGPT.Core/Model/Services/IStorageFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace ChatGPT.Model.Services; | ||
|
||
public interface IStorageFactory | ||
{ | ||
IStorageService<T> CreateStorageService<T>(); | ||
} |
12 changes: 12 additions & 0 deletions
12
WalletWasabi.Fluent/AI/ChatGPT.Core/Model/Services/IStorageService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.Text.Json.Serialization.Metadata; | ||
using System.Threading.Tasks; | ||
|
||
namespace ChatGPT.Model.Services; | ||
|
||
public interface IStorageService<T> | ||
{ | ||
Task SaveObjectAsync(T obj, string key, JsonTypeInfo<T> typeInfo); | ||
Task<T?> LoadObjectAsync(string key, JsonTypeInfo<T> typeInfo); | ||
void SaveObject(T obj, string key, JsonTypeInfo<T> typeInfo); | ||
T? LoadObject(string key, JsonTypeInfo<T> typeInfo); | ||
} |
31 changes: 31 additions & 0 deletions
31
WalletWasabi.Fluent/AI/ChatGPT.Core/Plugins/DummyChatPlugin.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Threading.Tasks; | ||
using ChatGPT.Model.Plugins; | ||
|
||
namespace ChatGPT.Plugins; | ||
|
||
public class DummyChatPlugin : IChatPlugin | ||
{ | ||
public string Id => "Dummy"; | ||
|
||
public string Name => "Dummy"; | ||
|
||
public async Task StartAsync() | ||
{ | ||
await Task.Yield(); | ||
} | ||
|
||
public async Task StopAsync() | ||
{ | ||
await Task.Yield(); | ||
} | ||
|
||
public async Task InitializeAsync(IPluginContext context) | ||
{ | ||
await Task.Yield(); | ||
} | ||
|
||
public async Task ShutdownAsync() | ||
{ | ||
await Task.Yield(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
WalletWasabi.Fluent/AI/ChatGPT.Core/Services/ApplicationDataStorageFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using ChatGPT.Model.Services; | ||
|
||
namespace ChatGPT.Services; | ||
|
||
public class ApplicationDataStorageFactory : IStorageFactory | ||
{ | ||
public IStorageService<T> CreateStorageService<T>() => new ApplicationDataStorageService<T>(); | ||
} |
91 changes: 91 additions & 0 deletions
91
WalletWasabi.Fluent/AI/ChatGPT.Core/Services/ApplicationDataStorageService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization.Metadata; | ||
using System.Threading.Tasks; | ||
using ChatGPT.Model.Services; | ||
|
||
namespace ChatGPT.Services; | ||
|
||
public class ApplicationDataStorageService<T> : IStorageService<T> | ||
{ | ||
private const string FolderName = "ChatGPT"; | ||
private const string FileExtension = ".json"; | ||
|
||
public async Task SaveObjectAsync(T obj, string key, JsonTypeInfo<T> typeInfo) | ||
{ | ||
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); | ||
var appPath = Path.Combine(appDataPath, FolderName); | ||
if (!Directory.Exists(appPath)) | ||
{ | ||
Directory.CreateDirectory(appPath); | ||
} | ||
var appSettingPath = Path.Combine(appPath, key + FileExtension); | ||
#if NETFRAMEWORK | ||
using var stream = File.Open(appSettingPath, FileMode.Create); | ||
#else | ||
await using var stream = File.Open(appSettingPath, FileMode.Create); | ||
#endif | ||
await JsonSerializer.SerializeAsync(stream, obj, typeInfo); | ||
} | ||
|
||
public async Task<T?> LoadObjectAsync(string key, JsonTypeInfo<T> typeInfo) | ||
{ | ||
try | ||
{ | ||
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); | ||
var appSettingPath = Path.Combine(appDataPath, FolderName, key + FileExtension); | ||
if (File.Exists(appSettingPath)) | ||
{ | ||
#if NETFRAMEWORK | ||
using var stream = File.OpenRead(appSettingPath); | ||
#else | ||
await using var stream = File.OpenRead(appSettingPath); | ||
#endif | ||
var storedObj = await JsonSerializer.DeserializeAsync(stream, typeInfo); | ||
return storedObj ?? default; | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Debug.WriteLine(e); | ||
} | ||
|
||
return default; | ||
} | ||
|
||
public void SaveObject(T obj, string key, JsonTypeInfo<T> typeInfo) | ||
{ | ||
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); | ||
var appPath = Path.Combine(appDataPath, FolderName); | ||
if (!Directory.Exists(appPath)) | ||
{ | ||
Directory.CreateDirectory(appPath); | ||
} | ||
var appSettingPath = Path.Combine(appPath, key + FileExtension); | ||
using var stream = File.Open(appSettingPath, FileMode.Create); | ||
JsonSerializer.Serialize(stream, obj, typeInfo); | ||
} | ||
|
||
public T? LoadObject(string key, JsonTypeInfo<T> typeInfo) | ||
{ | ||
try | ||
{ | ||
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); | ||
var appSettingPath = Path.Combine(appDataPath, FolderName, key + FileExtension); | ||
if (File.Exists(appSettingPath)) | ||
{ | ||
using var stream = File.OpenRead(appSettingPath); | ||
var storedObj = JsonSerializer.Deserialize(stream, typeInfo); | ||
return storedObj ?? default; | ||
} | ||
} | ||
catch (Exception e) | ||
{ | ||
Debug.WriteLine(e); | ||
} | ||
|
||
return default; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
WalletWasabi.Fluent/AI/ChatGPT.Core/Services/IsolatedStorageFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using ChatGPT.Model.Services; | ||
|
||
namespace ChatGPT.Services; | ||
|
||
public class IsolatedStorageFactory : IStorageFactory | ||
{ | ||
public IStorageService<T> CreateStorageService<T>() => new IsolatedStorageService<T>(); | ||
} |
Oops, something went wrong.