< Summary

Information
Class: UIBlazor.Models.ToolResult
Assembly: UIBlazor
File(s): /home/runner/work/InvAit/InvAit/UIBlazor/Models/ToolResult.cs
Tag: 71_26091983037
Line coverage
0%
Covered lines: 0
Uncovered lines: 18
Coverable lines: 18
Total lines: 51
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%210%
get_Name()100%210%
get_DisplayName()100%210%
get_Content()100%210%
get_GetDisplayContent()100%210%
get_Success()100%210%
Convert(...)0%2040%
GetDisplayName(...)0%620%

File(s)

/home/runner/work/InvAit/InvAit/UIBlazor/Models/ToolResult.cs

#LineLine coverage
 1namespace UIBlazor.Models;
 2
 3/// <summary>
 4/// Класс для хранения ответов тулзов в <see cref="VisualChatMessage"/>
 5/// </summary>
 6public class ToolResult
 7{
 08    public string Id { get; } = $"tool{Guid.NewGuid()}";
 9
 10    /// <summary>
 11    /// Имя тулзы
 12    /// </summary>
 013    public string Name { get; init; } = string.Empty;
 14
 15    /// <summary>
 16    /// Локализованное имя тулзы. Только для UI
 17    /// </summary>
 18    [JsonIgnore]
 019    public string DisplayName { get; set; } = string.Empty;
 20
 21    /// <summary>
 22    /// Полное содержание ответа включая теги <tool_result></tool_result>
 23    /// </summary>
 024    public string Content { get; init; } = string.Empty;
 25
 26    [JsonIgnore]
 027    public string GetDisplayContent => string.Join("\n", Content.Split('\n').Skip(1).SkipLast(1)).Trim();
 28
 29    /// <summary>
 30    /// Статус
 31    /// </summary>
 032    public bool Success { get; set; }
 33
 34    public static ToolResult Convert(VsToolResult vsToolResult, string displayName, string name)
 35    {
 036        return new ToolResult
 037        {
 038            DisplayName = GetDisplayName(vsToolResult.Success, !string.IsNullOrEmpty(displayName) ? displayName : name),
 039            Name = name,
 040            Content = $"""
 041                       <tool_result name="{name}" success={vsToolResult.Success}>
 042                       {(vsToolResult.Success ? vsToolResult.Result : vsToolResult.ErrorMessage)}
 043                       </tool_result>
 044                       """,
 045            Success = vsToolResult.Success
 046        };
 47    }
 48
 49    public static string GetDisplayName(bool success, string displayName)
 050        => $"{(success ? '✅' : '❌')} {displayName}";
 51}