|
| 1 | +// Copyright (c) Microsoft. All rights reserved. |
| 2 | + |
| 3 | +using System.Text; |
| 4 | +using System.Text.Json.Serialization; |
| 5 | + |
| 6 | +namespace Microsoft.SemanticKernel.Plugins.Core.CodeInterpreter; |
| 7 | + |
| 8 | +/// <summary> |
| 9 | +/// Represents the result of a Python code execution. |
| 10 | +/// </summary> |
| 11 | +public sealed class SessionsPythonCodeExecutionResult |
| 12 | +{ |
| 13 | + /// <summary> |
| 14 | + /// Gets or sets the status of the execution (e.g., Succeeded, Failed). |
| 15 | + /// </summary> |
| 16 | + [JsonPropertyName("status")] |
| 17 | + public required string Status { get; set; } |
| 18 | + |
| 19 | + /// <summary> |
| 20 | + /// Gets or sets the detailed result of the execution. |
| 21 | + /// </summary> |
| 22 | + [JsonPropertyName("result")] |
| 23 | + public ExecutionDetails? Result { get; set; } |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// Returns a string representation of the execution result. |
| 27 | + /// </summary> |
| 28 | + public override string ToString() |
| 29 | + { |
| 30 | + StringBuilder sb = new(); |
| 31 | + |
| 32 | + sb.AppendLine($"Status: {this.Status}"); |
| 33 | + if (this.Result is not null) |
| 34 | + { |
| 35 | + sb.AppendLine($"Result: {this.Result.ExecutionResult}"); |
| 36 | + sb.AppendLine($"Stdout: {this.Result.StdOut}"); |
| 37 | + sb.AppendLine($"Stderr: {this.Result.StdErr}"); |
| 38 | + } |
| 39 | + |
| 40 | + return sb.ToString(); |
| 41 | + } |
| 42 | + |
| 43 | + /// <summary> |
| 44 | + /// Represents the detailed result of a Python code execution. |
| 45 | + /// </summary> |
| 46 | + public sealed class ExecutionDetails |
| 47 | + { |
| 48 | + /// <summary> |
| 49 | + /// Gets or sets the standard output (stdout) of the code execution. |
| 50 | + /// </summary> |
| 51 | + [JsonPropertyName("stdout")] |
| 52 | + public string? StdOut { get; set; } |
| 53 | + |
| 54 | + /// <summary> |
| 55 | + /// Gets or sets the standard error (stderr) of the code execution. |
| 56 | + /// </summary> |
| 57 | + [JsonPropertyName("stderr")] |
| 58 | + public string? StdErr { get; set; } |
| 59 | + |
| 60 | + /// <summary> |
| 61 | + /// Gets or sets the result of the code execution. |
| 62 | + /// </summary> |
| 63 | + [JsonPropertyName("executionResult")] |
| 64 | + public string? ExecutionResult { get; set; } |
| 65 | + } |
| 66 | +} |
0 commit comments