Skip to content
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

com.openai.unity 2.2.5 #34

Merged
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
15 changes: 15 additions & 0 deletions OpenAI/Packages/com.openai.unity/Documentation~/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,21 @@ foreach (var (path, texture) in results)
}
```

Alternatively, the endpoint can directly take a Texture2D with Read/Write enabled and Compression set to None.

```csharp
var api = new OpenAIClient();
var results = await api.ImagesEndPoint.CreateImageVariationAsync(imageTexture, 1, ImageSize.Small);
// imageTexture is of type Texture2D
foreach (var (path, texture) in results)
{
Debug.Log(path);
// path == file://path/to/image.png
Assert.IsNotNull(texture);
// texture == The preloaded Texture2D
}
```

EvanCrabtree marked this conversation as resolved.
Show resolved Hide resolved
### [Files](https://beta.openai.com/docs/api-reference/files)

Files are used to upload documents that can be used with features like [Fine-tuning](#fine-tuning).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ImageVariationRequest(string imagePath, int numberOfResults = 1, ImageSiz
/// Constructor.
/// </summary>
/// <param name="texture">
/// The image to edit. Must be a valid PNG file, less than 4MB, and square.
/// The texture to edit. Must be a valid PNG file, less than 4MB, and square. Read/Write should be enabled and Compression set to None.
/// </param>
/// <param name="numberOfResults">
/// The number of images to generate. Must be between 1 and 10.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public async Task<IReadOnlyDictionary<string, Texture2D>> CreateImageVariationAs
/// <summary>
/// Creates a variation of a given image.
/// </summary>
/// <param name="imagePath">
/// The image to edit. Must be a valid PNG file, less than 4MB, and square.
/// <param name="texture">
/// The texture to edit. Must be a valid PNG file, less than 4MB, and square. Read/Write should be enabled and Compression set to None.
/// </param>
/// <param name="numberOfResults">
/// The number of images to generate. Must be between 1 and 10.
Expand All @@ -180,8 +180,8 @@ public async Task<IReadOnlyDictionary<string, Texture2D>> CreateImageVariationAs
/// <param name="cancellationToken">Optional, <see cref="CancellationToken"/>.</param>
/// <returns>A dictionary of file urls and the preloaded <see cref="Texture2D"/> that were downloaded.</returns>
/// <exception cref="HttpRequestException"></exception>
public async Task<IReadOnlyDictionary<string, Texture2D>> CreateImageVariationAsync(Texture2D imagePath, int numberOfResults = 1, ImageSize size = ImageSize.Large, string user = null, CancellationToken cancellationToken = default)
=> await CreateImageVariationAsync(new ImageVariationRequest(imagePath, numberOfResults, size, user), cancellationToken);
public async Task<IReadOnlyDictionary<string, Texture2D>> CreateImageVariationAsync(Texture2D texture, int numberOfResults = 1, ImageSize size = ImageSize.Large, string user = null, CancellationToken cancellationToken = default)
=> await CreateImageVariationAsync(new ImageVariationRequest(texture, numberOfResults, size, user), cancellationToken);

/// <summary>
/// Creates a variation of a given image.
Expand Down
2 changes: 1 addition & 1 deletion OpenAI/Packages/com.openai.unity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "OpenAI",
"description": "A OpenAI package for the Unity Game Engine to use GPT-3 and Dall-E though their RESTful API (currently in beta).\n\nIndependently developed, this is not an official library and I am not affiliated with OpenAI.\n\nAn OpenAI API account is required.",
"keywords": [],
"version": "2.2.4",
"version": "2.2.5",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases",
Expand Down