Skip to content

Commit

Permalink
added vivid and b64 in dall-e3
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcastropy committed Jan 25, 2024
1 parent aa8854e commit 693b627
Show file tree
Hide file tree
Showing 5 changed files with 595 additions and 97 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ build/
test.py
archives/
saved_images/
*__pycache__*
*__pycache__*
.env
Binary file added images/test2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions serverless_openai/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ def dall_e(
prompt: str,
model: Union[ImageCreationModels, str] = ImageCreationModels.dalle_3,
n: int = 1,
size: str = "1024x1024",
response_format: str = 'url', # or b64_json
style: str = 'natural', # or vivid
size: str = "1024x1024", # 1792x1024 or 1024x1792
timeout: int = 500,
tries: int = 5
) -> OpenAIResults:
Expand All @@ -157,12 +159,15 @@ def dall_e(
"prompt": prompt,
"n": n,
"size": size,
"response_format": response_format,
"style": style
}

results = {}
for _ in range(tries):
results = requests.post(self.imagecreation_url, headers=self.headers, json=data, timeout=timeout).json()
print(results)
if response_format == 'b64_json':
return OpenAIResults(result=results['data'][0]['b64_json'], result_json=results)
return OpenAIResults(result=results['data'][0]['url'], result_json=results)
return OpenAIResults(result=False, result_json=results)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '1.2.6'
VERSION = '1.2.7'
DESCRIPTION = "A package for using Openai in serverless environment"
LONG_DESCRIPTION = 'A package for using Openai with scraping and etc. in serverless application such as AWS Lambda and GCP Cloud Function'

Expand Down
678 changes: 585 additions & 93 deletions test.ipynb

Large diffs are not rendered by default.

0 comments on commit 693b627

Please sign in to comment.