from UI_layout_generation import generate_layout_onestep
from UI_text_prediction import generate_text_onestep
import os
import json
from openai import OpenAI
import random
import time
def generate_single_step(start_image,start_image_withmask,action,client,result_ep_path,index,cuda_id,model_path):
    if action =='Stop.':
        return start_image,start_image_withmask



    next_layout_path = os.path.join(result_ep_path,index)[:240]+'_layout.png'

    next_UI_path = os.path.join(result_ep_path,index)[:240]+'.png'

 
    generate_layout_onestep(start_image_withmask,next_layout_path,action,cuda_id,ckpt_path=model_path)
    generate_text_onestep(start_image,next_layout_path,action,next_UI_path,client,model_str='gemini')
    return next_UI_path,next_layout_path