Skip to content

Commit

Permalink
Changes from testing
Browse files Browse the repository at this point in the history
  • Loading branch information
parishwolfe committed Sep 25, 2024
1 parent 842505d commit e35f549
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 15 additions & 6 deletions product_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import argparse
import uuid
import random
import json
from datetime import datetime

from util.printify_util import printify_util
from util.ai_util import ai_util
from util.image_util import create_text_image
from res.models.tshirt import tshirt_from_ai, basic_tshirt_product
from res.models.tshirt import tshirt_from_ai, tshirt_from_ai_list

from dotenv import load_dotenv

Expand Down Expand Up @@ -47,18 +48,26 @@ def main():

response = ai.chat(
messages = prompt,
output_model=tshirt_from_ai
output_model=tshirt_from_ai_list,
)
for pattern in response.patterns:
# Parse the response
print(response)
print(type(response))
parsed_response = json.loads(response)
patterns = parsed_response['patterns']



for pattern in patterns:
print(pattern) #[{pattern.title, pattern.description, pattern.tshirt_text}]
# generate filename
filename = uuid.uuid5(uuid.NAMESPACE_DNS, random.getrandombits(128))
#filename = uuid.uuid5(uuid.NAMESPACE_DNS, random.getrandbits(128)) #TODO - broken
# generate image
create_text_image(
text=imagepattern.tshirt_text,
text=pattern.get("tshirt_text"),
height=1000,
width=1000,
file_name=filename
file_name=pattern.get("title"),
color="#000000"
) #TOOD = make both white text and black text version of this
# upload the image
Expand Down
4 changes: 4 additions & 0 deletions res/models/tshirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ class tshirt_from_ai(BaseModel):
# tshirt_text is the text that will be printed on the tshirt
tshirt_text: str

class tshirt_from_ai_list(BaseModel):
"""A pydantic model for a list of ai generated fields"""
patterns: list[tshirt_from_ai]


class basic_tshirt_product(BaseModel):
title: str
Expand Down

0 comments on commit e35f549

Please sign in to comment.