{"version":3,"sources":["../../src/openai/dalle.ts"],"sourcesContent":["/**\n * Copyright 2024 The Fire Company\n * Copyright 2024 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { z } from 'genkit';\nimport {\n  ImageGenerationCommonConfigSchema,\n  ImageRequestBuilder,\n  compatOaiImageModelRef as openAIImageModelRef,\n} from '../image';\n\n/** OpenAI image generation ModelRef helper, same as the OpenAI-compatible spec.\n * */\nexport { openAIImageModelRef };\n\nexport const SUPPORTED_IMAGE_MODELS = {\n  'dall-e-3': openAIImageModelRef({ name: 'openai/dall-e-3' }),\n  'gpt-image-1': openAIImageModelRef({\n    name: 'openai/gpt-image-1',\n    configSchema: ImageGenerationCommonConfigSchema.omit({\n      response_format: true,\n    }).extend({\n      size: z.enum(['1024x1024', '1536x1024', '1024x1536', 'auto']).optional(),\n      background: z.enum(['transparent', 'opaque', 'auto']).optional(),\n      moderation: z.enum(['low', 'auto']).optional(),\n      output_compression: z.number().int().min(1).max(100).optional(),\n      output_format: z.enum(['png', 'jpeg', 'web']).optional(),\n      quality: z.enum(['low', 'medium', 'high']).optional(),\n    }),\n  }),\n};\n\nexport const gptImage1RequestBuilder: ImageRequestBuilder = (req, params) => {\n  const {\n    background,\n    moderation,\n    n,\n    output_compression,\n    output_format,\n    quality,\n    style,\n    user,\n  } = req.config ?? {};\n  // GPT Image 1 does not support response format\n  params.response_format = undefined;\n  params.background = background;\n  params.moderation = moderation;\n  params.n = n;\n  params.output_compression = output_compression;\n  params.output_format = output_format;\n  params.quality = quality;\n  params.style = style;\n  params.user = user;\n};\n"],"mappings":"AAgBA,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EAEA,0BAA0B;AAAA,OACrB;AAMA,MAAM,yBAAyB;AAAA,EACpC,YAAY,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAAA,EAC3D,eAAe,oBAAoB;AAAA,IACjC,MAAM;AAAA,IACN,cAAc,kCAAkC,KAAK;AAAA,MACnD,iBAAiB;AAAA,IACnB,CAAC,EAAE,OAAO;AAAA,MACR,MAAM,EAAE,KAAK,CAAC,aAAa,aAAa,aAAa,MAAM,CAAC,EAAE,SAAS;AAAA,MACvE,YAAY,EAAE,KAAK,CAAC,eAAe,UAAU,MAAM,CAAC,EAAE,SAAS;AAAA,MAC/D,YAAY,EAAE,KAAK,CAAC,OAAO,MAAM,CAAC,EAAE,SAAS;AAAA,MAC7C,oBAAoB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS;AAAA,MAC9D,eAAe,EAAE,KAAK,CAAC,OAAO,QAAQ,KAAK,CAAC,EAAE,SAAS;AAAA,MACvD,SAAS,EAAE,KAAK,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,SAAS;AAAA,IACtD,CAAC;AAAA,EACH,CAAC;AACH;AAEO,MAAM,0BAA+C,CAAC,KAAK,WAAW;AAC3E,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,IAAI,UAAU,CAAC;AAEnB,SAAO,kBAAkB;AACzB,SAAO,aAAa;AACpB,SAAO,aAAa;AACpB,SAAO,IAAI;AACX,SAAO,qBAAqB;AAC5B,SAAO,gBAAgB;AACvB,SAAO,UAAU;AACjB,SAAO,QAAQ;AACf,SAAO,OAAO;AAChB;","names":[]}