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

Fix merge conflicts in feature-openapi #285

Merged
merged 21 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8f6dcb9
Add OpenAI GPT tokenizer class (#148)
dluc Mar 27, 2023
72ebfa2
Bump Microsoft.Azure.Functions.Worker from 1.10.1 to 1.13.0 in /dotne…
dependabot[bot] Mar 28, 2023
ed447a6
Small fix to TimeSkill minutes and seconds (#184)
RogerBarreto Mar 28, 2023
5cc4777
Extend AI support: add ChatGPT, add DallE, allow custom/any models (#…
dluc Mar 28, 2023
114d771
Cosmetic: More precise prompts for better chat demo. (#157)
sanjeev3 Mar 28, 2023
49c4884
Added prompt normalization for OpenAI requests (#185)
dmytrostruk Mar 28, 2023
8bbd432
Upgrade notebooks to new nuget version (#194)
dluc Mar 28, 2023
ab80c7c
Update README and lock notebooks to 0.9 (#206)
dluc Mar 29, 2023
e3e3fc3
add nuget sources troubleshooting (#223)
danmarshall Mar 30, 2023
0963e22
Memory - Qdrant Vector Database Connector (#210)
tawalke Mar 30, 2023
215933e
Name refactoring + move OpenAI code to Connectors namespace (#204)
dluc Mar 30, 2023
ad77101
Add FileCompression skill (#82)
glahaye Mar 30, 2023
b86e2dd
Update API for getting-started-notebook (#221)
alexchaomander Mar 30, 2023
05f7b10
HuggingFace service for text completion and embedding generation (#231)
dmytrostruk Mar 31, 2023
bcd740b
Remove files that could contain secrets (#244)
dluc Mar 31, 2023
6e2d314
Change visibility modifiers on MemoryRecord and associated collection…
craigomatic Mar 31, 2023
24503c9
Fix Github skill to better support DB backed memory stores (#254)
craigomatic Mar 31, 2023
d94d5c6
Remove unnecessary finalizer of the OpenAIClientAbstract class. (#253)
SergeyMenshykh Mar 31, 2023
cf1d2b4
Update README.md (#263)
Qworg Apr 1, 2023
9a825d0
Fix nuget, include tokenizer data files into the output dir (#269)
dluc Apr 2, 2023
eb40c60
Merge branch 'main' into feature-openapi
adrianwyatt Apr 3, 2023
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ Here is a quick example of how to use Semantic Kernel from a C# console app.

```csharp
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.KernelExtensions;
using Microsoft.SemanticKernel.Configuration;

var kernel = Kernel.Builder.Build();

// For Azure Open AI details please see
// https://learn.microsoft.com/azure/cognitive-services/openai/quickstart?pivots=rest-api
kernel.Config.AddAzureOpenAITextCompletionService(
kernel.Config.AddAzureOpenAITextCompletion(
"davinci-azure", // Alias used by the kernel
"text-davinci-003", // Azure OpenAI *Deployment ID*
"https://contoso.openai.azure.com/", // Azure OpenAI *Endpoint*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.IO;
using System.Reflection;

namespace Microsoft.SemanticKernel.Connectors.OpenAI.Tokenizers.Settings;

Expand Down Expand Up @@ -37,16 +38,46 @@ internal static string ReadEncodingTable()
/// <exception cref="FileNotFoundException">Error in case the file doesn't exist</exception>
private static string ReadFile(string fileName)
{
// Assume the class namespace matches the directory structure to find the file
var dir = s_namespace
// Assume the class namespace matches the directory structure
var currentClassDir = s_namespace
.Replace(PrefixToIgnore, "", StringComparison.OrdinalIgnoreCase)
.Trim('.')
.Replace('.', Path.DirectorySeparatorChar);

var file = Path.Join(dir, fileName);
// Check the execution assembly directory first
var assembly1 = Assembly.GetExecutingAssembly();
var assembly1Dir = Path.GetDirectoryName(Path.GetFullPath(assembly1.Location));

if (!File.Exists(file)) { throw new FileNotFoundException(file); }
// Concatenate assembly location with class namespace with file name
var filePath1 = Path.Join(assembly1Dir, currentClassDir, fileName);
if (File.Exists(filePath1))
{
return File.ReadAllText(filePath1);
}

return File.ReadAllText(file);
// Check the current assembly, in case that's a different file on a different directory
Assembly? assembly2 = Assembly.GetAssembly(typeof(EmbeddedResource));
if (assembly2 == null)
{
throw new FileNotFoundException($"{fileName} not found, path: '{filePath1}'");
}

// Path where the assembly is
var assembly2Dir = Path.GetDirectoryName(Path.GetFullPath(assembly2.Location));

// No need to continue if the path is the same
if (assembly2Dir == assembly1Dir)
{
throw new FileNotFoundException($"{fileName} not found, path: '{filePath1}'");
}

// Concatenate assembly location with class namespace with file name
var filePath2 = Path.Join(assembly2Dir, currentClassDir, fileName);
if (File.Exists(filePath2))
{
return File.ReadAllText(filePath2);
}

throw new FileNotFoundException($"{fileName} not found, paths: '{filePath1}', '{filePath2}'");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public override int GetHashCode()
return left.CompareTo(right) >= 0;
}


[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1000:Do not declare static members on generic types", Justification = "Min value convenience method")]
public static ScoredValue<T> Min()
{
Expand Down
13 changes: 13 additions & 0 deletions dotnet/src/SemanticKernel/SemanticKernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,17 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
<None Remove="Connectors\OpenAI\Tokenizers\Settings\encoder.json" />
<Content Include="Connectors\OpenAI\Tokenizers\Settings\encoder.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
<None Remove="Connectors\OpenAI\Tokenizers\Settings\vocab.bpe" />
<Content Include="Connectors\OpenAI\Tokenizers\Settings\vocab.bpe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
</ItemGroup>
</Project>
17 changes: 0 additions & 17 deletions samples/apps/github-qna-webapp-react/.env

This file was deleted.

12 changes: 6 additions & 6 deletions samples/dotnet/FileCompression/FileCompressionSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ public FileCompressionSkill(IFileCompressor fileCompressor, ILogger<FileCompress
[SKFunctionContextParameter(Name = Parameters.DestinationFilePath, Description = "Path of compressed file to create")]
public async Task<string?> CompressFileAsync(string sourceFilePath, SKContext context)
{
this._logger.LogTrace($"{nameof(CompressFileAsync)} got called");
this._logger.LogTrace($"{nameof(this.CompressFileAsync)} got called");

if (!context.Variables.Get(Parameters.DestinationFilePath, out string destinationFilePath))
{
const string errorMessage = $"Missing context variable {Parameters.DestinationFilePath} in {nameof(CompressFileAsync)}";
const string errorMessage = $"Missing context variable {Parameters.DestinationFilePath} in {nameof(this.CompressFileAsync)}";
this._logger.LogError(errorMessage);
context.Fail(errorMessage);

Expand All @@ -97,11 +97,11 @@ await this._fileCompressor.CompressFileAsync(Environment.ExpandEnvironmentVariab
[SKFunctionContextParameter(Name = Parameters.DestinationFilePath, Description = "Path of compressed file to create")]
public async Task<string?> CompressDirectoryAsync(string sourceDirectoryPath, SKContext context)
{
this._logger.LogTrace($"{nameof(CompressDirectoryAsync)} got called");
this._logger.LogTrace($"{nameof(this.CompressDirectoryAsync)} got called");

if (!context.Variables.Get(Parameters.DestinationFilePath, out string destinationFilePath))
{
const string errorMessage = $"Missing context variable {Parameters.DestinationFilePath} in {nameof(CompressDirectoryAsync)}";
const string errorMessage = $"Missing context variable {Parameters.DestinationFilePath} in {nameof(this.CompressDirectoryAsync)}";
this._logger.LogError(errorMessage);
context.Fail(errorMessage);

Expand All @@ -127,11 +127,11 @@ await this._fileCompressor.CompressDirectoryAsync(Environment.ExpandEnvironmentV
[SKFunctionContextParameter(Name = Parameters.DestinationDirectoryPath, Description = "Directory into which to extract the decompressed content")]
public async Task<string?> DecompressFileAsync(string sourceFilePath, SKContext context)
{
this._logger.LogTrace($"{nameof(DecompressFileAsync)} got called");
this._logger.LogTrace($"{nameof(this.DecompressFileAsync)} got called");

if (!context.Variables.Get(Parameters.DestinationDirectoryPath, out string destinationDirectoryPath))
{
const string errorMessage = $"Missing context variable {Parameters.DestinationDirectoryPath} in {nameof(DecompressFileAsync)}";
const string errorMessage = $"Missing context variable {Parameters.DestinationDirectoryPath} in {nameof(this.DecompressFileAsync)}";
this._logger.LogError(errorMessage);
context.Fail(errorMessage);

Expand Down