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

Support new fields for /v1/images/generation API #530

Merged
merged 6 commits into from
Nov 8, 2023

Conversation

mikecutalo
Copy link
Contributor

@mikecutalo mikecutalo commented Nov 7, 2023

Describe the change
Updating the /v1/images/generation api with the new changes announced at devday.

Describe your solution
Simply add new fields to ImageRequest & ImageResponseDataInner as well a bunch of new const's for supported options.

Tests
Added more fields to the existing TestImages test, as these are later unmarshaled. Although if you would like to see tests that simply assert marshalling I could add some, let me know.

Issue: #529

@vuguet
Copy link

vuguet commented Nov 7, 2023

could you set the response on this way ? :

	type ImageResponseDataInner struct {
		URL     string `json:"url,omitempty"`
		B64JSON string `json:"b64_json,omitempty"`
		RevisedPrompt string `json:"revised_prompt"`
	}

They now return a prompt in the response :
image

@vuguet
Copy link

vuguet commented Nov 7, 2023

It is not related to your changes and sorry for so many comments but the linter issue is because of this :
image

@mikecutalo
Copy link
Contributor Author

Nice good catch let me update the response object. There is already a lint fix PR #522 thats been opened.

Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #530 (924bd06) into master (3063e67) will not change coverage.
Report is 2 commits behind head on master.
The diff coverage is n/a.

❗ Current head 924bd06 differs from pull request most recent head bbfebb4. Consider uploading reports for the commit bbfebb4 to get more accurate results

@@           Coverage Diff           @@
##           master     #530   +/-   ##
=======================================
  Coverage   97.85%   97.85%           
=======================================
  Files          20       20           
  Lines         978      978           
=======================================
  Hits          957      957           
  Misses         15       15           
  Partials        6        6           
Files Coverage Δ
chat.go 100.00% <ø> (ø)
chat_stream.go 100.00% <ø> (ø)
image.go 92.59% <ø> (ø)

image.go Outdated
)

const (
CreateImageQualityHD = "hd"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikecutalo
Sometimes you may want to explicitly specify default values in the code. Please add the following as well.

CreateImageQualityStandard = "standard"

image

https://platform.openai.com/docs/api-reference/images/create#images-create-quality

@vvatanabe vvatanabe merged commit a0159ad into sashabaranov:master Nov 8, 2023
1 check passed
@vvatanabe
Copy link
Collaborator

@mikecutalo Thanks for implementing the new API so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants