|
2 | 2 | using System.IO;
|
3 | 3 | using System.Text.Json.Serialization;
|
4 | 4 | using System.Threading.Tasks;
|
5 |
| -using CommunityToolkit.Mvvm.ComponentModel; |
6 | 5 | using CommunityToolkit.Mvvm.Input;
|
7 | 6 |
|
8 | 7 | namespace ChatGPT.ViewModels.Chat;
|
9 | 8 |
|
10 |
| -public class ChatMessageViewModel : ObservableObject |
| 9 | +public partial class ChatMessageViewModel : ViewModelBase |
11 | 10 | {
|
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; |
22 | 11 | private Func<ChatMessageViewModel, bool, Task>? _send;
|
23 | 12 | private Func<ChatMessageViewModel, Task>? _copy;
|
24 | 13 | private Action<ChatMessageViewModel>? _remove;
|
@@ -73,83 +62,43 @@ public ChatMessageViewModel(string role, string? message, string name, ChatMessa
|
73 | 62 | /// The role of the messages author. One of system, user, assistant, or function.
|
74 | 63 | /// </summary>
|
75 | 64 | [JsonPropertyName("role")]
|
76 |
| - public string? Role |
77 |
| - { |
78 |
| - get => _role; |
79 |
| - set => SetProperty(ref _role, value); |
80 |
| - } |
| 65 | + public partial string? Role { get; set; } |
81 | 66 |
|
82 | 67 | /// <summary>
|
83 | 68 | /// The contents of the message. content is required for all messages, and may be null for assistant messages with function calls.
|
84 | 69 | /// </summary>
|
85 | 70 | [JsonPropertyName("message")]
|
86 |
| - public string? Message |
87 |
| - { |
88 |
| - get => _message; |
89 |
| - set => SetProperty(ref _message, value); |
90 |
| - } |
| 71 | + public partial string? Message { get; set; } |
91 | 72 |
|
92 | 73 | /// <summary>
|
93 | 74 | /// 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.
|
94 | 75 | /// </summary>
|
95 | 76 | [JsonPropertyName("name")]
|
96 |
| - public string? Name |
97 |
| - { |
98 |
| - get => _name; |
99 |
| - set => SetProperty(ref _name, value); |
100 |
| - } |
| 77 | + public partial string? Name { get; set; } |
101 | 78 |
|
102 | 79 | /// <summary>
|
103 | 80 | /// The name and arguments of a function that should be called, as generated by the model.
|
104 | 81 | /// </summary>
|
105 | 82 | [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; } |
111 | 84 |
|
112 | 85 | [JsonPropertyName("format")]
|
113 |
| - public string? Format |
114 |
| - { |
115 |
| - get => _format; |
116 |
| - set => SetProperty(ref _format, value); |
117 |
| - } |
| 86 | + public partial string? Format { get; set; } |
118 | 87 |
|
119 | 88 | [JsonPropertyName("isSent")]
|
120 |
| - public bool IsSent |
121 |
| - { |
122 |
| - get => _isSent; |
123 |
| - set => SetProperty(ref _isSent, value); |
124 |
| - } |
| 89 | + public partial bool IsSent { get; set; } |
125 | 90 |
|
126 | 91 | [JsonPropertyName("isAwaiting")]
|
127 |
| - public bool IsAwaiting |
128 |
| - { |
129 |
| - get => _isAwaiting; |
130 |
| - set => SetProperty(ref _isAwaiting, value); |
131 |
| - } |
| 92 | + public partial bool IsAwaiting { get; set; } |
132 | 93 |
|
133 | 94 | [JsonPropertyName("isError")]
|
134 |
| - public bool IsError |
135 |
| - { |
136 |
| - get => _isError; |
137 |
| - set => SetProperty(ref _isError, value); |
138 |
| - } |
| 95 | + public partial bool IsError { get; set; } |
139 | 96 |
|
140 | 97 | [JsonPropertyName("canRemove")]
|
141 |
| - public bool CanRemove |
142 |
| - { |
143 |
| - get => _canRemove; |
144 |
| - set => SetProperty(ref _canRemove, value); |
145 |
| - } |
| 98 | + public partial bool CanRemove { get; set; } |
146 | 99 |
|
147 | 100 | [JsonIgnore]
|
148 |
| - public bool IsEditing |
149 |
| - { |
150 |
| - get => _isEditing; |
151 |
| - set => SetProperty(ref _isEditing, value); |
152 |
| - } |
| 101 | + public partial bool IsEditing { get; set; } |
153 | 102 |
|
154 | 103 | [JsonIgnore]
|
155 | 104 | public IAsyncRelayCommand AddCommand { get; }
|
|
0 commit comments