import gradio as gr #import openai import requests #import json #from PIL import Image #from io import BytesIO import os def generate_text_descriptions(concept): api_key = os.environ.get("api_key") concept = concept user_id = "user_123" # Unique ID used to track conversation state body = {"action": {"type": "text", "payload": concept}} # Start a conversation response = requests.post( f"https://general-runtime.voiceflow.com/state/user/{user_id}/interact", json=body, headers={"Authorization": api_key}, ) return response.json()[0]['payload']['message'].strip("\n") def generate_shots(prompt): persona = "You are an award winning cinematographer" prompt_shot = f"{persona} create an interesting shot using different camera angles for the concept enclosed in three backticks ```{prompt}```." prompt_lighting = f"{persona} create Lighting Design for the concept enclosed in three backticks ```{prompt}``` and provide description for your choice." prompt_color_grading = f"{persona} Create Color Grading for the concept enclosed in three backticks ```{prompt}``` and provide description for your choice." shot_description = generate_text_descriptions(prompt_shot) lighting_description = generate_text_descriptions(prompt_lighting) color_grading_description = generate_text_descriptions(prompt_color_grading) return shot_description, lighting_description, color_grading_description def generate_output(prompt): shots, lighting, color_grading = generate_shots(prompt) return shots, lighting, color_grading input_text = gr.inputs.Textbox(lines=5, label="Please provide the concept of your film to generate shot compositions, lighting designs, and color grading styles.") iface = gr.Interface(fn=generate_output, inputs=input_text, outputs=["text", "text", "text"], label = ["shot angles", "lighting design", "color grading"], layout="vertical", title="CinemAI", description="Your AI assistant that generates shot compositions, lighting designs, and color grading styles.") iface.launch()