Skip to content

Commit 85d2fc6

Browse files
Merge branch 'main' into copilot/add-support-for-responses-api
2 parents fcec6d3 + d554049 commit 85d2fc6

File tree

102 files changed

+2277
-630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2277
-630
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ dotnet_diagnostic.CA1303.severity = none
236236
dotnet_diagnostic.CA1308.severity = none
237237
# Avoid uninstantiated internal classes
238238
dotnet_diagnostic.CA1812.severity = none
239+
# Avoid potentially expensive logging
240+
dotnet_diagnostic.CA1873.severity = none
239241
# Use the LoggerMessage delegates
240242
dotnet_diagnostic.CA1848.severity = none
241243
# Possible multiple enumerations of IEnumerable collection

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ jobs:
4444

4545
steps:
4646
- name: Checkout repository
47-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
47+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
4848

4949
- name: Setup .NET
50-
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
50+
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
5151
with:
52-
dotnet-version: 9.0.x
52+
dotnet-version: 10.0.x
5353

5454
# Initializes the CodeQL tools for scanning.
5555
- name: Initialize CodeQL
56-
uses: github/codeql-action/init@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3
56+
uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5
5757
with:
5858
languages: ${{ matrix.language }}
5959
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -81,4 +81,4 @@ jobs:
8181
run: dotnet build --no-restore -c Release
8282

8383
- name: Perform CodeQL Analysis
84-
uses: github/codeql-action/analyze@014f16e7ab1402f30e7c3329d33797e7948572db # v4.31.3
84+
uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # v4.31.5

.github/workflows/create-release.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ jobs:
3030
env:
3131
release: 'dev-proxy-${{ matrix.architecture }}-${{ github.ref_name }}'
3232
steps:
33-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
33+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
3434
- name: Setup .NET
35-
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
35+
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
3636
with:
37-
dotnet-version: 9.0.x
37+
dotnet-version: 10.0.x
3838
- name: Rename executable for beta
3939
if: contains(github.ref_name, '-beta')
4040
run: |
@@ -59,7 +59,7 @@ jobs:
5959
if: matrix.architecture == 'win-x64'
6060
run: dotnet build ./DevProxy.Abstractions/DevProxy.Abstractions.csproj -p:InformationalVersion=$("${{ github.ref_name }}".Substring(1)) -c Release --no-self-contained
6161
- name: Add plugins to output
62-
run: cp ./DevProxy/bin/Release/net9.0/${{ matrix.architecture }}/plugins ./${{ env.release }} -r
62+
run: cp ./DevProxy/bin/Release/net10.0/${{ matrix.architecture }}/plugins ./${{ env.release }} -r
6363
- name: Remove unnecessary files
6464
run: |
6565
pushd
@@ -112,7 +112,7 @@ jobs:
112112
shell: pwsh
113113
run: >
114114
./sign code azure-key-vault
115-
./DevProxy.Abstractions/bin/Release/net9.0/DevProxy.Abstractions.dll
115+
./DevProxy.Abstractions/bin/Release/net10.0/DevProxy.Abstractions.dll
116116
--publisher-name "${{ env.APP_PUBLISHER }}"
117117
--description "${{ env.APP_DESCRIPTION }}"
118118
--description-url "${{ env.APP_DESCRIPTION_URL }}"
@@ -127,7 +127,7 @@ jobs:
127127
uses: thedoctor0/zip-release@b57d897cb5d60cb78b51a507f63fa184cfe35554 # master
128128
with:
129129
filename: '../../../../DevProxy.Abstractions-${{ github.ref_name }}.zip'
130-
directory: './DevProxy.Abstractions/bin/Release/net9.0'
130+
directory: './DevProxy.Abstractions/bin/Release/net10.0'
131131
exclusions: '*.json'
132132
- name: Upload abstractions
133133
if: matrix.architecture == 'win-x64'
@@ -202,7 +202,7 @@ jobs:
202202
permissions:
203203
contents: write
204204
steps:
205-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
205+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
206206
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
207207
with:
208208
path: output
@@ -229,7 +229,7 @@ jobs:
229229
id-token: write
230230
steps:
231231
- name: Checkout repository
232-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
232+
uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
233233
# Required for multi-platform images
234234
- name: Set up QEMU
235235
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
@@ -246,7 +246,7 @@ jobs:
246246
password: ${{ secrets.GITHUB_TOKEN }}
247247
- name: Extract metadata (tags, labels) for Docker
248248
id: meta
249-
uses: docker/metadata-action@318604b99e75e41977312d83839a89be02ca4893 # v5.9.0
249+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
250250
with:
251251
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
252252
flavor: |

.github/workflows/dotnet.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ jobs:
1818
runs-on: ubuntu-latest
1919

2020
steps:
21-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
21+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
2222
- name: Setup .NET
23-
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0
23+
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
2424
with:
25-
dotnet-version: 9.0.x
25+
dotnet-version: 10.0.x
2626
- name: Restore workloads
2727
run: dotnet workload restore
2828
- name: Restore dependencies

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"request": "launch",
1111
"preLaunchTask": "build",
1212
// If you have changed target frameworks, make sure to update the program path.
13-
"program": "${workspaceFolder}/DevProxy/bin/Debug/net9.0/devproxy.dll",
13+
"program": "${workspaceFolder}/DevProxy/bin/Debug/net10.0/devproxy.dll",
1414
"args": [],
15-
"cwd": "${workspaceFolder}/DevProxy/bin/Debug/net9.0",
15+
"cwd": "${workspaceFolder}/DevProxy/bin/Debug/net10.0",
1616
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
1717
"console": "integratedTerminal",
1818
"stopAtEntry": false,

DevProxy.Abstractions/DevProxy.Abstractions.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net9.0</TargetFramework>
4+
<TargetFramework>net10.0</TargetFramework>
55
<RootNamespace>DevProxy.Abstractions</RootNamespace>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8-
<Version>1.3.0</Version>
8+
<Version>2.0.0</Version>
99
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
1010
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
1111
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

DevProxy.Abstractions/LanguageModel/OllamaLanguageModelClient.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ public sealed class OllamaLanguageModelClient(
5454

5555
if (Configuration.CacheResponses && _cacheChatCompletion.TryGetCacheValue(messages, out var cachedResponse))
5656
{
57-
Logger.LogDebug("Returning cached response for message: {LastMessage}", messages.Last().Content);
57+
if (Logger.IsEnabled(LogLevel.Debug))
58+
{
59+
Logger.LogDebug("Returning cached response for message: {LastMessage}", messages.Last().Content);
60+
}
5861
return cachedResponse;
5962
}
6063

@@ -181,7 +184,10 @@ protected override async Task<bool> IsEnabledCoreAsync(CancellationToken cancell
181184
try
182185
{
183186
var url = $"{Configuration.Url?.TrimEnd('/')}/api/chat";
184-
Logger.LogDebug("Requesting chat completion. Message: {LastMessage}", messages.Last().Content);
187+
if (Logger.IsEnabled(LogLevel.Debug))
188+
{
189+
Logger.LogDebug("Requesting chat completion. Message: {LastMessage}", messages.Last().Content);
190+
}
185191

186192
var response = await _httpClient.PostAsJsonAsync(url,
187193
new

DevProxy.Abstractions/LanguageModel/OpenAILanguageModelClient.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public sealed class OpenAILanguageModelClient(
6262

6363
if (Configuration.CacheResponses && _cacheChatCompletion.TryGetCacheValue(messages, out var cachedResponse))
6464
{
65-
_logger.LogDebug("Returning cached response for message: {LastMessage}", messages.Last().Content);
65+
if (_logger.IsEnabled(LogLevel.Debug))
66+
{
67+
_logger.LogDebug("Returning cached response for message: {LastMessage}", messages.Last().Content);
68+
}
6669
return cachedResponse;
6770
}
6871

@@ -148,7 +151,10 @@ protected override async Task<bool> IsEnabledCoreAsync(CancellationToken cancell
148151
try
149152
{
150153
var url = $"{Configuration.Url?.TrimEnd('/')}/chat/completions";
151-
_logger.LogDebug("Requesting chat completion. Message: {LastMessage}", messages.Last().Content);
154+
if (_logger.IsEnabled(LogLevel.Debug))
155+
{
156+
_logger.LogDebug("Requesting chat completion. Message: {LastMessage}", messages.Last().Content);
157+
}
152158

153159
var payload = new OpenAIChatCompletionRequest
154160
{

DevProxy.Abstractions/Models/MockResponse.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public object Clone()
2121

2222
public static MockResponse FromHttpResponse(string httpResponse, ILogger logger)
2323
{
24+
ArgumentNullException.ThrowIfNull(logger);
25+
2426
logger.LogTrace("{Method} called", nameof(FromHttpResponse));
2527

2628
if (string.IsNullOrWhiteSpace(httpResponse))
@@ -40,7 +42,10 @@ public static MockResponse FromHttpResponse(string httpResponse, ILogger logger)
4042
for (var i = 0; i < lines.Length; i++)
4143
{
4244
var line = lines[i];
43-
logger.LogTrace("Processing line {LineNumber}: {LineContent}", i + 1, line);
45+
if (logger.IsEnabled(LogLevel.Trace))
46+
{
47+
logger.LogTrace("Processing line {LineNumber}: {LineContent}", i + 1, line);
48+
}
4449

4550
if (i == 0)
4651
{

DevProxy.Abstractions/Plugins/BaseLoader.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ private async Task<bool> ValidateFileContentsAsync(string fileContents, Cancella
9191

9292
if (!IsValid)
9393
{
94-
Logger.LogError("Schema validation failed for {File} with the following errors: {Errors}", FilePath, string.Join(", ", ValidationErrors));
94+
if (Logger.IsEnabled(LogLevel.Error))
95+
{
96+
Logger.LogError("Schema validation failed for {File} with the following errors: {Errors}", FilePath, string.Join(", ", ValidationErrors));
97+
}
9598
}
9699

97100
return IsValid;

0 commit comments

Comments
 (0)