Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ReactiveGenerator #77

Merged
merged 8 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<PropertyGroup>
<AnalysisLevel>latest</AnalysisLevel>
<LangVersion>latest</LangVersion>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<PropertyGroup>
<AvaloniaVersion>11.2.0</AvaloniaVersion>
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ resources:
variables:
BuildConfiguration: 'Release'
BuildPlatform: 'Any CPU'
PublishFramework: 'net8.0'
PublishFramework: 'net9.0'
PublishProject: 'ChatGPT.UI.Desktop'
PublishRuntime: ''
Workloads: 'wasm-tools wasm-experimental android'
Expand Down
3 changes: 2 additions & 1 deletion build/build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<IsPackable>False</IsPackable>
<NoWarn>CS0649;CS0169</NoWarn>
Expand All @@ -12,6 +12,7 @@

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="5.3.0" />
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"version": "9.0.100",
"rollForward": "latestMinor",
"allowPrerelease": true
}
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGPT.CLI.Chaining/ChatGPT.CLI.Chaining.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGPT.CLI.Repl/ChatGPT.CLI.Repl.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGPT.UI.Designer/ChatGPT.UI.Designer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<OutputType>WinExe</OutputType>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<TrimMode>full</TrimMode>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
Expand Down
2 changes: 1 addition & 1 deletion samples/ChatGPT.UI.Game/ChatGPT.UI.Game.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<OutputType>WinExe</OutputType>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<TrimMode>full</TrimMode>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
Expand Down
2 changes: 1 addition & 1 deletion src/ChatGPT.CLI/ChatGPT.CLI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
9 changes: 8 additions & 1 deletion src/ChatGPT.Core/ChatGPT.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFrameworks>net8.0;net462</TargetFrameworks>
<TargetFrameworks>net9.0;net462</TargetFrameworks>
<Nullable>enable</Nullable>
<IsPackable>True</IsPackable>
<RootNamespace>ChatGPT</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<UseBackingFields>true</UseBackingFields>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\ChatGPT.snk</AssemblyOriginatorKeyFile>
Expand All @@ -18,6 +21,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="$(CommunityToolkitMvvmVersion)" />
<PackageReference Include="ReactiveGenerator" Version="0.9.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
Expand Down
11 changes: 2 additions & 9 deletions src/ChatGPT.Core/ViewModels/Chat/ChatFunctionCallViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using System.Text.Json.Serialization;
using CommunityToolkit.Mvvm.ComponentModel;

namespace ChatGPT.ViewModels.Chat;

public class ChatFunctionCallViewModel : ObservableObject
public partial class ChatFunctionCallViewModel : ViewModelBase
{
private string? _name;

[JsonConstructor]
public ChatFunctionCallViewModel()
{
Expand All @@ -19,11 +16,7 @@ public ChatFunctionCallViewModel(string name)
}

[JsonPropertyName("name")]
public string? Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public partial string? Name { get; set; }

public ChatFunctionCallViewModel Copy()
{
Expand Down
25 changes: 4 additions & 21 deletions src/ChatGPT.Core/ViewModels/Chat/ChatFunctionViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
using System.Text.Json.Serialization;
using CommunityToolkit.Mvvm.ComponentModel;

namespace ChatGPT.ViewModels.Chat;

public class ChatFunctionViewModel : ObservableObject
public partial class ChatFunctionViewModel : ViewModelBase
{
private string? _name;
private string? _description;
private object? _parameters;

[JsonConstructor]
public ChatFunctionViewModel()
{
Expand All @@ -30,25 +25,13 @@ public ChatFunctionViewModel(string name, string description, object parameters)
}

[JsonPropertyName("name")]
public string? Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public partial string? Name { get; set; }

[JsonPropertyName("description")]
public string? Description
{
get => _description;
set => SetProperty(ref _description, value);
}
public partial string? Description { get; set; }

[JsonPropertyName("parameters")]
public object? Parameters
{
get => _parameters;
set => SetProperty(ref _parameters, value);
}
public partial object? Parameters { get; set; }

public ChatFunctionViewModel Copy()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using CommunityToolkit.Mvvm.ComponentModel;

namespace ChatGPT.ViewModels.Chat;

public class ChatMessageFunctionCallViewModel : ObservableObject
public partial class ChatMessageFunctionCallViewModel : ViewModelBase
{
private string? _name;
private Dictionary<string, string>? _arguments;

[JsonConstructor]
public ChatMessageFunctionCallViewModel()
{
Expand All @@ -23,18 +19,10 @@ public ChatMessageFunctionCallViewModel(string role, Dictionary<string, string>
}

[JsonPropertyName("name")]
public string? Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public partial string? Name { get; set; }

[JsonPropertyName("arguments")]
public Dictionary<string, string>? Arguments
{
get => _arguments;
set => SetProperty(ref _arguments, value);
}
public partial Dictionary<string, string>? Arguments { get; set; }

public ChatMessageFunctionCallViewModel Copy()
{
Expand Down
73 changes: 11 additions & 62 deletions src/ChatGPT.Core/ViewModels/Chat/ChatMessageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,12 @@
using System.IO;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace ChatGPT.ViewModels.Chat;

public class ChatMessageViewModel : ObservableObject
public partial class ChatMessageViewModel : ViewModelBase
{
private string? _role;
private string? _message;
private string? _name;
private ChatMessageFunctionCallViewModel? _functionCall;
private string? _format;
private bool _isSent;
private bool _isAwaiting;
private bool _isError;
private bool _canRemove;
private bool _isEditing;
private Func<ChatMessageViewModel, bool, Task>? _send;
private Func<ChatMessageViewModel, Task>? _copy;
private Action<ChatMessageViewModel>? _remove;
Expand Down Expand Up @@ -73,83 +62,43 @@ public ChatMessageViewModel(string role, string? message, string name, ChatMessa
/// The role of the messages author. One of system, user, assistant, or function.
/// </summary>
[JsonPropertyName("role")]
public string? Role
{
get => _role;
set => SetProperty(ref _role, value);
}
public partial string? Role { get; set; }

/// <summary>
/// The contents of the message. content is required for all messages, and may be null for assistant messages with function calls.
/// </summary>
[JsonPropertyName("message")]
public string? Message
{
get => _message;
set => SetProperty(ref _message, value);
}
public partial string? Message { get; set; }

/// <summary>
/// The name of the author of this message. name is required if role is function, and it should be the name of the function whose response is in the content. May contain a-z, A-Z, 0-9, and underscores, with a maximum length of 64 characters.
/// </summary>
[JsonPropertyName("name")]
public string? Name
{
get => _name;
set => SetProperty(ref _name, value);
}
public partial string? Name { get; set; }

/// <summary>
/// The name and arguments of a function that should be called, as generated by the model.
/// </summary>
[JsonPropertyName("function_call")]
public ChatMessageFunctionCallViewModel? FunctionCall
{
get => _functionCall;
set => SetProperty(ref _functionCall, value);
}
public partial ChatMessageFunctionCallViewModel? FunctionCall { get; set; }

[JsonPropertyName("format")]
public string? Format
{
get => _format;
set => SetProperty(ref _format, value);
}
public partial string? Format { get; set; }

[JsonPropertyName("isSent")]
public bool IsSent
{
get => _isSent;
set => SetProperty(ref _isSent, value);
}
public partial bool IsSent { get; set; }

[JsonPropertyName("isAwaiting")]
public bool IsAwaiting
{
get => _isAwaiting;
set => SetProperty(ref _isAwaiting, value);
}
public partial bool IsAwaiting { get; set; }

[JsonPropertyName("isError")]
public bool IsError
{
get => _isError;
set => SetProperty(ref _isError, value);
}
public partial bool IsError { get; set; }

[JsonPropertyName("canRemove")]
public bool CanRemove
{
get => _canRemove;
set => SetProperty(ref _canRemove, value);
}
public partial bool CanRemove { get; set; }

[JsonIgnore]
public bool IsEditing
{
get => _isEditing;
set => SetProperty(ref _isEditing, value);
}
public partial bool IsEditing { get; set; }

[JsonIgnore]
public IAsyncRelayCommand AddCommand { get; }
Expand Down
25 changes: 4 additions & 21 deletions src/ChatGPT.Core/ViewModels/Chat/ChatResultViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
using System.Text.Json.Serialization;
using CommunityToolkit.Mvvm.ComponentModel;

namespace ChatGPT.ViewModels.Chat;

public class ChatResultViewModel : ObservableObject
public partial class ChatResultViewModel : ViewModelBase
{
private string? _message;
private bool _isError;
private ChatMessageFunctionCallViewModel? _functionCall;

[JsonPropertyName("name")]
public string? Message
{
get => _message;
set => SetProperty(ref _message, value);
}
public partial string? Message { get; set; }

[JsonPropertyName("isError")]
public bool IsError
{
get => _isError;
set => SetProperty(ref _isError, value);
}
public partial bool IsError { get; set; }

[JsonPropertyName("function_call")]
public ChatMessageFunctionCallViewModel? FunctionCall
{
get => _functionCall;
set => SetProperty(ref _functionCall, value);
}
public partial ChatMessageFunctionCallViewModel? FunctionCall { get; set; }
}
Loading
Loading