Spaces:
Runtime error
Runtime error
File size: 1,214 Bytes
1bc7525 739e67a 1bc7525 739e67a 1bc7525 739e67a 1bc7525 739e67a 1bc7525 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import json
from typing import Dict, List
from ai import llm
from utils.io import print_system
PROMPT = """
Your goal is to find a set of the best images that can be used as ads for a website.
The ads have to be in certain dimensions. The images can be edited or cut.
So you must consider which images would be better suited to fit those dimensions after editing.
You should consider the content of the website. The content of the images has been labeled.
You will create a headline for each ad.
Summary of the website:
{summary}
Image urls, with labels and dimensions:
{images}
Dimensions for the ads: {dimensions}
Use the folliowing format. Each target dimension must be represented.
Why the image was chosen:
Url:
Headline:
Image dimensions:
Target dimensions: It can be more than one
"""
def get_headlines_for_images(
summary: str, dimensions: List[str], image_labels: List[Dict]
) -> str:
print_system("Generating headlines for images...")
instructions = PROMPT.format(
summary=summary,
images=json.dumps(image_labels, indent=2),
dimensions=dimensions,
)
messages = [{"role": "user", "content": instructions}]
return llm.next(messages, temperature=0)
|