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

DALL·E 3, DALL·E 3 HD, DALL·E 2 支持、减少模型混淆以及更好的处理图像中继的代码逻辑 #679

Merged
merged 12 commits into from
Nov 17, 2023

Conversation

ckt1031
Copy link
Contributor

@ckt1031 ckt1031 commented Nov 7, 2023

No description provided.

added new Dall-E models and size ratios
@songquanpeng
Copy link
Owner

改动较多,近期处理哈

common/model-ratio.go Outdated Show resolved Hide resolved
controller/relay-image.go Outdated Show resolved Hide resolved
controller/relay-image.go Outdated Show resolved Hide resolved
if imageRequest.Prompt == "" {
return errorWrapper(errors.New("prompt is required"), "required_field_missing", http.StatusBadRequest)
// Model validation
if imageRequest.Model != "" && imageRequest.Model != "dall-e-3" {
Copy link
Contributor

@dirname dirname Nov 11, 2023

Choose a reason for hiding this comment

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

The lack of assigning the model name parsed from UnmarshalBodyReusable to imageModel here causes it to always be dall-e-2 later on.

Choose a reason for hiding this comment

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

And I think return a invalid_field_value error when imageRequest.Model is neither dall-e-2 nor dall-e-3, will be better than assign default dall-e-2 here

@goc-wurongcan
Copy link

middleware/distributor.go line63, need to change default model from "dall-e" to "dall-e-2"

if strings.HasPrefix(c.Request.URL.Path, "/v1/images/generations") {
    if modelRequest.Model == "" {
        modelRequest.Model = "dall-e"
    }
}

@ckt1031
Copy link
Contributor Author

ckt1031 commented Nov 15, 2023

Thank you for reviewing my code, I am so sorry for not publishing my updated code before I go for exam, hopefully those issues will be fixed in 2 days.

and defined image generation ratios
DalleGenerationImageAmountRatios to
DalleGenerationImageAmounts
relayImageHelper function
supported error in relayImageHelper function
@songquanpeng
Copy link
Owner

@ckt1031 Hello, I plan to review and merge this PR coming Friday. Will there be any additional commits?

@ckt1031
Copy link
Contributor Author

ckt1031 commented Nov 17, 2023

@ckt1031 Hello, I plan to review and merge this PR coming Friday. Will there be any additional commits?

There will not be any additional commits

@songquanpeng songquanpeng merged commit 1d15157 into songquanpeng:main Nov 17, 2023
@songquanpeng
Copy link
Owner

Thx~

humphery755 added a commit to humphery755/one-api that referenced this pull request Nov 19, 2023
…ync-one-api

* 'main' of https://github.com/songquanpeng/one-api:
  fix: cloudflare test & expose detailed info about test failures (songquanpeng#715)
  feat: support tts model (songquanpeng#713)
  feat: keep sync with dall-e updates (songquanpeng#679)
  fix: fix PaLM not working issue (songquanpeng#667)
  fix: fix channel_id column name (songquanpeng#681, close songquanpeng#688)
  feat: add improve docker-compose.yml and support fast startup (songquanpeng#685)
  docs: add deploy to zeabur button (songquanpeng#693)
  fix: numeric sorting in tables (songquanpeng#695)
  feat: sync pricing for new 1106 models (songquanpeng#696)
  docs: update readme
  chore: update quota calc logic (close songquanpeng#599) (songquanpeng#627)
  fix: fix Cloudflare AI Gateway channel test support (songquanpeng#639)
  feat: support chatglm_turbo (songquanpeng#648)
  fix: fix typo (songquanpeng#651)
greeeds pushed a commit to greeeds/one-api that referenced this pull request Mar 3, 2024
* Updated ImageRequest struct and OpenAIModels,
added new Dall-E models and size ratios

* Fixed suspect `or`

* Refactored size ratio calculation in
relayImageHelper function

* Updated the format of resolution keys in
DalleSizeRatios map

* Added error handling for unsupported image size in
relayImageHelper function

* Added validation for number of generated images
and defined image generation ratios

* Refactored variable name from
DalleGenerationImageAmountRatios to
DalleGenerationImageAmounts

* Added validation for prompt length in
relayImageHelper function

* Updated model validation and removed size not
supported error in relayImageHelper function

* Refactored image size and model validation in
relayImageHelper function

* chore: discard binary file

* chore: update impl

---------

Co-authored-by: cktsun1031 <65409152+cktsun1031@users.noreply.github.com>
Co-authored-by: JustSong <songquanpeng@foxmail.com>
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

4 participants