import requests import time import os def save_record(arg_json): request_url = os.environ['facilityURL'] + "/facilities" r = requests.post(request_url, json={'pk': round(time.time()), 'json': arg_json}) print(r.status_code, r.reason) return { "message": "Done" } instruction = '''black-and-white building plan, 2d, flat, house-building plan, top view. Rooms according to locations. Write room-id in the center of room. Write room and floor size inside of room/floor at the top. Write floor description outside above the top border with margin 5px. Sizes must be proportional. Information should be based on next json: ''' def generate_image(json_prompt): prompt = 'black and white building plan, 2d, top view:' + json_prompt openAIToken = os.environ['openAIToken'] client = OpenAI(api_key=openAIToken) try: response = client.images.generate( n=1, prompt=prompt, model="dall-e-3", quality='hd', style='natural', ) done_msg ="Done. Url:" + response.data[0].url return { "message": done_msg} except Exception as e: print(e) functions_dictionary = { "save_record": save_record, "generate_image": generate_image }