thorwhalen / oa

Python interface to OpenAi
Apache License 2.0
0 stars 0 forks source link

Generating images to describe concepts #1

Closed thorwhalen closed 1 year ago

thorwhalen commented 1 year ago

Useful to include in slides and/or videos when making presentations.

def images_about_concept(
    concept, 
    expert="illustrator", 
    n_words_to_explain_concept=0, 
    get_text=get_chatgpt_response,  # TODO: get_text? Perhaps something more precise?
    get_image=get_dalle_response
):
    chatgpt_prompt = f"As a {expert}, describe an image that would illustrate the concept of {concept}."
    if n_words_to_explain_concept:
        concept_prompt = f"Explain what {concept} is in around {n_words_to_explain_concept} words."
        concept_description = get_text(concept_prompt)
        chatgpt_prompt = f"\nHere's an explanation of what {concept is}: {concept_description}"
    image_description = get_text(concept_prompt)
    return get_image(image_description)

Manual example

ChatGPT Prompt:

Act as an illustrator who knows software principles.

Describe an image that would illustrate the advantages of domain driven design, which is a software development approach that emphasizes understanding and modeling the business domain to build software that is aligned with business needs.

ChatGPT Response:

The image could be of a bridge spanning a river. On one side of the bridge is a bustling city, representing the business domain. On the other side of the bridge is a forest, representing the software development process. The bridge represents Domain Driven Design, connecting the business domain with the software development process. The bridge is strong and sturdy, symbolizing the reliability and robustness of software built using DDD principles. On the city side of the bridge, there are signs pointing to different areas of the business domain, such as finance, marketing, and sales, representing the different bounded contexts. On the forest side of the bridge, there are workers building the software, using tools such as entities, value objects, and domain services to construct the software in a way that accurately reflects the business domain. The workers are wearing hard hats and using safety equipment, representing the importance of testing and quality control in the DDD approach. Overall, the image conveys the idea that DDD is a reliable, robust, and effective way to build software that is aligned with business needs.

--> Note; will need to postprocess the response, or include more formatting specifications in the chatGPT prompt.

Dall-e Prompt:

a bridge spanning a river. On one side of the bridge is a bustling city, representing the business domain. On the other side of the bridge is a forest, representing the software development process. The bridge represents Domain Driven Design, connecting the business domain with the software development process. The bridge is strong and sturdy, symbolizing the reliability and robustness of software

Dall-e Response:

image
thorwhalen commented 1 year ago
image
thorwhalen commented 1 year ago

A photo-realistic image of a water fall that splits into two streams that merge back into one.

image