from Promptless_LLM_Agent import questions from Summarization import Summarizer from TextToImage_StableDiffusion import generate as image_generator import random import gradio as gr user_defined_questions = ["What is the title or subject of the video? Please provide a brief description (1-2 sentences) to help me understand the content?", "What type of video is this (e.g., documentary, informative, sarcastic, comedy, tutorial, review, etc.)?", "Are there any specific keywords or tags you want to include for search optimization? ", "What is the desired mood or atmosphere for the thumbnail (e.g., energetic, calm, inspirational, humorous)?", "What style or tone do you want to convey (e.g., serious, playful, minimalist, detailed)?", "Are there any specific text elements (e.g., titles, subtitles, quotes) you want to include in the thumbnail?", "Who is the target audience for this video?"] def nextGen(): try: x = next(q) except StopIteration: x = None return x def requirement_string(req, QA): req = "User Requirement: "+req+"\n" for q, a in QA: req = req+'\n'+'Graphic Designer: '+q+'\n'+'User: '+a return req r = None q = None qa = None summary = None with gr.Blocks() as demo: title = gr.Label(value="Graphic Designer", show_label=False) a = gr.Textbox(label="Enter Requirement") b = gr.Button("Submit") c = gr.Label(visible=False) d = gr.Chatbot(visible=False) g = gr.Textbox(visible=False) e = gr.Textbox(visible=False) f = gr.Button(visible=False) h = gr.Label(visible=False) m = gr.Image(visible=False) def fn_req(data): global r global q r = data[a] try: llm_q = questions(data[a]) llm_q = random.sample(llm_q, 3) except: llm_q = [] all_q = user_defined_questions + llm_q q = (i for i in all_q) return {a: gr.Textbox(visible=False), b: gr.Button(visible=False), c: gr.Label(value=data[a], label="Customer Requirement", visible=True), d: gr.Chatbot(label="Requirements Gathering", visible=True), g: gr.Textbox(value=nextGen(), label="Question", visible=True), e: gr.Textbox(label="Answer", visible=True), f: gr.Button("Submit Answer", visible=True)} def bot_user_response(question, answer, history): global qa global summary history = history + [[question, answer]] question = nextGen() if question: return {g: question, e: '', d: history} else: qa = requirement_string(r, history) summary = Summarizer(qa) # summary = """The user requires a YouTube thumbnail for an educational video. # They want a dancer to be featured in the image and # the tone or mood they want to convey is joyful.""" image = image_generator(summary) text = "Thank you for your response" return {g: gr.Textbox(visible=False), e: gr.Textbox(visible=False), d: history, h: gr.Label(value=text, visible=True, show_label=False), f: gr.Button(visible=False), m: gr.Image(value=image ,visible=True)} b.click(fn=fn_req, inputs={a}, outputs=[a,b,c,d,g,e,f]) f.click(bot_user_response, [g, e, d], [g, e, d, h, f, m]) demo.launch()