Spaces:
Runtime error
Runtime error
File size: 1,078 Bytes
1bc7525 a46217d 1bc7525 a46217d 1bc7525 a46217d 1bc7525 a46217d 1bc7525 a46217d 1bc7525 391b2d9 a46217d 739e67a a46217d 1bc7525 a46217d |
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 |
import json
from typing import Dict, List
from ai import llm
from utils.io import print_system
PROMPT = """
Your goal is to find the best image that can be used as an ad for a website.
The ad must have certain dimensions but the image can be edited or cut.
So you must consider an image that is 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 the ad.
Summary of the website:
{summary}
Image urls, with labels and dimensions:
{images}
Dimensions for the ad: {dimensions}.
Use the folliowing format.
Why the image was chosen:
Url:
Headline:
Original dimensions:
"""
def get_headline_for_image(
summary: str, dimensions: str, image_labels: List[Dict]
) -> str:
print_system("Generating ad from images...")
instructions = PROMPT.format(
summary=summary,
images=json.dumps(image_labels, indent=2),
dimensions=dimensions,
)
messages = [{"role": "user", "content": instructions}]
return llm.next(messages)
|