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

Version 6.6.4 #68

Merged
merged 6 commits into from
Jan 11, 2023
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
2 changes: 1 addition & 1 deletion OpenAI.SDK/Managers/OpenAIImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public async Task<ImageCreateResponse> CreateImageEdit(ImageEditCreateRequest im
if (imageEditCreateRequest.ResponseFormat != null) multipartContent.Add(new StringContent(imageEditCreateRequest.ResponseFormat), "response_format");
if (imageEditCreateRequest.Size != null) multipartContent.Add(new StringContent(imageEditCreateRequest.Size), "size");
if (imageEditCreateRequest.N != null) multipartContent.Add(new StringContent(imageEditCreateRequest.N.ToString()!), "n");
if (imageEditCreateRequest.Mask != null) multipartContent.Add(new ByteArrayContent(imageEditCreateRequest.Mask), "mask", imageEditCreateRequest.MaskName);

multipartContent.Add(new StringContent(imageEditCreateRequest.Prompt), "prompt");
multipartContent.Add(new ByteArrayContent(imageEditCreateRequest.Image), "image", imageEditCreateRequest.ImageName);
multipartContent.Add(new ByteArrayContent(imageEditCreateRequest.Mask), "mask", imageEditCreateRequest.MaskName);

return await _httpClient.PostFileAndReadAsAsync<ImageCreateResponse>(_endpointProvider.ImageEditCreate(), multipartContent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public record ImageEditCreateRequest : ImageCreateRequest
/// An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited.
/// Must be a valid PNG file, less than 4MB, and have the same dimensions as image.
/// </summary>
public byte[] Mask { get; set; }
public byte[]? Mask { get; set; }

/// <summary>
/// Mask file name
/// </summary>
public string MaskName { get; set; }
public string? MaskName { get; set; }
}
}
6 changes: 3 additions & 3 deletions OpenAI.SDK/OpenAI.GPT3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<PackageProjectUrl>https://openai.com/</PackageProjectUrl>
<PackageIcon>OpenAI-Betalgo.png</PackageIcon>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>6.6.3</Version>
<Version>6.6.4</Version>
<Authors>Tolga Kayhan, Betalgo</Authors>
<Company>Betalgo Up Ltd.</Company>
<Product>OpenAI GPT-3 and DALL·E dotnet SDK</Product>
<Description>Dotnet SDK for OpenAI GTP-3 and DALL·E</Description>
<Description>Dotnet SDK for OpenAI GPT-3 and DALL·E</Description>
<RepositoryUrl>https://github.com/betalgo/openai/</RepositoryUrl>
<PackageTags>openAI,gpt-3,ai,betalgo,NLP,dalle,DALL·E,dall-e,OpenAI,OpenAi,openAi,</PackageTags>
<PackageId>Betalgo.$(AssemblyName)</PackageId>
Expand All @@ -38,4 +38,4 @@
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
</ItemGroup>

</Project>
</Project>
20 changes: 20 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,23 @@ else
Console.WriteLine($"{completionResult.Error.Code}: {completionResult.Error.Message}");
}
```
## DALL·E Sample
```csharp
var imageResult = await sdk.Image.CreateImage(new ImageCreateRequest
{
Prompt = "Laser cat eyes",
N = 2,
Size = StaticValues.ImageStatics.Size.Size256,
ResponseFormat = StaticValues.ImageStatics.ResponseFormat.Url,
User = "TestUser"
});


if (imageResult.Successful)
{
Console.WriteLine(string.Join("\n", imageResult.Results.Select(r => r.Url)));
}
```

## Notes:
I couldn't find enough time to test all the methods or improve the documentation. My main target was to make fine-tuning available. If you hit any issue please report it or pull request always appreciated.
Expand All @@ -109,6 +125,10 @@ As you can guess I do not accept any damage caused by use of the library. You ar


## Changelog
### 6.6.4
* Bug-fix, ImageEditRequest.Mask now is optional. thanks to @hanialaraj
*(if you are using edit request without mask your image has to be RGBA, RGB is not allowed)*

### 6.6.3
* Bug-fix, now we are handling logprops response properly, thanks to @KosmonikOS
* Code clean-up, thanks to @KosmonikOS
Expand Down