| | | 1 | | <div class="ai-chat-message"> |
| | 0 | 2 | | @if (Message.Role != ChatMessageRole.Assistant) |
| | | 3 | | { |
| | | 4 | | <MarkdownBlock Content="@Message.Content" /> |
| | | 5 | | } |
| | | 6 | | else |
| | | 7 | | { |
| | 0 | 8 | | toolCount = 0; |
| | 0 | 9 | | @if (!string.IsNullOrEmpty(Message.ReasoningContent)) |
| | | 10 | | { |
| | 0 | 11 | | var header = Message.Timings is { Reasoning.TotalMilliseconds: > 100 } |
| | 0 | 12 | | ? $"{SharedResource.Thinking} {Message.Timings.Reasoning.TotalSeconds.ToString("F1")} sec" |
| | 0 | 13 | | : SharedResource.Thinking; |
| | | 14 | | <Details Text="@header" Icon="fa-solid fa-lightbulb" class="reasoning-details"> |
| | | 15 | | <MarkdownBlock Content="@Message.ReasoningContent" /> |
| | | 16 | | </Details> |
| | | 17 | | } |
| | | 18 | | |
| | 0 | 19 | | @foreach (var segment in Message.Segments) |
| | | 20 | | { |
| | 0 | 21 | | if (segment.Type == SegmentType.Tool) |
| | | 22 | | { |
| | | 23 | | <ToolCallBlock @key="segment.Id" |
| | | 24 | | Segment="@segment" |
| | | 25 | | OnApproval="@OnToolApprovalHandler" |
| | | 26 | | ToolResult="@(toolCount < Message.ToolResults.Count ? Message.ToolResults[toolCount] : null)" /> |
| | 0 | 27 | | toolCount++; |
| | | 28 | | } |
| | 0 | 29 | | else if (segment.Type is SegmentType.Markdown) |
| | | 30 | | { |
| | | 31 | | <MarkdownBlock @key="segment.Id" Content="@segment.CurrentLine.ToString()" /> |
| | | 32 | | } |
| | | 33 | | } |
| | | 34 | | } |
| | | 35 | | </div> |
| | | 36 | | |
| | | 37 | | @code { |
| | 0 | 38 | | [Parameter] public VisualChatMessage Message { get; set; } = new(); |
| | 0 | 39 | | [Parameter] public EventCallback<(string MessageId, string SegmentId, bool Approved)> OnToolApproval { get; set; } |
| | 0 | 40 | | [Inject] private IToolManager ToolManager { get; set; } = null!; |
| | | 41 | | |
| | | 42 | | private int toolCount; |
| | | 43 | | |
| | | 44 | | private async Task OnToolApprovalHandler((string SegmentId, bool Approved) args) |
| | | 45 | | { |
| | 0 | 46 | | await OnToolApproval.InvokeAsync((Message.Id, args.SegmentId, args.Approved)); |
| | 0 | 47 | | } |
| | | 48 | | } |