Spaces:
Paused
Paused
Commit
·
cb12053
1
Parent(s):
7827db1
Update app.py
Browse files
app.py
CHANGED
@@ -16,7 +16,6 @@ def getBrains():
|
|
16 |
return gr.update(choices=active_indexes)
|
17 |
|
18 |
|
19 |
-
|
20 |
prompt_names = ["Industry / Topic Research", "Data Analysis",
|
21 |
"Rewrite / Repurpose Content", "Create Long Form Article/Blog"]
|
22 |
prompt_enhancers = ["""Write at is if you had a Harvard MBA. You are providing in-depth report that is captured at the end of this [PROMPT]
|
@@ -68,29 +67,32 @@ mycss = """
|
|
68 |
|
69 |
#question {{background-color: {bgcolor};border-style:none; !important;box-shadow:none !important;padding-left:0;padding-right:0}}
|
70 |
#question span {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
71 |
-
#output {{background-color: {bgcolor};border-style:none;
|
72 |
#output span {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
73 |
#temp span {{background-color:#ffffff;color:{scolor}}}
|
74 |
#temp input {{accent-color:{scolor}}}
|
75 |
#tokens span {{background-color:#ffffff;color:{scolor}}}
|
76 |
#tokens input {{accent-color:{scolor}}}
|
77 |
-
#button {{background-color:{scolor};color:#ffffff;margin-top:
|
|
|
78 |
"""
|
79 |
formatted_css = mycss.format(bgcolor=bg_color, scolor=s_color)
|
80 |
|
81 |
|
82 |
def handleSubmit(brain_name, enhancer, question, temperature, maxTokens):
|
83 |
print(brain_name)
|
|
|
84 |
if (brain_name == "" and question == ""):
|
85 |
-
return "Please select Brain Name & Enter Question"
|
86 |
if (brain_name == ""):
|
87 |
-
return "Please select Brain Name"
|
88 |
if (question == ""):
|
89 |
-
return "Please Enter Question"
|
90 |
if (enhancer != ""):
|
91 |
promptIndex = prompt_names.index(enhancer)
|
92 |
-
|
93 |
-
|
|
|
94 |
|
95 |
|
96 |
with gr.Blocks(theme=gr.themes.Soft(), css=formatted_css) as block_demo:
|
@@ -104,6 +106,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=formatted_css) as block_demo:
|
|
104 |
|
105 |
with gr.Row(elem_id="secondrow"):
|
106 |
|
|
|
|
|
107 |
with gr.Column(scale=1, elem_id="inputsCol"):
|
108 |
|
109 |
brain_name = gr.Dropdown(
|
@@ -119,15 +123,20 @@ with gr.Blocks(theme=gr.themes.Soft(), css=formatted_css) as block_demo:
|
|
119 |
maxTokens = gr.Slider(minimum=200, maximum=2000,
|
120 |
step=100, value=1000, label="Max Tokens", elem_id="tokens")
|
121 |
|
122 |
-
submit_button = gr.Button(
|
123 |
|
124 |
-
with gr.Column(scale=1, elem_id="outputCol"
|
125 |
output_text = gr.TextArea(
|
126 |
-
label="Brain Output", lines=
|
|
|
|
|
|
|
|
|
127 |
|
128 |
submit_button.click(
|
129 |
-
handleSubmit, [brain_name, enhancer_name, question, temperature, maxTokens], output_text)
|
130 |
-
|
|
|
131 |
block_demo.load(getBrains, [], brain_name)
|
132 |
|
133 |
block_demo.launch(show_api=False)
|
|
|
16 |
return gr.update(choices=active_indexes)
|
17 |
|
18 |
|
|
|
19 |
prompt_names = ["Industry / Topic Research", "Data Analysis",
|
20 |
"Rewrite / Repurpose Content", "Create Long Form Article/Blog"]
|
21 |
prompt_enhancers = ["""Write at is if you had a Harvard MBA. You are providing in-depth report that is captured at the end of this [PROMPT]
|
|
|
67 |
|
68 |
#question {{background-color: {bgcolor};border-style:none; !important;box-shadow:none !important;padding-left:0;padding-right:0}}
|
69 |
#question span {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
70 |
+
#output {{background-color: {bgcolor};border-style:none;!important;box-shadow:none !important;padding-left:0;padding-right:0}}
|
71 |
#output span {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
72 |
#temp span {{background-color:#ffffff;color:{scolor}}}
|
73 |
#temp input {{accent-color:{scolor}}}
|
74 |
#tokens span {{background-color:#ffffff;color:{scolor}}}
|
75 |
#tokens input {{accent-color:{scolor}}}
|
76 |
+
#button {{background-color:{scolor};color:#ffffff;margin-top:22px}}
|
77 |
+
#buttonfollowup {{background-color:{scolor};color:#ffffff;margin-top:10px}}
|
78 |
"""
|
79 |
formatted_css = mycss.format(bgcolor=bg_color, scolor=s_color)
|
80 |
|
81 |
|
82 |
def handleSubmit(brain_name, enhancer, question, temperature, maxTokens):
|
83 |
print(brain_name)
|
84 |
+
prompt = ""
|
85 |
if (brain_name == "" and question == ""):
|
86 |
+
return "Please select Brain Name & Enter Question", False
|
87 |
if (brain_name == ""):
|
88 |
+
return "Please select Brain Name", False
|
89 |
if (question == ""):
|
90 |
+
return "Please Enter Question", False
|
91 |
if (enhancer != ""):
|
92 |
promptIndex = prompt_names.index(enhancer)
|
93 |
+
prompt = prompt_enhancers[promptIndex]
|
94 |
+
# question = prompt_enhancers[promptIndex]+question
|
95 |
+
return askQuestion(brain_name, question, prompt, temperature, maxTokens)
|
96 |
|
97 |
|
98 |
with gr.Blocks(theme=gr.themes.Soft(), css=formatted_css) as block_demo:
|
|
|
106 |
|
107 |
with gr.Row(elem_id="secondrow"):
|
108 |
|
109 |
+
memory = gr.State(value=False)
|
110 |
+
|
111 |
with gr.Column(scale=1, elem_id="inputsCol"):
|
112 |
|
113 |
brain_name = gr.Dropdown(
|
|
|
123 |
maxTokens = gr.Slider(minimum=200, maximum=2000,
|
124 |
step=100, value=1000, label="Max Tokens", elem_id="tokens")
|
125 |
|
126 |
+
submit_button = gr.Button(value="Submit", elem_id="button")
|
127 |
|
128 |
+
with gr.Column(scale=1, elem_id="outputCol"):
|
129 |
output_text = gr.TextArea(
|
130 |
+
label="Brain Output", lines=13, elem_id="output").style(show_copy_button=True)
|
131 |
+
followupquestion = gr.Textbox(
|
132 |
+
label="FOLLOW UP QUESTION", lines=2, elem_id="question")
|
133 |
+
followupButton = gr.Button(
|
134 |
+
value="FOLLOW UP", elem_id="buttonfollowup")
|
135 |
|
136 |
submit_button.click(
|
137 |
+
handleSubmit, [brain_name, enhancer_name, question, temperature, maxTokens], [output_text, memory])
|
138 |
+
followupButton.click(
|
139 |
+
runAgent, [memory, followupquestion, temperature, maxTokens], [output_text, memory])
|
140 |
block_demo.load(getBrains, [], brain_name)
|
141 |
|
142 |
block_demo.launch(show_api=False)
|