-
Notifications
You must be signed in to change notification settings - Fork 342
Added a model factory to Responses namespace #566
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using System.Linq; | ||
|
|
||
| namespace OpenAI.Responses; | ||
|
|
||
| /// <summary> Model factory for models. </summary> | ||
| [Experimental("OPENAI001")] | ||
| public static partial class OpenAIResponsesModelFactory | ||
KrzysztofCwalina marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Responses.OpenAIResponse"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Responses.OpenAIResponse"/> instance for mocking. </returns> | ||
| public static OpenAIResponse OpenAIResponse( | ||
| string id = null, | ||
| DateTimeOffset createdAt = default, | ||
| ResponseStatus? status = null, | ||
| ResponseError error = null, | ||
| ResponseTokenUsage usage = null, | ||
| string endUserId = null, | ||
| ResponseReasoningOptions reasoningOptions = null, | ||
| int? maxOutputTokenCount = null, | ||
| ResponseTextOptions textOptions = null, | ||
| ResponseTruncationMode? truncationMode = null, | ||
| ResponseIncompleteStatusDetails incompleteStatusDetails = null, | ||
| IEnumerable<ResponseItem> outputItems = null, | ||
| bool parallelToolCallsEnabled = default, | ||
| ResponseToolChoice toolChoice = null, | ||
| string model = null, | ||
| IDictionary<string, string> metadata = null, | ||
| float? temperature = null, | ||
| float? topP = null, | ||
| string previousResponseId = null, | ||
| bool? background = null, | ||
| string instructions = null, | ||
| IEnumerable<ResponseTool> tools = null) | ||
| { | ||
| outputItems ??= new List<ResponseItem>(); | ||
| tools ??= new List<ResponseTool>(); | ||
| metadata ??= new Dictionary<string, string>(); | ||
|
|
||
| return new OpenAIResponse( | ||
| metadata: metadata, | ||
| temperature: temperature, | ||
| topP: topP, | ||
| serviceTier: null, | ||
| previousResponseId: previousResponseId, | ||
| background: background, | ||
| instructions: instructions, | ||
| tools: tools.ToList(), | ||
| id: id, | ||
| status: status, | ||
| createdAt: createdAt, | ||
| error: error, | ||
| usage: usage, | ||
| endUserId: endUserId, | ||
| reasoningOptions: reasoningOptions, | ||
| maxOutputTokenCount: maxOutputTokenCount, | ||
| textOptions: textOptions, | ||
| truncationMode: truncationMode, | ||
| incompleteStatusDetails: incompleteStatusDetails, | ||
| outputItems: outputItems.ToList(), | ||
| parallelToolCallsEnabled: parallelToolCallsEnabled, | ||
| toolChoice: toolChoice, | ||
| model: model, | ||
| @object: "response", | ||
| additionalBinaryDataProperties: null); | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Responses.MessageResponseItem"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Responses.MessageResponseItem"/> instance for mocking. </returns> | ||
| public static MessageResponseItem MessageResponseItem( | ||
| string id = null, | ||
| MessageRole role = MessageRole.Assistant, | ||
| MessageStatus? status = null) | ||
| { | ||
| // Convert the public MessageRole to the internal role type | ||
| InternalResponsesMessageRole internalRole = role.ToSerialString(); | ||
|
|
||
| return new MessageResponseItem( | ||
| id: id, | ||
| internalRole: internalRole, | ||
| status: status); | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Responses.ReasoningResponseItem"/>. </summary> | ||
| /// <param name="id">The ID of the reasoning response item.</param> | ||
| /// <param name="encryptedContent">The encrypted reasoning content.</param> | ||
| /// <param name="status">The status of the reasoning response item.</param> | ||
| /// <param name="summaryParts">The collection of summary parts.</param> | ||
| /// <returns> A new <see cref="OpenAI.Responses.ReasoningResponseItem"/> instance for mocking. </returns> | ||
| public static ReasoningResponseItem ReasoningResponseItem( | ||
| string id = null, | ||
| string encryptedContent = null, | ||
| ReasoningStatus? status = null, | ||
| IEnumerable<ReasoningSummaryPart> summaryParts = null) | ||
| { | ||
| summaryParts ??= new List<ReasoningSummaryPart>(); | ||
|
|
||
| var item = new ReasoningResponseItem( | ||
| kind: InternalItemType.Reasoning, | ||
| id: id, | ||
| additionalBinaryDataProperties: null, | ||
| encryptedContent: encryptedContent, | ||
| summaryParts: summaryParts.ToList()); | ||
|
|
||
| item.Status = status; | ||
| return item; | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Responses.ReasoningResponseItem"/> with summary text. </summary> | ||
| /// <param name="id">The ID of the reasoning response item.</param> | ||
| /// <param name="encryptedContent">The encrypted reasoning content.</param> | ||
| /// <param name="status">The status of the reasoning response item.</param> | ||
| /// <param name="summaryText">The summary text to create a ReasoningSummaryTextPart from.</param> | ||
| /// <returns> A new <see cref="OpenAI.Responses.ReasoningResponseItem"/> instance for mocking. </returns> | ||
| public static ReasoningResponseItem ReasoningResponseItem( | ||
| string id = null, | ||
| string encryptedContent = null, | ||
| ReasoningStatus? status = null, | ||
| string summaryText = null) | ||
| { | ||
| var summaryParts = !string.IsNullOrEmpty(summaryText) | ||
| ? new List<ReasoningSummaryPart> { new ReasoningSummaryTextPart(summaryText) } | ||
| : new List<ReasoningSummaryPart>(); | ||
|
|
||
| var item = new ReasoningResponseItem( | ||
| kind: InternalItemType.Reasoning, | ||
| id: id, | ||
| additionalBinaryDataProperties: null, | ||
| encryptedContent: encryptedContent, | ||
| summaryParts: summaryParts); | ||
|
|
||
| item.Status = status; | ||
| return item; | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Responses.ReferenceResponseItem"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Responses.ReferenceResponseItem"/> instance for mocking. </returns> | ||
| public static ReferenceResponseItem ReferenceResponseItem( | ||
| string id = null) | ||
| { | ||
| return new ReferenceResponseItem( | ||
| kind: InternalItemType.ItemReference, | ||
| id: id, | ||
| additionalBinaryDataProperties: null); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.