Skip to content

Commit 2fbff98

Browse files
Merge pull request #77 from wieslawsoltes/ReactiveGenerator
Use ReactiveGenerator
2 parents 6144d07 + f589234 commit 2fbff98

36 files changed

+123
-500
lines changed

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111
<PropertyGroup>
1212
<AnalysisLevel>latest</AnalysisLevel>
13-
<LangVersion>latest</LangVersion>
13+
<LangVersion>preview</LangVersion>
1414
</PropertyGroup>
1515
<PropertyGroup>
1616
<AvaloniaVersion>11.2.0</AvaloniaVersion>

azure-pipelines.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ resources:
1111
variables:
1212
BuildConfiguration: 'Release'
1313
BuildPlatform: 'Any CPU'
14-
PublishFramework: 'net8.0'
14+
PublishFramework: 'net9.0'
1515
PublishProject: 'ChatGPT.UI.Desktop'
1616
PublishRuntime: ''
1717
Workloads: 'wasm-tools wasm-experimental android'

build/build/_build.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
77
<IsPackable>False</IsPackable>
88
<NoWarn>CS0649;CS0169</NoWarn>
@@ -12,6 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Nuke.Common" Version="5.3.0" />
15+
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="9.0.0" />
1516
</ItemGroup>
1617

1718
<ItemGroup>

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.100",
3+
"version": "9.0.100",
44
"rollForward": "latestMinor",
55
"allowPrerelease": true
66
}

samples/ChatGPT.CLI.Chaining/ChatGPT.CLI.Chaining.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>

samples/ChatGPT.CLI.FunctionCalling/ChatGPT.CLI.FunctionCalling.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>

samples/ChatGPT.CLI.Repl/ChatGPT.CLI.Repl.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>

samples/ChatGPT.UI.Designer/ChatGPT.UI.Designer.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<OutputType>WinExe</OutputType>
77
</PropertyGroup>
88
<PropertyGroup>
9-
<TargetFramework>net8.0</TargetFramework>
9+
<TargetFramework>net9.0</TargetFramework>
1010
<Nullable>enable</Nullable>
1111
<TrimMode>full</TrimMode>
1212
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>

samples/ChatGPT.UI.Game/ChatGPT.UI.Game.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<OutputType>WinExe</OutputType>
77
</PropertyGroup>
88
<PropertyGroup>
9-
<TargetFramework>net8.0</TargetFramework>
9+
<TargetFramework>net9.0</TargetFramework>
1010
<Nullable>enable</Nullable>
1111
<TrimMode>full</TrimMode>
1212
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>

src/ChatGPT.CLI/ChatGPT.CLI.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Exe</OutputType>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<RuntimeIdentifiers>win-x64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>

src/ChatGPT.Core/ChatGPT.Core.csproj

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<OutputType>Library</OutputType>
4-
<TargetFrameworks>net8.0;net462</TargetFrameworks>
4+
<TargetFrameworks>net9.0;net462</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<IsPackable>True</IsPackable>
77
<RootNamespace>ChatGPT</RootNamespace>
88
</PropertyGroup>
9+
<PropertyGroup>
10+
<UseBackingFields>true</UseBackingFields>
11+
</PropertyGroup>
912
<PropertyGroup>
1013
<SignAssembly>true</SignAssembly>
1114
<AssemblyOriginatorKeyFile>..\..\ChatGPT.snk</AssemblyOriginatorKeyFile>
@@ -18,6 +21,10 @@
1821
<ItemGroup>
1922
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
2023
<PackageReference Include="CommunityToolkit.Mvvm" Version="$(CommunityToolkitMvvmVersion)" />
24+
<PackageReference Include="ReactiveGenerator" Version="0.9.13">
25+
<PrivateAssets>all</PrivateAssets>
26+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27+
</PackageReference>
2128
</ItemGroup>
2229
<ItemGroup Condition=" '$(TargetFramework)' == 'net462' ">
2330
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />

src/ChatGPT.Core/ViewModels/Chat/ChatFunctionCallViewModel.cs

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
using System.Text.Json.Serialization;
2-
using CommunityToolkit.Mvvm.ComponentModel;
32

43
namespace ChatGPT.ViewModels.Chat;
54

6-
public class ChatFunctionCallViewModel : ObservableObject
5+
public partial class ChatFunctionCallViewModel : ViewModelBase
76
{
8-
private string? _name;
9-
107
[JsonConstructor]
118
public ChatFunctionCallViewModel()
129
{
@@ -19,11 +16,7 @@ public ChatFunctionCallViewModel(string name)
1916
}
2017

2118
[JsonPropertyName("name")]
22-
public string? Name
23-
{
24-
get => _name;
25-
set => SetProperty(ref _name, value);
26-
}
19+
public partial string? Name { get; set; }
2720

2821
public ChatFunctionCallViewModel Copy()
2922
{

src/ChatGPT.Core/ViewModels/Chat/ChatFunctionViewModel.cs

+4-21
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
using System.Text.Json.Serialization;
2-
using CommunityToolkit.Mvvm.ComponentModel;
32

43
namespace ChatGPT.ViewModels.Chat;
54

6-
public class ChatFunctionViewModel : ObservableObject
5+
public partial class ChatFunctionViewModel : ViewModelBase
76
{
8-
private string? _name;
9-
private string? _description;
10-
private object? _parameters;
11-
127
[JsonConstructor]
138
public ChatFunctionViewModel()
149
{
@@ -30,25 +25,13 @@ public ChatFunctionViewModel(string name, string description, object parameters)
3025
}
3126

3227
[JsonPropertyName("name")]
33-
public string? Name
34-
{
35-
get => _name;
36-
set => SetProperty(ref _name, value);
37-
}
28+
public partial string? Name { get; set; }
3829

3930
[JsonPropertyName("description")]
40-
public string? Description
41-
{
42-
get => _description;
43-
set => SetProperty(ref _description, value);
44-
}
31+
public partial string? Description { get; set; }
4532

4633
[JsonPropertyName("parameters")]
47-
public object? Parameters
48-
{
49-
get => _parameters;
50-
set => SetProperty(ref _parameters, value);
51-
}
34+
public partial object? Parameters { get; set; }
5235

5336
public ChatFunctionViewModel Copy()
5437
{

src/ChatGPT.Core/ViewModels/Chat/ChatMessageFunctionCallViewModel.cs

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using System.Text.Json.Serialization;
4-
using CommunityToolkit.Mvvm.ComponentModel;
54

65
namespace ChatGPT.ViewModels.Chat;
76

8-
public class ChatMessageFunctionCallViewModel : ObservableObject
7+
public partial class ChatMessageFunctionCallViewModel : ViewModelBase
98
{
10-
private string? _name;
11-
private Dictionary<string, string>? _arguments;
12-
139
[JsonConstructor]
1410
public ChatMessageFunctionCallViewModel()
1511
{
@@ -23,18 +19,10 @@ public ChatMessageFunctionCallViewModel(string role, Dictionary<string, string>
2319
}
2420

2521
[JsonPropertyName("name")]
26-
public string? Name
27-
{
28-
get => _name;
29-
set => SetProperty(ref _name, value);
30-
}
22+
public partial string? Name { get; set; }
3123

3224
[JsonPropertyName("arguments")]
33-
public Dictionary<string, string>? Arguments
34-
{
35-
get => _arguments;
36-
set => SetProperty(ref _arguments, value);
37-
}
25+
public partial Dictionary<string, string>? Arguments { get; set; }
3826

3927
public ChatMessageFunctionCallViewModel Copy()
4028
{

src/ChatGPT.Core/ViewModels/Chat/ChatMessageViewModel.cs

+11-62
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,12 @@
22
using System.IO;
33
using System.Text.Json.Serialization;
44
using System.Threading.Tasks;
5-
using CommunityToolkit.Mvvm.ComponentModel;
65
using CommunityToolkit.Mvvm.Input;
76

87
namespace ChatGPT.ViewModels.Chat;
98

10-
public class ChatMessageViewModel : ObservableObject
9+
public partial class ChatMessageViewModel : ViewModelBase
1110
{
12-
private string? _role;
13-
private string? _message;
14-
private string? _name;
15-
private ChatMessageFunctionCallViewModel? _functionCall;
16-
private string? _format;
17-
private bool _isSent;
18-
private bool _isAwaiting;
19-
private bool _isError;
20-
private bool _canRemove;
21-
private bool _isEditing;
2211
private Func<ChatMessageViewModel, bool, Task>? _send;
2312
private Func<ChatMessageViewModel, Task>? _copy;
2413
private Action<ChatMessageViewModel>? _remove;
@@ -73,83 +62,43 @@ public ChatMessageViewModel(string role, string? message, string name, ChatMessa
7362
/// The role of the messages author. One of system, user, assistant, or function.
7463
/// </summary>
7564
[JsonPropertyName("role")]
76-
public string? Role
77-
{
78-
get => _role;
79-
set => SetProperty(ref _role, value);
80-
}
65+
public partial string? Role { get; set; }
8166

8267
/// <summary>
8368
/// The contents of the message. content is required for all messages, and may be null for assistant messages with function calls.
8469
/// </summary>
8570
[JsonPropertyName("message")]
86-
public string? Message
87-
{
88-
get => _message;
89-
set => SetProperty(ref _message, value);
90-
}
71+
public partial string? Message { get; set; }
9172

9273
/// <summary>
9374
/// 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.
9475
/// </summary>
9576
[JsonPropertyName("name")]
96-
public string? Name
97-
{
98-
get => _name;
99-
set => SetProperty(ref _name, value);
100-
}
77+
public partial string? Name { get; set; }
10178

10279
/// <summary>
10380
/// The name and arguments of a function that should be called, as generated by the model.
10481
/// </summary>
10582
[JsonPropertyName("function_call")]
106-
public ChatMessageFunctionCallViewModel? FunctionCall
107-
{
108-
get => _functionCall;
109-
set => SetProperty(ref _functionCall, value);
110-
}
83+
public partial ChatMessageFunctionCallViewModel? FunctionCall { get; set; }
11184

11285
[JsonPropertyName("format")]
113-
public string? Format
114-
{
115-
get => _format;
116-
set => SetProperty(ref _format, value);
117-
}
86+
public partial string? Format { get; set; }
11887

11988
[JsonPropertyName("isSent")]
120-
public bool IsSent
121-
{
122-
get => _isSent;
123-
set => SetProperty(ref _isSent, value);
124-
}
89+
public partial bool IsSent { get; set; }
12590

12691
[JsonPropertyName("isAwaiting")]
127-
public bool IsAwaiting
128-
{
129-
get => _isAwaiting;
130-
set => SetProperty(ref _isAwaiting, value);
131-
}
92+
public partial bool IsAwaiting { get; set; }
13293

13394
[JsonPropertyName("isError")]
134-
public bool IsError
135-
{
136-
get => _isError;
137-
set => SetProperty(ref _isError, value);
138-
}
95+
public partial bool IsError { get; set; }
13996

14097
[JsonPropertyName("canRemove")]
141-
public bool CanRemove
142-
{
143-
get => _canRemove;
144-
set => SetProperty(ref _canRemove, value);
145-
}
98+
public partial bool CanRemove { get; set; }
14699

147100
[JsonIgnore]
148-
public bool IsEditing
149-
{
150-
get => _isEditing;
151-
set => SetProperty(ref _isEditing, value);
152-
}
101+
public partial bool IsEditing { get; set; }
153102

154103
[JsonIgnore]
155104
public IAsyncRelayCommand AddCommand { get; }
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
11
using System.Text.Json.Serialization;
2-
using CommunityToolkit.Mvvm.ComponentModel;
32

43
namespace ChatGPT.ViewModels.Chat;
54

6-
public class ChatResultViewModel : ObservableObject
5+
public partial class ChatResultViewModel : ViewModelBase
76
{
8-
private string? _message;
9-
private bool _isError;
10-
private ChatMessageFunctionCallViewModel? _functionCall;
11-
127
[JsonPropertyName("name")]
13-
public string? Message
14-
{
15-
get => _message;
16-
set => SetProperty(ref _message, value);
17-
}
8+
public partial string? Message { get; set; }
189

1910
[JsonPropertyName("isError")]
20-
public bool IsError
21-
{
22-
get => _isError;
23-
set => SetProperty(ref _isError, value);
24-
}
11+
public partial bool IsError { get; set; }
2512

2613
[JsonPropertyName("function_call")]
27-
public ChatMessageFunctionCallViewModel? FunctionCall
28-
{
29-
get => _functionCall;
30-
set => SetProperty(ref _functionCall, value);
31-
}
14+
public partial ChatMessageFunctionCallViewModel? FunctionCall { get; set; }
3215
}

0 commit comments

Comments
 (0)