fix: address methods that return void or task in those cases return null
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using AnthropicClient.Json;
|
||||
|
||||
@@ -65,7 +66,9 @@ public class ToolCall
|
||||
|
||||
const string resultPropertyName = "Result";
|
||||
var resultProperty = task.GetType().GetProperty(resultPropertyName);
|
||||
result = resultProperty is not null ? (T)resultProperty.GetValue(task) : default;
|
||||
var isVoidTaskResult = resultProperty.PropertyType.FullName.Contains("VoidTaskResult");
|
||||
|
||||
result = resultProperty is not null && isVoidTaskResult is false ? (T)resultProperty.GetValue(task) : default;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace AnthropicClient.Models;
|
||||
public class ToolCallResult<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// The value of the tool call result.
|
||||
/// The value of the tool call result. Can be null if the call failed, the call was successful but the return type is void or Task, or the call was successful but the return value is null
|
||||
/// </summary>
|
||||
public T? Value { get; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user