diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/AITool.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/AITool.cs
index ebbc6751c04..ab9f010ae57 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/AITool.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/AITool.cs
@@ -1,13 +1,55 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+using Microsoft.Shared.Collections;
+
namespace Microsoft.Extensions.AI;
+#pragma warning disable S1694 // An abstract class should have both abstract and concrete methods
+
/// Represents a tool that can be specified to an AI service.
-public class AITool
+[DebuggerDisplay("{DebuggerDisplay,nq}")]
+public abstract class AITool
{
/// Initializes a new instance of the class.
protected AITool()
{
}
+
+ /// Gets the name of the tool.
+ public virtual string Name => GetType().Name;
+
+ /// Gets a description of the tool, suitable for use in describing the purpose to a model.
+ public virtual string Description => string.Empty;
+
+ /// Gets any additional properties associated with the tool.
+ public virtual IReadOnlyDictionary AdditionalProperties => EmptyReadOnlyDictionary.Instance;
+
+ ///
+ public override string ToString() => Name;
+
+ /// Gets the string to display in the debugger for this instance.
+ [DebuggerBrowsable(DebuggerBrowsableState.Never)]
+ private string DebuggerDisplay
+ {
+ get
+ {
+ StringBuilder sb = new(Name);
+
+ if (Description is string description && !string.IsNullOrEmpty(description))
+ {
+ _ = sb.Append(" (").Append(description).Append(')');
+ }
+
+ foreach (var entry in AdditionalProperties)
+ {
+ _ = sb.Append(", ").Append(entry.Key).Append(" = ").Append(entry.Value);
+ }
+
+ return sb.ToString();
+ }
+ }
}
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/CodeInterpreterTool.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/CodeInterpreterTool.cs
new file mode 100644
index 00000000000..408810ca6f7
--- /dev/null
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/CodeInterpreterTool.cs
@@ -0,0 +1,17 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace Microsoft.Extensions.AI;
+
+/// Represents a tool that can be specified to an AI service to enable it to execute code it generates.
+///
+/// This tool does not itself implement code interpration. It is a marker that can be used to inform a service
+/// that the service is allowed to execute its generated code if the service is capable of doing so.
+///
+public class CodeInterpreterTool : AITool
+{
+ /// Initializes a new instance of the class.
+ public CodeInterpreterTool()
+ {
+ }
+}
diff --git a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunction.cs b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunction.cs
index 84cde4bc82a..667a956a2f7 100644
--- a/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunction.cs
+++ b/src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/AIFunction.cs
@@ -2,7 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
-using System.Diagnostics;
using System.Reflection;
using System.Text.Json;
using System.Threading;
@@ -12,15 +11,8 @@
namespace Microsoft.Extensions.AI;
/// Represents a function that can be described to an AI service and invoked.
-[DebuggerDisplay("{DebuggerDisplay,nq}")]
public abstract class AIFunction : AITool
{
- /// Gets the name of the function.
- public abstract string Name { get; }
-
- /// Gets a description of the function, suitable for use in describing the purpose to a model.
- public abstract string Description { get; }
-
/// Gets a JSON Schema describing the function and its input parameters.
///
///
@@ -56,11 +48,8 @@ public abstract class AIFunction : AITool
///
public virtual MethodInfo? UnderlyingMethod => null;
- /// Gets any additional properties associated with the function.
- public virtual IReadOnlyDictionary AdditionalProperties => EmptyReadOnlyDictionary.Instance;
-
/// Gets a that can be used to marshal function parameters.
- public virtual JsonSerializerOptions? JsonSerializerOptions => AIJsonUtilities.DefaultOptions;
+ public virtual JsonSerializerOptions JsonSerializerOptions => AIJsonUtilities.DefaultOptions;
/// Invokes the and returns its result.
/// The arguments to pass to the function's invocation.
@@ -75,9 +64,6 @@ public abstract class AIFunction : AITool
return InvokeCoreAsync(arguments, cancellationToken);
}
- ///
- public override string ToString() => Name;
-
/// Invokes the and returns its result.
/// The arguments to pass to the function's invocation.
/// The to monitor for cancellation requests.
@@ -85,8 +71,4 @@ public abstract class AIFunction : AITool
protected abstract Task