Skip to content

Commit

Permalink
upgrade deps and add hide flag
Browse files Browse the repository at this point in the history
  • Loading branch information
raiyanyahya committed Oct 13, 2023
1 parent 67dfec3 commit 95086d0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Actions Status](https://github.com/raiyanyahya/dallecli/workflows/Build%20Test/badge.svg)](https://github.com/raiyanyahya/dallecli/actions) [![Actions Status](https://github.com/raiyanyahya/dallecli/workflows/Package%20Release/badge.svg)](https://github.com/raiyanyahya/dallecli/actions) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=raiyanyahya_dallecli&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=raiyanyahya_dallecli)[![CodeQL](https://github.com/raiyanyahya/dallecli/workflows/CodeQL/badge.svg)](https://github.com/raiyanyahya/dallecli/actions?query=workflow%3ACodeQL) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/851417bc6ec8405ba244438fe31dae55)](https://www.codacy.com/gh/raiyanyahya/dallecli/dashboard?utm_source=github.com&utm_medium=referral&utm_content=raiyanyahya/dallecli&utm_campaign=Badge_Grade) [![](https://img.shields.io/badge/python-3.6+-blue.svg)]
[![PyPI version](https://badge.fury.io/py/dallecli.png)](https://badge.fury.io/py/dallecli)[![PyPI download month](https://img.shields.io/pypi/dm/dallecli.svg)](https://pypi.python.org/pypi/dallecli/)[![Linux](https://svgshare.com/i/Zhy.svg)](https://svgshare.com/i/Zhy.svg)[![macOS](https://svgshare.com/i/ZjP.svg)](https://svgshare.com/i/ZjP.svg)
[![PyPI version](https://badge.fury.io/py/dallecli.png)](https://badge.fury.io/py/dallecli)[![PyPI download month](https://img.shields.io/pypi/dm/dallecli.svg)](https://pypi.python.org/pypi/dallecli/)

# DalleCli 💠

`dallecli` is a community-maintained cli designed to provide users with the ability to generate, edit and filter images using the DALL-E 2 API provided by OpenAI, all from the command line.
Expand Down Expand Up @@ -56,8 +57,9 @@ Options:
--prompt TEXT 💬 The prompt to generate the image from.
--size TEXT 📐 The size of the generated image.
--filter 🎨 Apply a filter to the generated image.
--iterations INTEGER 🔄 The number of times to generate the image
--save-path FILE 💾 Save the generated image to the specifiedfile path
--iterations INTEGER 🔄 The number of times to generate the image.
--save-path FILE 💾 Save the generated image to the specifiedfile path.
--hide FLAG 🖱️ Do not open the image after generation.
--help Show this message and exit.
```

Expand Down
12 changes: 7 additions & 5 deletions dallecli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def configure_openai():
openai.api_key = api_key or getenv("OPENAI_API_KEY")


def generate_image(prompt, size, filter, iterations, save_path=None):
def generate_image(prompt, size, filter, iterations, hide, save_path=None):
try:
with console.status("Generating image...", spinner="dots8Bit"):
for _ in range(iterations):
Expand All @@ -41,7 +41,8 @@ def generate_image(prompt, size, filter, iterations, save_path=None):
response.get("data")[0]["url"], timeout=300
).content
image = Image.open(BytesIO(image_data))
image.show()
if not hide:
image.show()
if save_path is not None:
if not path.exists(path.dirname(save_path)):
makedirs(path.dirname(save_path))
Expand Down Expand Up @@ -108,7 +109,7 @@ def apply_filter_choices(image, filter_name):


@click.group()
@click.version_option(version="1.2.0")
@click.version_option(version="1.3.0")
def cli():
"""💠 Use the Dall.E 2 api to generate, edit & filter images from the cmd line."""

Expand Down Expand Up @@ -155,10 +156,11 @@ def cli():
help="💾 Save the generated image to the specified file path",
default="images/output.png",
)
def generate(prompt, size, filter, iterations, save_path):
@click.option("--hide", is_flag=True, help="🖱️ Do not open the image after generation")
def generate(prompt, size, filter, iterations, save_path, hide):
"""🌸 Generate an image from the OpenAI Dalle api"""
configure_openai()
generate_image(prompt, size, filter, iterations, save_path)
generate_image(prompt, size, filter, iterations, hide, save_path)


@cli.command("edit")
Expand Down
19 changes: 16 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,29 @@
name="dallecli",
python_requires=">3.5",
options={"bdist_wheel": {"universal": "1"}},
version="1.2.0",
version="1.3.0",
description="A command line application to help wrap the OpenAI Dalle api and other utilities.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/raiyanyahya/dallecli",
author="Raiyan Yahya",
license="MIT",
author_email="raiyanyahyadeveloper@gmail.com",
keywords=["cli", "developer tools", "productivity", "openai", "generative art", "ai"],
keywords=[
"cli",
"developer tools",
"productivity",
"openai",
"generative art",
"ai",
],
packages=find_packages(),
install_requires=["click==8.1.3", "openai==0.27.2", "rich==13.3.1", "idna", "pillow"],
install_requires=[
"click==8.1.3",
"openai==0.27.8",
"rich==13.4.2",
"idna",
"pillow==9.4.0",
],
entry_points={"console_scripts": ["dallecli=dallecli.cli:cli"]},
)

0 comments on commit 95086d0

Please sign in to comment.