Fix McpAIFunction to override Name/Description (#35)
This commit is contained in:
parent
f15b94c244
commit
e5c26d6285
1 changed files with 7 additions and 9 deletions
|
|
@ -23,7 +23,10 @@ public class McpAIFunction : AIFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override string ToString() => _tool.Name;
|
public override string Name => _tool.Name;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public override string Description => _tool.Description ?? string.Empty;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public override JsonElement JsonSchema => AIFunctionUtilities.MapToJsonElement(_tool);
|
public override JsonElement JsonSchema => AIFunctionUtilities.MapToJsonElement(_tool);
|
||||||
|
|
@ -42,14 +45,9 @@ public class McpAIFunction : AIFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call the tool through mcpdotnet
|
// Call the tool through mcpdotnet
|
||||||
var result = await _client.CallToolAsync(
|
var result = await _client.CallToolAsync(_tool.Name, argDict, cancellationToken);
|
||||||
_tool.Name,
|
|
||||||
argDict.Count == 0 ? [] : argDict,
|
|
||||||
cancellationToken: cancellationToken
|
|
||||||
);
|
|
||||||
|
|
||||||
// Extract the text content from the result
|
// Extract the text content from the result.
|
||||||
// For simplicity in this sample, we'll just concatenate all text content
|
|
||||||
return string.Join("\n", result.Content
|
return string.Join("\n", result.Content
|
||||||
.Where(c => c.Type == "text")
|
.Where(c => c.Type == "text")
|
||||||
.Select(c => c.Text));
|
.Select(c => c.Text));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue