Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #18 from premAI-io/images-format-fix
Browse files Browse the repository at this point in the history
add response_format to openai connector
  • Loading branch information
filopedraz authored Feb 6, 2024
2 parents 4db2283 + e20c10a commit 2a371fb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions prem_utils/connectors/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,17 @@ def generate_image(
n: int = 1,
quality: str = "standard",
style: str = "vivid",
response_format: str = "url",
):
try:
response = self.client.images.generate(
model=model, prompt=prompt, n=n, size=size, quality=quality, style=style
model=model,
prompt=prompt,
n=n,
size=size,
quality=quality,
style=style,
response_format=response_format,
)
except (
NotFoundError,
Expand All @@ -326,4 +333,4 @@ def generate_image(
) as error:
custom_exception = self.exception_mapping.get(type(error), errors.PremProviderError)
raise custom_exception(error, provider="openai", model=model, provider_message=str(error))
return {"created": None, "data": [{"url": image.url} for image in response.data]}
return {"created": None, "data": [{"url": image.url, "b64_json": image.b64_json} for image in response.data]}

0 comments on commit 2a371fb

Please sign in to comment.