forked from microsoft/semantic-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.Net: Removing IsSemantic and IsAsync properties from ISKFunction and…
… FunctionView (microsoft#2881) ### Motivation and Context The Kernel no longer differentiates between Native and Semantic functions, nor between async and synchronous functions. These are abstractions that are resolved internally. ### Description ISKFunction - Removing IsSemantic - Updating tests and callers FunctionView - Removing IsSemantic - Removing IsAsync - Updating tests and callers ### 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 😄 BREAKING CHANGE - due to change in public APIs. Low impact. --------- Co-authored-by: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com>
- Loading branch information
1 parent
663f2b8
commit 0a0ad99
Showing
25 changed files
with
194 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
dotnet/src/InternalUtilities/src/Diagnostics/IsExternalInit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.ComponentModel; | ||
|
||
namespace System.Runtime.CompilerServices; | ||
|
||
/// <summary> | ||
/// Reserved to be used by the compiler for tracking metadata. | ||
/// This class should not be used by developers in source code. | ||
/// </summary> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
internal static class IsExternalInit | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 12 additions & 66 deletions
78
dotnet/src/SemanticKernel.Abstractions/SkillDefinition/FunctionView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,25 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
|
||
namespace Microsoft.SemanticKernel.SkillDefinition; | ||
|
||
/// <summary> | ||
/// Class used to copy and export data from the skill collection. | ||
/// The data is mutable, but changes do not affect the skill collection. | ||
/// A function view is a read-only representation of a function. | ||
/// </summary> | ||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | ||
public sealed class FunctionView | ||
/// <param name="Name">Name of the function. The name is used by the skill collection and in prompt templates e.g. {{skillName.functionName}}</param> | ||
/// <param name="SkillName">Name of the skill containing the function. The name is used by the skill collection and in prompt templates e.g. {{skillName.functionName}}</param> | ||
/// <param name="Description">Function description. The description is used in combination with embeddings when searching relevant functions.</param> | ||
/// <param name="Parameters">Optional list of function parameters</param> | ||
public sealed record FunctionView( | ||
string Name, | ||
string SkillName, | ||
string Description = "", | ||
IReadOnlyList<ParameterView>? Parameters = null) | ||
{ | ||
/// <summary> | ||
/// Name of the function. The name is used by the skill collection and in prompt templates e.g. {{skillName.functionName}} | ||
/// </summary> | ||
public string Name { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Name of the skill containing the function. The name is used by the skill collection and in prompt templates e.g. {{skillName.functionName}} | ||
/// </summary> | ||
public string SkillName { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Function description. The description is used in combination with embeddings when searching relevant functions. | ||
/// </summary> | ||
public string Description { get; set; } = string.Empty; | ||
|
||
/// <summary> | ||
/// Whether the delegate points to a semantic function | ||
/// </summary> | ||
public bool IsSemantic { get; set; } | ||
|
||
/// <summary> | ||
/// Whether the delegate is an asynchronous function | ||
/// </summary> | ||
public bool IsAsynchronous { get; set; } | ||
|
||
/// <summary> | ||
/// List of function parameters | ||
/// </summary> | ||
public IList<ParameterView> Parameters { get; set; } = new List<ParameterView>(); | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
public FunctionView() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Create a function view. | ||
/// </summary> | ||
/// <param name="name">Function name</param> | ||
/// <param name="skillName">Skill name, e.g. the function namespace</param> | ||
/// <param name="description">Function description</param> | ||
/// <param name="parameters">List of function parameters provided by the skill developer</param> | ||
/// <param name="isSemantic">Whether the function is a semantic one (or native is False)</param> | ||
/// <param name="isAsynchronous">Whether the function is async. Note: all semantic functions are async.</param> | ||
public FunctionView( | ||
string name, | ||
string skillName, | ||
string description, | ||
IList<ParameterView> parameters, | ||
bool isSemantic, | ||
bool isAsynchronous = true) | ||
{ | ||
this.Name = name; | ||
this.SkillName = skillName; | ||
this.Description = description; | ||
this.Parameters = parameters; | ||
this.IsSemantic = isSemantic; | ||
this.IsAsynchronous = isAsynchronous; | ||
} | ||
|
||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] | ||
private string DebuggerDisplay => $"{this.Name} ({this.Description})"; | ||
public IReadOnlyList<ParameterView> Parameters { get; init; } = Parameters ?? Array.Empty<ParameterView>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 10 additions & 69 deletions
79
dotnet/src/SemanticKernel.Abstractions/SkillDefinition/ParameterView.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,16 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
|
||
using System.Diagnostics; | ||
using Microsoft.SemanticKernel.Diagnostics; | ||
|
||
namespace Microsoft.SemanticKernel.SkillDefinition; | ||
|
||
/// <summary> | ||
/// Class used to copy and export data about parameters | ||
/// for planner and related scenarios. | ||
/// Class used to copy and export data about parameters for planner and related scenarios. | ||
/// </summary> | ||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | ||
public sealed class ParameterView | ||
{ | ||
private string _name = string.Empty; | ||
|
||
/// <summary> | ||
/// Parameter name. Alphanumeric chars + "_" only. | ||
/// </summary> | ||
public string Name | ||
{ | ||
get => this._name; | ||
set | ||
{ | ||
Verify.ValidFunctionParamName(value); | ||
this._name = value; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Parameter description. | ||
/// </summary> | ||
public string? Description { get; set; } | ||
|
||
/// <summary> | ||
/// Default value when the value is not provided. | ||
/// </summary> | ||
public string? DefaultValue { get; set; } | ||
|
||
/// <summary> | ||
/// Parameter type. | ||
/// </summary> | ||
public ParameterViewType? Type { get; set; } | ||
|
||
/// <summary> | ||
/// Constructor | ||
/// </summary> | ||
public ParameterView() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Create a function parameter view, using information provided by the skill developer. | ||
/// </summary> | ||
/// <param name="name">Parameter name. The name must be alphanumeric (underscore is the only special char allowed).</param> | ||
/// <param name="description">Parameter description</param> | ||
/// <param name="defaultValue">Default parameter value, if not provided</param> | ||
/// <param name="type">Parameter type.</param> | ||
public ParameterView( | ||
string name, | ||
string? description = null, | ||
string? defaultValue = null, | ||
ParameterViewType? type = null) | ||
{ | ||
this.Name = name; | ||
this.Description = description; | ||
this.DefaultValue = defaultValue; | ||
this.Type = type; | ||
} | ||
|
||
[DebuggerBrowsable(DebuggerBrowsableState.Never)] | ||
private string DebuggerDisplay => string.IsNullOrEmpty(this.Description) | ||
? this.Name | ||
: $"{this.Name} ({this.Description})"; | ||
} | ||
/// <param name="Name">Parameter name. The name must be alphanumeric (underscore is the only special char allowed).</param> | ||
/// <param name="Description">Parameter description</param> | ||
/// <param name="DefaultValue">Default parameter value, if not provided</param> | ||
/// <param name="Type">Parameter type.</param> | ||
public sealed record ParameterView( | ||
string Name, | ||
string? Description = null, | ||
string? DefaultValue = null, | ||
ParameterViewType? Type = null); |
Oops, something went wrong.