Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
33 changes: 33 additions & 0 deletions dotnet/IF-SK-dotnet.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path="../.editorconfig" />
<File Path="../.github/workflows/dotnet-format.yml" />
<File Path="../.gitignore" />
<File Path="../nuget.config" />
<File Path="../README.md" />
<File Path="Directory.Build.props" />
<File Path="Directory.Build.targets" />
<File Path="Directory.Packages.props" />
<File Path="docs/EXPERIMENTS.md" />
<File Path="global.json" />
</Folder>
<Folder Name="/Solution Items/nuget/">
<File Path="nuget/icon.png" />
<File Path="nuget/nuget-package.props" />
<File Path="nuget/NUGET.md" />
<File Path="nuget/VECTORDATA-CONNECTORS-NUGET.md" />
</Folder>
<Folder Name="/src/">
<Project Path="src/SemanticKernel.Abstractions/SemanticKernel.Abstractions.csproj" />
<Project Path="src/SemanticKernel.Core/SemanticKernel.Core.csproj" />
<Project Path="src/SemanticKernel.UnitTests/SemanticKernel.UnitTests.csproj" />
</Folder>
<Folder Name="/src/connectors/" />
<Folder Name="/src/connectors/AI/">
<Project Path="src/Connectors/Connectors.AzureOpenAI.UnitTests/Connectors.AzureOpenAI.UnitTests.csproj" />
<Project Path="src/Connectors/Connectors.AzureOpenAI/Connectors.AzureOpenAI.csproj" />
</Folder>
<Folder Name="/src/VectorData/">
<Project Path="src/VectorData/VectorData.Abstractions/VectorData.Abstractions.csproj" />
</Folder>
</Solution>
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,24 @@
<Description>Semantic Kernel interfaces and abstractions. This package is automatically installed by Semantic Kernel packages if needed.</Description>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
<DefineConstants>$(DefineConstants);UNITY</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
<DefineConstants>$(DefineConstants);UNITY</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Publish|netstandard2.0|AnyCPU'">
<DefineConstants>$(DefineConstants);UNITY</DefineConstants>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\VectorData\VectorData.Abstractions\VectorData.Abstractions.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.HashCode" />
<!--<PackageReference Include="Microsoft.Bcl.HashCode" />-->
<PackageReference Include="Microsoft.Extensions.AI" />
</ItemGroup>

Expand All @@ -54,7 +66,7 @@
<Compile Remove="$(RepoRoot)/dotnet/src/InternalUtilities/src/Type/**/*.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />

<!-- Gets included multiple times, causing CS1685 on RuntimeHelpers (and not really needed in this project) -->
<Compile Remove="$(RepoRoot)/dotnet/src/InternalUtilities/src/System/IndexRange.cs" Link="%(RecursiveDir)%(Filename)%(Extension)"/>
<Compile Remove="$(RepoRoot)/dotnet/src/InternalUtilities/src/System/IndexRange.cs" Link="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#if UNITY

namespace System;

/// <summary>
/// Provides utility methods for combining hash codes of multiple values.
/// </summary>
/// <remarks>This class is designed to assist in generating composite hash codes for multiple values. It uses a
/// standard hash code combination algorithm to ensure a good distribution of hash values.</remarks>
/// <remarks>This implementation does not use Microsoft.Bcl.HashCode because that library conflicts with Unity pipeline and splines.</remarks>
internal static class HashCodeSlim
{
public static int Combine<T1, T2, T3>(T1 value1, T2 value2, T3 value3)
{
unchecked
{
int hash = 17;
hash = hash * 31 + (value1?.GetHashCode() ?? 0);
hash = hash * 31 + (value2?.GetHashCode() ?? 0);
hash = hash * 31 + (value3?.GetHashCode() ?? 0);
return hash;
}
}

public static int Combine<T1, T2, T3, T4, T5>(T1 value1, T2 value2, T3 value3, T4 value4, T5 value5)
{
unchecked
{
int hash = 17;
hash = hash * 31 + (value1?.GetHashCode() ?? 0);
hash = hash * 31 + (value2?.GetHashCode() ?? 0);
hash = hash * 31 + (value3?.GetHashCode() ?? 0);
hash = hash * 31 + (value4?.GetHashCode() ?? 0);
hash = hash * 31 + (value5?.GetHashCode() ?? 0);
return hash;
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,15 @@ public override bool Equals(object? obj)
}

/// <inheritdoc/>
public override int GetHashCode() => HashCode.Combine(nameof(ChatHistorySummarizationReducer), this._thresholdCount, this._targetCount, this.SummarizationInstructions, this.UseSingleSummary);
public override int GetHashCode()
{
#if UNITY
return HashCodeSlim.Combine(nameof(ChatHistorySummarizationReducer), this._thresholdCount, this._targetCount, this.SummarizationInstructions, this.UseSingleSummary);
#else
return HashCode.Combine(nameof(ChatHistorySummarizationReducer), this._thresholdCount, this._targetCount, this.SummarizationInstructions, this.UseSingleSummary);

#endif
}
private readonly IChatCompletionService _service;
private readonly int _thresholdCount;
private readonly int _targetCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ public override bool Equals(object? obj)
}

/// <inheritdoc/>
public override int GetHashCode() => HashCode.Combine(nameof(ChatHistoryTruncationReducer), this._thresholdCount, this._targetCount);
public override int GetHashCode()
{
#if UNITY
return HashCodeSlim.Combine(nameof(ChatHistoryTruncationReducer), this._thresholdCount, this._targetCount);
#else
return HashCode.Combine(nameof(ChatHistoryTruncationReducer), this._thresholdCount, this._targetCount);
#endif
}

private readonly int _thresholdCount;
private readonly int _targetCount;
Expand Down
14 changes: 13 additions & 1 deletion dotnet/src/SemanticKernel.Core/SemanticKernel.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
</Description>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
<DefineConstants>$(DefineConstants);UNITY</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.0|AnyCPU'">
<DefineConstants>$(DefineConstants);UNITY</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Publish|netstandard2.0|AnyCPU'">
<DefineConstants>$(DefineConstants);UNITY</DefineConstants>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="SemanticKernel.UnitTests" />
<InternalsVisibleTo Include="SemanticKernel.AotTests" />
Expand All @@ -35,7 +47,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="System.Numerics.Tensors" />
<!--<PackageReference Include="System.Numerics.Tensors" />-->
</ItemGroup>

<ItemGroup>
Expand Down