Skip to content

Commit 46b358a

Browse files
authored
Merge pull request #49 from yarns123/main
Add logging for invalid WebSocket payloads and new properties
2 parents 7f68457 + 58590a5 commit 46b358a

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/GenerativeAI.Live/Logging/LoggingExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,7 @@ public static partial class MultiModalLiveClientLoggingExtensions
4747

4848
[LoggerMessage(EventId = 112, Level = LogLevel.Information, Message = "Calling function: {FunctionName}")]
4949
public static partial void LogFunctionCall(this ILogger logger, string functionName);
50+
51+
[LoggerMessage(EventId = 113, Level = LogLevel.Error, Message = "WebSocket connection closed caused by invalid payload: {CloseStatusDescription}")]
52+
public static partial void LogConnectionClosedWithInvalidPyload(this ILogger logger, string closeStatusDescription);
5053
}

src/GenerativeAI.Live/Models/MultiModalLiveClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ public async Task ConnectAsync(bool autoSendSetup = true,CancellationToken cance
429429
_logger?.LogConnectionClosedWithError(info.Type, info.Exception!);
430430
ErrorOccurred?.Invoke(this, new ErrorEventArgs(info.Exception!));
431431
}
432+
else if (info.CloseStatus == WebSocketCloseStatus.InvalidPayloadData)
433+
{
434+
//log info.CloseStatusDescription
435+
_logger?.LogConnectionClosedWithInvalidPyload(info.CloseStatusDescription!);
436+
}
432437
else
433438
{
434439
_logger?.LogConnectionClosed();

src/GenerativeAI/Types/MultimodalLive/BidiGenerateContentSetup.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,14 @@ public class BidiGenerateContentSetup
4343
/// </summary>
4444
[JsonPropertyName("tools")]
4545
public Tool[]? Tools { get; set; }
46+
47+
[JsonPropertyName("outputAudioTranscription")]
48+
public OutputAudioTranscription? OutputAudioTranscription { get; set; } = new OutputAudioTranscription();
49+
50+
[JsonPropertyName("inputAudioTranscription")]
51+
public OutputAudioTranscription? InputAudioTranscription { get; set; }
52+
}
53+
public class OutputAudioTranscription
54+
{
55+
4656
}

0 commit comments

Comments
 (0)