Skip to content
Merged
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
7 changes: 6 additions & 1 deletion dotnet/src/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,11 @@ private static string FormatCliExitedMessage(string message, string stderrOutput
Message = "CopilotClient.ConnectToServerAsync connecting to CLI server. Host={Host}, Port={Port}")]
private static partial void LogConnectingToCliServer(ILogger logger, string host, int port);

[LoggerMessage(
Level = LogLevel.Warning,
Message = "[CLI] {Line}")]
private static partial void LogCliStderrLine(ILogger logger, string line);

private static IOException CreateCliExitedException(string message, StringBuilder stderrBuffer)
{
string stderrOutput;
Expand Down Expand Up @@ -2324,7 +2329,7 @@ private async Task PumpAsync(Process process, ILogger logger, CancellationToken
Buffer.AppendLine(line);
}

logger.LogWarning("[CLI] {Line}", line);
LogCliStderrLine(logger, line);
}
}
catch (Exception e) when (cancellationToken.IsCancellationRequested
Expand Down
4,708 changes: 2,473 additions & 2,235 deletions dotnet/src/Generated/Rpc.cs

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions dotnet/src/Generated/SessionEvents.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion dotnet/src/JsonRpc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ private void HandleResponse(JsonElement message, JsonElement idProp)
}
catch (Exception ex)
{
_logger.LogWarning(ex, "Inline response callback for request {RequestId} threw", id);
LogInlineResponseCallbackThrew(_logger, ex, id);
pending.TrySetException(ex);
return;
}
Expand Down Expand Up @@ -935,6 +935,11 @@ private sealed class CancelRequestParams
public long Id { get; set; }
}

[LoggerMessage(
Level = LogLevel.Warning,
Message = "Inline response callback for request {RequestId} threw")]
private static partial void LogInlineResponseCallbackThrew(ILogger logger, Exception exception, long requestId);

[JsonSerializable(typeof(CancelRequestParams))]
private partial class CancelRequestParamsContext : JsonSerializerContext;
}
Expand Down
22 changes: 13 additions & 9 deletions dotnet/test/Unit/SerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,17 @@ public void ModelBilling_CanSerializeTokenPrices_WithSdkOptions()
{
InputPrice = 2.0,
OutputPrice = 8.0,
CachePrice = 0.5,
CacheReadPrice = 0.5,
CacheWritePrice = 0.75,
BatchSize = 1_000_000L,
ContextMax = 128_000L,
MaxPromptTokens = 128_000L,
LongContext = new GitHub.Copilot.Rpc.ModelBillingTokenPricesLongContext
{
InputPrice = 4.0,
OutputPrice = 16.0,
CachePrice = 1.0,
ContextMax = 1_000_000L
CacheReadPrice = 1.0,
CacheWritePrice = 1.25,
MaxPromptTokens = 1_000_000L
}
}
};
Expand All @@ -103,23 +105,25 @@ public void ModelBilling_CanSerializeTokenPrices_WithSdkOptions()
var tokenPrices = root.GetProperty("tokenPrices");
Assert.Equal(2.0, tokenPrices.GetProperty("inputPrice").GetDouble());
Assert.Equal(8.0, tokenPrices.GetProperty("outputPrice").GetDouble());
Assert.Equal(0.5, tokenPrices.GetProperty("cachePrice").GetDouble());
Assert.Equal(0.5, tokenPrices.GetProperty("cacheReadPrice").GetDouble());
Assert.Equal(0.75, tokenPrices.GetProperty("cacheWritePrice").GetDouble());
Assert.Equal(1_000_000L, tokenPrices.GetProperty("batchSize").GetInt64());
Assert.Equal(128_000L, tokenPrices.GetProperty("contextMax").GetInt64());
Assert.Equal(128_000L, tokenPrices.GetProperty("maxPromptTokens").GetInt64());
var longContext = tokenPrices.GetProperty("longContext");
Assert.Equal(4.0, longContext.GetProperty("inputPrice").GetDouble());
Assert.Equal(1_000_000L, longContext.GetProperty("contextMax").GetInt64());
Assert.Equal(1.25, longContext.GetProperty("cacheWritePrice").GetDouble());
Assert.Equal(1_000_000L, longContext.GetProperty("maxPromptTokens").GetInt64());

var deserialized = JsonSerializer.Deserialize<ModelBilling>(json, options);
Assert.NotNull(deserialized);
Assert.Equal(1.5, deserialized.Multiplier);
Assert.NotNull(deserialized.TokenPrices);
Assert.Equal(2.0, deserialized.TokenPrices.InputPrice);
Assert.Equal(1_000_000L, deserialized.TokenPrices.BatchSize);
Assert.Equal(128_000L, deserialized.TokenPrices.ContextMax);
Assert.Equal(128_000L, deserialized.TokenPrices.MaxPromptTokens);
Assert.NotNull(deserialized.TokenPrices.LongContext);
Assert.Equal(16.0, deserialized.TokenPrices.LongContext.OutputPrice);
Assert.Equal(1_000_000L, deserialized.TokenPrices.LongContext.ContextMax);
Assert.Equal(1_000_000L, deserialized.TokenPrices.LongContext.MaxPromptTokens);
}

[Fact]
Expand Down
Loading
Loading