-
Notifications
You must be signed in to change notification settings - Fork 341
feat: Add prompt parameter support for stored prompts in Responses API (Fixes #500) #501
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
base: main
Are you sure you want to change the base?
Conversation
…port - Implement ResponsePrompt class with properties for Id, Version, and Variables. - Add serialization and deserialization methods for ResponsePrompt. - Introduce ResponseCreationOptions class to support stored prompts. - Create example tests for serialization and deserialization of ResponsePrompt. - Add basic functionality tests for ResponsePrompt integration.
|
Hi @YairSadan. Thanks very much for your contribution and your interest in improving the OpenAI developer experience. First, I'd like to tell you how much we appreciate your rigor and attention to detail - you've managed to mimic the existing conventions and approach perfectly. This one is a bit tricky, in that the implementation is for a feature that is in a newer version of the REST API spec than our upstream repository currently references. While you've done a great job ensuring that your implementation only touches custom code (so that it isn't impacted by automatic generation), it is overlapping an area that will be generated and makes some assumptions about the naming and structure of the spec. The assumptions are well-reasoned and based on the API docs and JS implantation - so probably safe. When we do generate the feature, either we'll see your implementation integrate perfectly or cause generation/build failures. It's hard to predict until we receive a spec hand-off. I'm inclined to say that the quality of your work offsets a great deal of that risk and that we should accept the changes - but @joseharriaga is the expert on what is happening upstream, so I'm going to ask that he makes the call. Regardless of how things work out, your efforts and professionalism are very much appreciated. |
|
Hi team, since assistants deprecation is already in place for a year ahead, looks like this fix address the need for migrating to "prompts". Any idea when this will become available? Thanks for the great work you been putting to this project. |
|
Any update to this? Or is there a timeline on when the newer version of the REST API spec will be in the upstream repository? We wanted to utilize Assistant, but since that won't be updated with the newer models, our project is currently stuck waiting on this update. |
|
We'd love to see this as well -- at the moment, lack of support for prompts on the responses API is blocking us from migrating away from Assistants (which appear to be less stable than ideal in the recent past). Thanks! |
Summary
This PR implements support for stored prompts in the OpenAI .NET SDK Responses API, addressing the feature request in issue #500. The implementation brings the .NET SDK to feature parity with the JavaScript SDK for stored prompt functionality.
Changes
Core Implementation
ResponsePrompt.cs: New class representing stored prompts withId,Version, andVariablespropertiesResponsePrompt.Serialization.cs: Complete JSON serialization support with trimming compatibility (IL2026 compliant)ResponseCreationOptions.cs: AddedPromptproperty to enable stored prompt usageTesting & Examples
ResponsesTests.csExample03_StoredPrompts.csdemonstrating synchronous usageExample03_StoredPromptsAsync.csdemonstrating asynchronous usageFeatures
✅ Stored Prompt Support: Full implementation matching JavaScript SDK functionality
✅ Variable Substitution: Support for prompt variables with type-safe handling
✅ JSON Serialization: Custom IJsonModel implementation with proper error handling
✅ Trimming Compatibility: All IL2026 warnings resolved for AOT scenarios
✅ Pattern Compliance: Follows existing codebase conventions and patterns
✅ Comprehensive Testing: Unit tests covering serialization, deserialization, and integration
Usage Example
API Compatibility
This implementation enables the same functionality as the JavaScript SDK:
JavaScript:
C# (with this PR):
Technical Details
IJsonModel<ResponsePrompt>implementation handles all primitive types and complex objectsWriteRawValuefor .NET 6.0+ with fallback for earlier versionsIDictionary<string, object>with proper JSON deserializationResponseCreationOptionsworkflowTesting
All tests pass and the project builds successfully in Release configuration:
Breaking Changes
None. This is a purely additive feature that maintains full backward compatibility.
Fixes #500