-
Notifications
You must be signed in to change notification settings - Fork 841
Add CodeInterpreterToolCall/ResultContent content types #6964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces new content types for representing code interpreter tool interactions in hosted AI services, specifically adding CodeInterpreterToolCallContent and CodeInterpreterToolResultContent. These types enable better modeling of code execution workflows in OpenAI's Assistants and Responses APIs.
Key changes:
- New content types for code interpreter tool calls and results
- Enhanced
HostedFileContentwith optionalMediaTypeandNameproperties to align withDataContentandUriContent - Updated coalescing logic to handle the new code interpreter content types
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| CodeInterpreterToolCallContent.cs | Defines new content type for code interpreter tool invocations |
| CodeInterpreterToolResultContent.cs | Defines new content type for code interpreter execution results |
| HostedFileContent.cs | Adds MediaType and Name properties with validation |
| ChatResponseExtensions.cs | Updates coalescing logic to merge code interpreter content |
| OpenAIResponsesChatClient.cs | Implements conversion from OpenAI responses to new content types |
| OpenAIAssistantsChatClient.cs | Implements streaming support for code interpreter updates |
| OpenAIClientExtensions.cs | Adds helper to determine image media types from URIs |
| DataContent.cs | Enhances debugger display for text and JSON content |
| AIJsonUtilities.Defaults.cs | Registers new content types for serialization |
| HostedFileContentTests.cs | Adds tests for new MediaType and Name properties |
| CodeInterpreterToolCallContentTests.cs | Adds comprehensive tests for new content type |
| CodeInterpreterToolResultContentTests.cs | Adds comprehensive tests for new content type |
| OpenAIResponseClientTests.cs | Adds integration tests for code interpreter scenarios |
| Various test files | Updates to use collection expressions |
Comments suppressed due to low confidence (1)
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs:1
- Inconsistent quote escaping in debugger display strings. Line 243 properly escapes the text content with
\\\", but line 248 only has a closing quote without proper escaping. Line 248 should be:return $\"JSON = \\\"{Encoding.UTF8.GetString(Data.ToArray())}\\\"\";
// Licensed to the .NET Foundation under one or more agreements.
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/DataContent.cs
Show resolved
Hide resolved
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolResultContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolCallContent.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolResultContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/HostedFileContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/HostedFileContent.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolCallContent.cs
Show resolved
Hide resolved
- Adds new CodeInterpreterToolCallContent and CodeInterpreterToolResultContent types
- Updates the OpenAI Assistants and Responses IChatClient implementations to produce them
- Updates HostedFileContent with an optional MediaType and Name, matching the corresponding properties on DataContent and UriContent.
- Updates ToChatResponse{Async} coalescing to handle these code interpreter types.
- Updates DataContent's DebuggerDisplay to show text for "text/*" and "application/json" media types.
…deInterpreterToolCallContent.cs Co-authored-by: Roger Barreto <[email protected]>
b05748b to
323db59
Compare
* Add CodeInterpreterToolCall/ResultContent content types
- Adds new CodeInterpreterToolCallContent and CodeInterpreterToolResultContent types
- Updates the OpenAI Assistants and Responses IChatClient implementations to produce them
- Updates HostedFileContent with an optional MediaType and Name, matching the corresponding properties on DataContent and UriContent.
- Updates ToChatResponse{Async} coalescing to handle these code interpreter types.
- Updates DataContent's DebuggerDisplay to show text for "text/*" and "application/json" media types.
* Update src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolCallContent.cs
Co-authored-by: Roger Barreto <[email protected]>
* Address PR feedback
---------
Co-authored-by: Roger Barreto <[email protected]>
* Add CodeInterpreterToolCall/ResultContent content types
- Adds new CodeInterpreterToolCallContent and CodeInterpreterToolResultContent types
- Updates the OpenAI Assistants and Responses IChatClient implementations to produce them
- Updates HostedFileContent with an optional MediaType and Name, matching the corresponding properties on DataContent and UriContent.
- Updates ToChatResponse{Async} coalescing to handle these code interpreter types.
- Updates DataContent's DebuggerDisplay to show text for "text/*" and "application/json" media types.
* Update src/Libraries/Microsoft.Extensions.AI.Abstractions/Contents/CodeInterpreterToolCallContent.cs
Co-authored-by: Roger Barreto <[email protected]>
* Address PR feedback
---------
Co-authored-by: Roger Barreto <[email protected]>
Contributes to #6057
Microsoft Reviewers: Open in CodeFlow