Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into openaiclientbasecle…
Browse files Browse the repository at this point in the history
…anup
  • Loading branch information
stephentoub committed May 4, 2023
2 parents e3f5eca + 9917ca3 commit 7ccdc46
Show file tree
Hide file tree
Showing 74 changed files with 1,088 additions and 779 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions:
contents: read

jobs:
build:
dotnet-build-and-test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,31 @@ on:
branches: [ "main", "feature*" ]

jobs:
check-for-dotnet-changes:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.filter.outputs.dotnet}}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
dotnet:
- 'dotnet/**'
- 'samples/dotnet/**'
- uses: actions/checkout@v3
# run only if 'dotnet' files were changed
- name: dotnet changes found
if: steps.filter.outputs.dotnet == 'true'
run: echo "dotnet file"
# run only if not 'dotnet' files were changed
- name: no dotnet changes found
if: steps.filter.outputs.dotnet != 'true'
run: echo "NOT dotnet file"

check-format:
needs: check-for-dotnet-changes
if: needs.check-for-dotnet-changes.outputs.output1 == 'true'
runs-on: ubuntu-latest

steps:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/dotnet-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
workflow_dispatch:
push:
branches: ["main", "feature*"]
paths:
- 'dotnet/**'
- 'samples/dotnet/**'

permissions:
contents: read
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/dotnet-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,35 @@ permissions:
contents: read

jobs:
check-for-dotnet-changes:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.filter.outputs.dotnet}}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
dotnet:
- 'dotnet/**'
- 'samples/dotnet/**'
- uses: actions/checkout@v3
# run only if 'dotnet' files were changed
- name: dotnet changes found
if: steps.filter.outputs.dotnet == 'true'
run: echo "dotnet file"
# run only if not 'dotnet' files were changed
- name: no dotnet changes found
if: steps.filter.outputs.dotnet != 'true'
run: echo "NOT dotnet file"

build:
strategy:
matrix:
os: [ubuntu-latest]
configuration: [Release, Debug]
runs-on: ${{ matrix.os }}
needs: check-for-dotnet-changes
env:
NUGET_CERT_REVOCATION_MODE: offline
steps:
Expand All @@ -27,13 +50,15 @@ jobs:
clean: true

- name: Setup .NET
if: needs.check-for-dotnet-changes.outputs.output1 == 'true'
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
env:
NUGET_AUTH_TOKEN: ${{ secrets.GPR_READ_TOKEN }}

- uses: actions/cache@v3
if: needs.check-for-dotnet-changes.outputs.output1 == 'true'
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
Expand All @@ -43,28 +68,33 @@ jobs:
- name: Find solutions
shell: bash
if: needs.check-for-dotnet-changes.outputs.output1 == 'true'
run: echo "solutions=$(find ./ -type f -name "*.sln" | tr '\n' ' ')" >> $GITHUB_ENV

- name: Restore dependencies
shell: bash
if: needs.check-for-dotnet-changes.outputs.output1 == 'true'
run: |
for solution in ${{ env.solutions }}; do
dotnet restore $solution
done
- name: Build
shell: bash
if: needs.check-for-dotnet-changes.outputs.output1 == 'true'
run: |
for solution in ${{ env.solutions }}; do
dotnet build $solution --no-restore --configuration ${{ matrix.configuration }}
done
- name: Find unit test projects
shell: bash
if: needs.check-for-dotnet-changes.outputs.output1 == 'true'
run: echo "projects=$(find ./dotnet -type f -name "*.UnitTests.csproj" | tr '\n' ' ')" >> $GITHUB_ENV

- name: Test
shell: bash
if: needs.check-for-dotnet-changes.outputs.output1 == 'true'
run: |
for project in ${{ env.projects }}; do
dotnet test $project --no-build --verbosity normal --logger trx --results-directory ./TestResults --configuration ${{ matrix.configuration }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ on:
branches: [ "main", "feature*" ]

jobs:
paths-filter:
check-for-python-changes:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.filter.outputs.python}}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
python:
- 'python/**'
- uses: actions/checkout@v3
# run only if 'python' files were changed
- name: python tests
- name: python changes found
if: steps.filter.outputs.python == 'true'
run: echo "Python file"
# run only if not 'python' files were changed
- name: not python tests
- name: no python changes found
if: steps.filter.outputs.python != 'true'
run: echo "NOT python file"

Expand All @@ -32,8 +32,8 @@ jobs:
matrix:
python-version: ["3.8"]
runs-on: ubuntu-latest
needs: paths-filter
if: needs.paths-filter.outputs.output1 == 'true'
needs: check-for-python-changes
if: needs.check-for-python-changes.outputs.output1 == 'true'
timeout-minutes: 5
steps:
- run: echo "/root/.local/bin" >> $GITHUB_PATH
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:
branches: ["main"]
paths:
- "samples/"
- 'samples/**'

jobs:
build:
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/python-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# This workflow will run all python integrations tests.
#

name: Python Integration Tests

on:
workflow_dispatch:
push:
branches: [ "main"]
paths:
- 'python/**'
schedule:
- cron: '0 */12 * * *' # Run every 12 hours: midnight UTC and noon UTC


permissions:
contents: read

jobs:
python-integration-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ ubuntu-latest, windows-latest, macos-latest ]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry pytest
cd python && poetry install
- name: Run Integration Tests
shell: bash
env: # Set Azure credentials secret as an input
Python_Integration_Tests: Python_Integration_Tests
AzureOpenAI__Label: azure-text-davinci-003
AzureOpenAIEmbedding__Label: azure-text-embedding-ada-002
AzureOpenAI__DeploymentName: ${{ vars.AZUREOPENAI__DEPLOYMENTNAME }}
AzureOpenAIChat__DeploymentName: ${{ vars.AZUREOPENAI__CHAT__DEPLOYMENTNAME }}
AzureOpenAIEmbeddings__DeploymentName: ${{ vars.AZUREOPENAIEMBEDDING__DEPLOYMENTNAME }}
AzureOpenAI__Endpoint: ${{ secrets.AZUREOPENAI__ENDPOINT }}
AzureOpenAIEmbeddings__Endpoint: ${{ secrets.AZUREOPENAI__ENDPOINT }}
AzureOpenAI__ApiKey: ${{ secrets.AZUREOPENAI__APIKEY }}
AzureOpenAIEmbeddings__ApiKey: ${{ secrets.AZUREOPENAI__APIKEY }}
Bing__ApiKey: ${{ secrets.BING__APIKEY }}
OpenAI__ApiKey: ${{ secrets.OPENAI__APIKEY }}
run: |
cd python
poetry run pytest ./tests/integration
16 changes: 8 additions & 8 deletions .github/workflows/python-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
name: Python tests
name: Python Unit Tests

on:
workflow_dispatch:
pull_request:
branches: [ "main", "feature*" ]

jobs:
paths-filter:
check-for-python-changes:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.filter.outputs.python}}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
python:
- 'python/**'
- uses: actions/checkout@v3
# run only if 'python' files were changed
- name: python tests
- name: python changes found
if: steps.filter.outputs.python == 'true'
run: echo "Python file"
# run only if not 'python' files were changed
- name: not python tests
- name: no python changes found
if: steps.filter.outputs.python != 'true'
run: echo "NOT python file"

build:
python-unit-tests:
runs-on: ${{ matrix.os }}
needs: paths-filter
if: needs.paths-filter.outputs.output1 == 'true'
needs: check-for-python-changes
if: needs.check-for-python-changes.outputs.output1 == 'true'
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion dotnet/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<AnalysisLevel>latest</AnalysisLevel>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>11</LangVersion>
<LangVersion>10</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
</PropertyGroup>
Expand Down
23 changes: 0 additions & 23 deletions dotnet/common.props

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ private protected virtual void AddRequestHeaders(HttpRequestMessage request)
#region private ================================================================================

// Shared singleton HttpClientHandler used when an existing HttpClient isn't provided
private readonly static HttpClientHandler s_defaultHttpClientHandler = new() { CheckCertificateRevocationList = true };
private static readonly HttpClientHandler s_defaultHttpClientHandler = new() { CheckCertificateRevocationList = true };

// HTTP user agent sent to remote endpoints
private const string HttpUserAgent = "Microsoft Semantic Kernel";
private const string HttpUserAgent = "Microsoft-Semantic-Kernel";

// Set to true to dispose of HttpClient when disposing. If HttpClient was passed in, then the caller can manage.
private readonly bool _disposeHttpClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ public async Task CanCallGetAvailableFunctionsWithFunctionsAsync()
x.SearchAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<double>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()))
.Returns(asyncEnumerable);

skills.Setup(x => x.HasFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
skills.Setup(x => x.HasSemanticFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
skills.Setup(x => x.HasNativeFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
skills.Setup(x => x.TryGetFunction(It.IsAny<string>(), It.IsAny<string>(), out It.Ref<ISKFunction?>.IsAny)).Returns(true);
skills.Setup(x => x.TryGetSemanticFunction(It.IsAny<string>(), It.IsAny<string>(), out It.Ref<ISKFunction?>.IsAny)).Returns(true);
skills.Setup(x => x.TryGetNativeFunction(It.IsAny<string>(), It.IsAny<string>(), out It.Ref<ISKFunction?>.IsAny)).Returns(true);
skills.Setup(x => x.GetSemanticFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(mockSemanticFunction.Object);
skills.Setup(x => x.GetNativeFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(mockNativeFunction.Object);
skills.Setup(x => x.GetFunctionsView(It.IsAny<bool>(), It.IsAny<bool>())).Returns(functionsView);
Expand Down Expand Up @@ -163,9 +163,9 @@ public async Task CanCallGetAvailableFunctionsWithFunctionsWithRelevancyAsync()
x.SearchAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<double>(), It.IsAny<bool>(), It.IsAny<CancellationToken>()))
.Returns(asyncEnumerable);

skills.Setup(x => x.HasFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
skills.Setup(x => x.HasSemanticFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
skills.Setup(x => x.HasNativeFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
skills.Setup(x => x.TryGetFunction(It.IsAny<string>(), It.IsAny<string>(), out It.Ref<ISKFunction?>.IsAny)).Returns(true);
skills.Setup(x => x.TryGetSemanticFunction(It.IsAny<string>(), It.IsAny<string>(), out It.Ref<ISKFunction?>.IsAny)).Returns(true);
skills.Setup(x => x.TryGetNativeFunction(It.IsAny<string>(), It.IsAny<string>(), out It.Ref<ISKFunction?>.IsAny)).Returns(true);
skills.Setup(x => x.GetSemanticFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(mockSemanticFunction.Object);
skills.Setup(x => x.GetNativeFunction(It.IsAny<string>(), It.IsAny<string>())).Returns(mockNativeFunction.Object);
skills.Setup(x => x.GetFunctionsView(It.IsAny<bool>(), It.IsAny<bool>())).Returns(functionsView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ private static Mock<ISKFunction> CreateMockFunction(FunctionView functionView, s
{
skills.Setup(x => x.GetSemanticFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name)))
.Returns(mockFunction.Object);
skills.Setup(x => x.HasSemanticFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name))).Returns(true);
ISKFunction? outFunc = mockFunction.Object;
skills.Setup(x => x.TryGetSemanticFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name), out outFunc)).Returns(true);
}
else
{
skills.Setup(x => x.GetNativeFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name)))
.Returns(mockFunction.Object);
skills.Setup(x => x.HasNativeFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name))).Returns(true);
ISKFunction? outFunc = mockFunction.Object;
skills.Setup(x => x.TryGetNativeFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name), out outFunc)).Returns(true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ public async Task ItCanCreatePlanAsync(string goal)
{
skills.Setup(x => x.GetSemanticFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name)))
.Returns(mockFunction.Object);
skills.Setup(x => x.HasSemanticFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name))).Returns(true);
ISKFunction? outFunc = mockFunction.Object;
skills.Setup(x => x.TryGetSemanticFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name), out outFunc)).Returns(true);
}
else
{
skills.Setup(x => x.GetNativeFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name)))
.Returns(mockFunction.Object);
skills.Setup(x => x.HasNativeFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name))).Returns(true);
ISKFunction? outFunc = mockFunction.Object;
skills.Setup(x => x.TryGetNativeFunction(It.Is<string>(s => s == skillName), It.Is<string>(s => s == name), out outFunc)).Returns(true);
}
}

Expand Down

0 comments on commit 7ccdc46

Please sign in to comment.