forked from bterlson/openai-in-typespec
-
Notifications
You must be signed in to change notification settings - Fork 14
[ModelFactory] Implemented Files, Models, and Moderations factories #198
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
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| namespace OpenAI.Files; | ||
|
|
||
| /// <summary> Model factory for models. </summary> | ||
| public static partial class OpenAIFilesModelFactory | ||
| { | ||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Files.OpenAIFileInfo"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Files.OpenAIFileInfo"/> instance for mocking. </returns> | ||
| public static OpenAIFileInfo OpenAIFileInfo(string id = null, long? sizeInBytes = null, DateTimeOffset createdAt = default, string filename = null, OpenAIFilePurpose purpose = default, OpenAIFileStatus status = default, string statusDetails = null) | ||
| { | ||
| return new OpenAIFileInfo( | ||
| id, | ||
| sizeInBytes, | ||
| createdAt, | ||
| filename, | ||
| @object: InternalOpenAIFileObject.File, | ||
| purpose, | ||
| status, | ||
| statusDetails, | ||
| serializedAdditionalRawData: null); | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Files.OpenAIFileInfoCollection"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Files.OpenAIFileInfoCollection"/> instance for mocking. </returns> | ||
| public static OpenAIFileInfoCollection OpenAIFileInfoCollection(IEnumerable<OpenAIFileInfo> items = null) | ||
| { | ||
| items ??= new List<OpenAIFileInfo>(); | ||
|
|
||
| return new OpenAIFileInfoCollection( | ||
| items.ToList(), | ||
| InternalListFilesResponseObject.List, | ||
| serializedAdditionalRawData: null); | ||
| } | ||
| } |
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,33 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| namespace OpenAI.Models; | ||
|
|
||
| /// <summary> Model factory for models. </summary> | ||
| public static partial class OpenAIModelsModelFactory | ||
| { | ||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Models.OpenAIModelInfo"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Models.OpenAIModelInfo"/> instance for mocking. </returns> | ||
| public static OpenAIModelInfo OpenAIModelInfo(string id = null, DateTimeOffset createdAt = default, string ownedBy = null) | ||
| { | ||
| return new OpenAIModelInfo( | ||
| id, | ||
| createdAt, | ||
| InternalModelObject.Model, | ||
| ownedBy, | ||
| serializedAdditionalRawData: null); | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Models.OpenAIModelInfoCollection"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Models.OpenAIModelInfoCollection"/> instance for mocking. </returns> | ||
| public static OpenAIModelInfoCollection OpenAIModelInfoCollection(IEnumerable<OpenAIModelInfo> items = null) | ||
| { | ||
| items ??= new List<OpenAIModelInfo>(); | ||
|
|
||
| return new OpenAIModelInfoCollection( | ||
| InternalListModelsResponseObject.List, | ||
| items.ToList(), | ||
| serializedAdditionalRawData: null); | ||
| } | ||
| } |
70 changes: 70 additions & 0 deletions
70
.dotnet/src/Custom/Moderations/OpenAIModerationsModelFactory.cs
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,70 @@ | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| namespace OpenAI.Moderations; | ||
|
|
||
| /// <summary> Model factory for models. </summary> | ||
| public static partial class OpenAIModerationsModelFactory | ||
| { | ||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Moderations.ModerationCategories"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Moderations.ModerationCategories"/> instance for mocking. </returns> | ||
| public static ModerationCategories ModerationCategories(bool hate = default, bool hateThreatening = default, bool harassment = default, bool harassmentThreatening = default, bool selfHarm = default, bool selfHarmIntent = default, bool selfHarmInstructions = default, bool sexual = default, bool sexualMinors = default, bool violence = default, bool violenceGraphic = default) | ||
| { | ||
| return new ModerationCategories( | ||
| hate, | ||
| hateThreatening, | ||
| harassment, | ||
| harassmentThreatening, | ||
| selfHarm, | ||
| selfHarmIntent, | ||
| selfHarmInstructions, | ||
| sexual, | ||
| sexualMinors, | ||
| violence, | ||
| violenceGraphic, | ||
| serializedAdditionalRawData: null); | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Moderations.ModerationCategoryScores"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Moderations.ModerationCategoryScores"/> instance for mocking. </returns> | ||
| public static ModerationCategoryScores ModerationCategoryScores(float hate = default, float hateThreatening = default, float harassment = default, float harassmentThreatening = default, float selfHarm = default, float selfHarmIntent = default, float selfHarmInstructions = default, float sexual = default, float sexualMinors = default, float violence = default, float violenceGraphic = default) | ||
| { | ||
| return new ModerationCategoryScores( | ||
| hate, | ||
| hateThreatening, | ||
| harassment, | ||
| harassmentThreatening, | ||
| selfHarm, | ||
| selfHarmIntent, | ||
| selfHarmInstructions, | ||
| sexual, | ||
| sexualMinors, | ||
| violence, | ||
| violenceGraphic, | ||
| serializedAdditionalRawData: null); | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Moderations.ModerationCollection"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Moderations.ModerationCollection"/> instance for mocking. </returns> | ||
| public static ModerationCollection ModerationCollection(string id = null, string model = null, IEnumerable<ModerationResult> items = null) | ||
| { | ||
| items ??= new List<ModerationResult>(); | ||
|
|
||
| return new ModerationCollection( | ||
| id, | ||
| model, | ||
| items.ToList(), | ||
| serializedAdditionalRawData: null); | ||
| } | ||
|
|
||
| /// <summary> Initializes a new instance of <see cref="OpenAI.Moderations.ModerationResult"/>. </summary> | ||
| /// <returns> A new <see cref="OpenAI.Moderations.ModerationResult"/> instance for mocking. </returns> | ||
| public static ModerationResult ModerationResult(bool flagged = default, ModerationCategories categories = null, ModerationCategoryScores categoryScores = null) | ||
| { | ||
| return new ModerationResult( | ||
| flagged, | ||
| categories, | ||
| categoryScores, | ||
| serializedAdditionalRawData: null); | ||
| } | ||
| } |
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
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.