|
92 | 92 | else |
93 | 93 | { |
94 | 94 | <div> |
95 | | - @if (_reasoning && conversation.Message.Role == "Assistant") |
| 95 | + @if (conversation.HasReasoning) |
96 | 96 | { |
97 | 97 | <div class="reasoning-row"> |
98 | 98 | <span class="brain-toggle" title="@(conversation.ShowReason ? "Hide reasoning" : "Show reasoning")" |
|
104 | 104 | { |
105 | 105 | <div class="thinker reasoning-text" |
106 | 106 | style="border-radius: 10px; padding: 10px; border-width: 2px; background-color: var(--neutral-fill-hover)"> |
107 | | - @((MarkupString)Markdown.ToHtml(GetReasoningContent(conversation.Message), _markdownPipeline)) |
| 107 | + @((MarkupString)Markdown.ToHtml(conversation.ComputedReasoning, _markdownPipeline)) |
108 | 108 | </div> |
109 | 109 | } |
110 | 110 | </div> |
111 | 111 | <hr class="reasoning-hr"/> |
112 | 112 | } |
113 | | - @((MarkupString)Markdown.ToHtml(GetMessageContent(conversation.Message), _markdownPipeline)) |
| 113 | + @((MarkupString)Markdown.ToHtml(conversation.ComputedContent, _markdownPipeline)) |
114 | 114 | </div> |
115 | 115 | } |
116 | 116 | } |
|
119 | 119 | } |
120 | 120 | @if (_isLoading) |
121 | 121 | { |
122 | | - @if (Utils.Visual) |
| 122 | + @if (Utils.ImageGen) |
123 | 123 | { |
124 | 124 | <span class="message-role-bot" style="font-style: italic; font-size: small">This might take a while...</span> |
125 | 125 | } |
|
207 | 207 | private bool _isLoading; |
208 | 208 | private bool _isThinking; |
209 | 209 | private bool _isDragging; |
210 | | - private bool _reasoning; |
211 | 210 | private bool _preserveScroll; |
212 | 211 | private string _accentColor = "#00cca3"; |
213 | 212 | private string? _errorMessage; |
|
272 | 271 | : new GenericCloudModel(Id: Utils.Model!, Backend: Utils.BackendType); |
273 | 272 | } |
274 | 273 |
|
275 | | - ctx = Utils.Visual |
276 | | - ? AIHub.Chat().WithModel(model).EnableVisual() |
277 | | - : AIHub.Chat().WithModel(model); |
| 274 | + ctx = AIHub.Chat().WithModel(model, imageGen: Utils.ImageGen); |
278 | 275 | } |
279 | 276 | catch (MaINCustomException ex) |
280 | 277 | { |
|
285 | 282 | _errorMessage = ex.Message; |
286 | 283 | } |
287 | 284 |
|
288 | | - _reasoning = !Utils.Visual && model?.HasReasoning == true; |
289 | | - Utils.Reason = _reasoning; |
290 | | - |
291 | 285 | return base.OnInitializedAsync(); |
292 | 286 | } |
293 | 287 |
|
|
451 | 445 | }); |
452 | 446 |
|
453 | 447 | Chat.ModelId = Utils.Model!; |
454 | | - Chat.Visual = Utils.Visual; |
| 448 | + Chat.ImageGen = Utils.ImageGen; |
455 | 449 |
|
456 | 450 | bool wasAtBottom = await JS.InvokeAsync<bool>("scrollManager.isAtBottom", "messages-container"); |
457 | 451 |
|
|
620 | 614 | Message = x, |
621 | 615 | AttachedFiles = existingFilesMap.TryGetValue(x, out var files) ? files : new List<string>(), |
622 | 616 | AttachedImages = existingImagesMap.TryGetValue(x, out var images) ? images : new List<(string, string)>(), |
623 | | - ShowReason = existingReasonMap.TryGetValue(x, out var show) && show |
| 617 | + ShowReason = existingReasonMap.TryGetValue(x, out var show) && show, |
| 618 | + HasReasoning = x.Tokens.Any(t => t.Type == TokenType.Reason), |
| 619 | + ComputedContent = GetMessageContent(x), |
| 620 | + ComputedReasoning = GetReasoningContent(x) |
624 | 621 | }).ToList(); |
625 | 622 | } |
626 | 623 |
|
|
0 commit comments