Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ private static JsonSerializerOptions CreateDefaultOptions()
[JsonSerializable(typeof(ResponsesDeveloperMessageItemParam))]
[JsonSerializable(typeof(FunctionToolCallItemParam))]
[JsonSerializable(typeof(FunctionToolCallOutputItemParam))]
[JsonSerializable(typeof(FunctionApprovalResponseItemParam))]
[JsonSerializable(typeof(FileSearchToolCallItemParam))]
[JsonSerializable(typeof(ComputerToolCallItemParam))]
[JsonSerializable(typeof(ComputerToolCallOutputItemParam))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ public async IAsyncEnumerable<StreamingResponseEvent> ExecuteAsync(
messages.AddRange(conversationHistory);
}

foreach (var inputMessage in request.Input.GetInputMessages())
{
messages.Add(inputMessage.ToChatMessage());
}
messages.AddRange(request.Input.GetChatMessages());

// Use the extension method to convert streaming updates to streaming response events
await foreach (var streamingEvent in this._agent.RunStreamingAsync(messages, options: options, cancellationToken: cancellationToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ internal sealed class ItemParamConverter : JsonConverter<ItemParam>
"message" => doc.Deserialize(OpenAIHostingJsonContext.Default.ResponsesMessageItemParam),
"function_call" => doc.Deserialize(OpenAIHostingJsonContext.Default.FunctionToolCallItemParam),
"function_call_output" => doc.Deserialize(OpenAIHostingJsonContext.Default.FunctionToolCallOutputItemParam),
"function_approval_response" => doc.Deserialize(OpenAIHostingJsonContext.Default.FunctionApprovalResponseItemParam),
"file_search_call" => doc.Deserialize(OpenAIHostingJsonContext.Default.FileSearchToolCallItemParam),
"computer_call" => doc.Deserialize(OpenAIHostingJsonContext.Default.ComputerToolCallItemParam),
"computer_call_output" => doc.Deserialize(OpenAIHostingJsonContext.Default.ComputerToolCallOutputItemParam),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ public async IAsyncEnumerable<StreamingResponseEvent> ExecuteAsync(
messages.AddRange(conversationHistory);
}

foreach (var inputMessage in request.Input.GetInputMessages())
{
messages.Add(inputMessage.ToChatMessage());
}
messages.AddRange(request.Input.GetChatMessages());

await foreach (var streamingEvent in agent.RunStreamingAsync(messages, options: options, cancellationToken: cancellationToken)
.ToStreamingResponseAsync(request, context, cancellationToken).ConfigureAwait(false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,38 @@ internal sealed class FunctionToolCallOutputItemParam : ItemParam
public required string Output { get; init; }
}

/// <summary>
/// A function approval response item parameter.
/// </summary>
internal sealed class FunctionApprovalResponseItemParam : ItemParam
{
/// <summary>
/// The constant item type identifier for function approval response items.
/// </summary>
public const string ItemType = "function_approval_response";

/// <inheritdoc/>
public override string Type => ItemType;

/// <summary>
/// The ID of the approval request being answered.
/// </summary>
[JsonPropertyName("approval_request_id")]
public required string ApprovalRequestId { get; init; }

/// <summary>
/// Whether the request was approved.
/// </summary>
[JsonPropertyName("approve")]
public bool Approve { get; init; }

/// <summary>
/// Optional reason for the decision.
/// </summary>
[JsonPropertyName("reason")]
public string? Reason { get; init; }
}

/// <summary>
/// A file search tool call item parameter.
/// </summary>
Expand Down
Loading