Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net Removing IPlan interface #3265

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
RogerBarreto marked this conversation as resolved.
Show resolved Hide resolved
{
/// <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
14 changes: 13 additions & 1 deletion 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 @@ -68,13 +69,24 @@ public static string ToPlanString(this Plan plan, string indent = " ")
return planString;
}

/// <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 ISKFunction plan, ILoggerFactory? loggerFactory = null)
RogerBarreto marked this conversation as resolved.
Show resolved Hide resolved
{
return new InstrumentedPlan(plan, loggerFactory);
}

/// <summary>
/// Returns decorated instance of <see cref="IPlan"/> with enabled instrumentation.
/// </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)
{
return new InstrumentedPlan(plan, loggerFactory);
throw new NotSupportedException("This method is obsolete, use concrete class Plan WithInstrumentation instead");
dmytrostruk marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading