arvindershinh commited on
Commit
7ecd3a9
·
verified ·
1 Parent(s): 48fa0f7

Added user defined questions

Browse files
Files changed (1) hide show
  1. app.py +94 -78
app.py CHANGED
@@ -1,79 +1,95 @@
1
- from Promptless_LLM_Agent import questions
2
- from Summarization import Summarizer
3
- from TextToImage_StableDiffusion import generate as image_generator
4
-
5
- import gradio as gr
6
-
7
- def nextGen():
8
- try:
9
- x = next(q)
10
- except StopIteration:
11
- x = None
12
- return x
13
-
14
- def requirement_string(req, QA):
15
- req = "User Requirement: "+req+"\n"
16
- for q, a in QA:
17
- req = req+'\n'+'Graphic Designer: '+q+'\n'+'User: '+a
18
- return req
19
-
20
- r = None
21
- q = None
22
- qa = None
23
- summary = None
24
-
25
- with gr.Blocks() as demo:
26
-
27
- title = gr.Label(value="Graphic Designer", show_label=False)
28
-
29
- a = gr.Textbox(label="Enter Requirement")
30
- b = gr.Button("Submit")
31
- c = gr.Label(visible=False)
32
- d = gr.Chatbot(visible=False)
33
- g = gr.Textbox(visible=False)
34
- e = gr.Textbox(visible=False)
35
- f = gr.Button(visible=False)
36
- h = gr.Label(visible=False)
37
- m = gr.Image(visible=False)
38
-
39
- def fn_req(data):
40
- global r
41
- global q
42
- r = data[a]
43
- q = (i for i in questions(data[a])[:3])
44
- return {a: gr.Textbox(visible=False),
45
- b: gr.Button(visible=False),
46
- c: gr.Label(value=data[a], label="Customer Requirement", visible=True),
47
- d: gr.Chatbot(label="Requirements Gathering", visible=True),
48
- g: gr.Textbox(value=nextGen(), label="Question", visible=True),
49
- e: gr.Textbox(label="Answer", visible=True),
50
- f: gr.Button("Submit Answer", visible=True)}
51
-
52
- def bot_user_response(question, answer, history):
53
- global qa
54
- global summary
55
- history = history + [[question, answer]]
56
- question = nextGen()
57
-
58
- if question:
59
- return {g: question, e: '', d: history}
60
- else:
61
- qa = requirement_string(r, history)
62
- summary = Summarizer(qa)
63
- # summary = """The user requires a YouTube thumbnail for an educational video.
64
- # They want a dancer to be featured in the image and
65
- # the tone or mood they want to convey is joyful."""
66
- image = image_generator(summary)
67
- text = "Thank you for your response"
68
- return {g: gr.Textbox(visible=False),
69
- e: gr.Textbox(visible=False),
70
- d: history,
71
- h: gr.Label(value=text, visible=True, show_label=False),
72
- f: gr.Button(visible=False),
73
- m: gr.Image(value=image ,visible=True)}
74
-
75
- b.click(fn=fn_req, inputs={a}, outputs=[a,b,c,d,g,e,f])
76
-
77
- f.click(bot_user_response, [g, e, d], [g, e, d, h, f, m])
78
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  demo.launch()
 
1
+ from Promptless_LLM_Agent import questions
2
+ from Summarization import Summarizer
3
+ from TextToImage_StableDiffusion import generate as image_generator
4
+
5
+ import gradio as gr
6
+
7
+ 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?",
8
+ "What type of video is this (e.g., documentary, informative, sarcastic, comedy, tutorial, review, etc.)?",
9
+ "Are there any specific keywords or tags you want to include for search optimization? ",
10
+ "What is the desired mood or atmosphere for the thumbnail (e.g., energetic, calm, inspirational, humorous)?",
11
+ "What style or tone do you want to convey (e.g., serious, playful, minimalist, detailed)?",
12
+ "Are there any specific text elements (e.g., titles, subtitles, quotes) you want to include in the thumbnail?",
13
+ "Who is the target audience for this video?"]
14
+
15
+ def nextGen():
16
+ try:
17
+ x = next(q)
18
+ except StopIteration:
19
+ x = None
20
+ return x
21
+
22
+ def requirement_string(req, QA):
23
+ req = "User Requirement: "+req+"\n"
24
+ for q, a in QA:
25
+ req = req+'\n'+'Graphic Designer: '+q+'\n'+'User: '+a
26
+ return req
27
+
28
+ r = None
29
+ q = None
30
+ qa = None
31
+ summary = None
32
+
33
+ with gr.Blocks() as demo:
34
+
35
+ title = gr.Label(value="Graphic Designer", show_label=False)
36
+
37
+ a = gr.Textbox(label="Enter Requirement")
38
+ b = gr.Button("Submit")
39
+ c = gr.Label(visible=False)
40
+ d = gr.Chatbot(visible=False)
41
+ g = gr.Textbox(visible=False)
42
+ e = gr.Textbox(visible=False)
43
+ f = gr.Button(visible=False)
44
+ h = gr.Label(visible=False)
45
+ m = gr.Image(visible=False)
46
+
47
+ def fn_req(data):
48
+ global r
49
+ global q
50
+ r = data[a]
51
+
52
+ try:
53
+ llm_q = questions(data[a])
54
+ llm_q = random.sample(llm_q, 3)
55
+ except:
56
+ llm_q = []
57
+
58
+ all_q = user_defined_questions + llm_q
59
+ q = (i for i in all_q)
60
+ return {a: gr.Textbox(visible=False),
61
+ b: gr.Button(visible=False),
62
+ c: gr.Label(value=data[a], label="Customer Requirement", visible=True),
63
+ d: gr.Chatbot(label="Requirements Gathering", visible=True),
64
+ g: gr.Textbox(value=nextGen(), label="Question", visible=True),
65
+ e: gr.Textbox(label="Answer", visible=True),
66
+ f: gr.Button("Submit Answer", visible=True)}
67
+
68
+ def bot_user_response(question, answer, history):
69
+ global qa
70
+ global summary
71
+ history = history + [[question, answer]]
72
+ question = nextGen()
73
+
74
+ if question:
75
+ return {g: question, e: '', d: history}
76
+ else:
77
+ qa = requirement_string(r, history)
78
+ summary = Summarizer(qa)
79
+ # summary = """The user requires a YouTube thumbnail for an educational video.
80
+ # They want a dancer to be featured in the image and
81
+ # the tone or mood they want to convey is joyful."""
82
+ image = image_generator(summary)
83
+ text = "Thank you for your response"
84
+ return {g: gr.Textbox(visible=False),
85
+ e: gr.Textbox(visible=False),
86
+ d: history,
87
+ h: gr.Label(value=text, visible=True, show_label=False),
88
+ f: gr.Button(visible=False),
89
+ m: gr.Image(value=image ,visible=True)}
90
+
91
+ b.click(fn=fn_req, inputs={a}, outputs=[a,b,c,d,g,e,f])
92
+
93
+ f.click(bot_user_response, [g, e, d], [g, e, d, h, f, m])
94
+
95
  demo.launch()