Skip to content

Commit

Permalink
.Net Removing IPlan interface (#3265)
Browse files Browse the repository at this point in the history
### Motivation and Context

IPlan interface has not definition and all Plan implementations actually
implement ISKFunction members.

Currently there is no need to have this as a `Flag interface`.

### Description

Removing `IPlan` interface and pointing all its dependencies to
`ISKFunction` directly.

### Contribution Checklist

- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [SK Contribution
Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄
  • Loading branch information
RogerBarreto authored Oct 24, 2023
1 parent 5bfff5d commit 5cad783
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 3 additions & 0 deletions dotnet/src/SemanticKernel.Core/Planning/IPlan.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Copyright (c) Microsoft. All rights reserved.

using System;

namespace Microsoft.SemanticKernel.Planning;

/// <summary>
/// Interface for standard Semantic Kernel callable plan.
/// </summary>
[Obsolete("This interface is obsoleted, use ISKFunction interface instead")]
public interface IPlan : ISKFunction
{
}
8 changes: 4 additions & 4 deletions dotnet/src/SemanticKernel.Core/Planning/InstrumentedPlan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Microsoft.SemanticKernel.Planning;
/// <summary>
/// Standard Semantic Kernel callable plan with instrumentation.
/// </summary>
internal sealed class InstrumentedPlan : IPlan
internal sealed class InstrumentedPlan : ISKFunction
{
/// <inheritdoc/>
public string Name => this._plan.Name;
Expand All @@ -31,10 +31,10 @@ internal sealed class InstrumentedPlan : IPlan
/// <summary>
/// Initialize a new instance of the <see cref="InstrumentedPlan"/> class.
/// </summary>
/// <param name="plan">Instance of <see cref="IPlan"/> to decorate.</param>
/// <param name="plan">Instance of <see cref="Plan"/> to decorate.</param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> to use for logging. If null, no logging will be performed.</param>
public InstrumentedPlan(
IPlan plan,
ISKFunction plan,
ILoggerFactory? loggerFactory = null)
{
this._plan = plan;
Expand All @@ -59,7 +59,7 @@ public async Task<FunctionResult> InvokeAsync(

#region private ================================================================================

private readonly IPlan _plan;
private readonly ISKFunction _plan;
private readonly ILogger _logger;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion dotnet/src/SemanticKernel.Core/Planning/Plan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.SemanticKernel.Planning;
/// Plan is used to create trees of <see cref="ISKFunction"/>s.
/// </summary>
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public sealed class Plan : IPlan
public sealed class Plan : ISKFunction
{
/// <summary>
/// State of the plan
Expand Down
12 changes: 12 additions & 0 deletions dotnet/src/SemanticKernel.Core/Planning/PlanExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Linq;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -73,7 +74,18 @@ public static string ToPlanString(this Plan plan, string indent = " ")
/// </summary>
/// <param name="plan">Instance of <see cref="IPlan"/> to decorate.</param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> to use for logging. If null, no logging will be performed.</param>
[Obsolete("Use concrete class Plan WithInstrumentation instead")]
public static IPlan WithInstrumentation(this IPlan plan, ILoggerFactory? loggerFactory = null)
{
throw new NotSupportedException("This method is obsolete, use concrete class Plan WithInstrumentation instead");
}

/// <summary>
/// Returns decorated instance of <see cref="ISKFunction"/> with plan enabled instrumentation.
/// </summary>
/// <param name="plan">Instance of <see cref="Plan"/> to decorate.</param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> to use for logging. If null, no logging will be performed.</param>
public static ISKFunction WithInstrumentation(this Plan plan, ILoggerFactory? loggerFactory = null)
{
return new InstrumentedPlan(plan, loggerFactory);
}
Expand Down

0 comments on commit 5cad783

Please sign in to comment.