Spaces:
Paused
Paused
Commit
·
3cdd448
1
Parent(s):
228f50e
Update app.py
Browse files
app.py
CHANGED
@@ -16,37 +16,46 @@ def getBrains():
|
|
16 |
return gr.update(choices=active_indexes)
|
17 |
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
bg_color = "#c5dde0"
|
20 |
s_color = "#1d2230"
|
21 |
mycss = """
|
22 |
.gradio-container {{background-color: {bgcolor}}}
|
23 |
#title {{margin-top:33%;margin-bottom:25px;display:flex;justify-content:center;align-items:center}}
|
|
|
24 |
#title h1 {{font-weight:900;color:{scolor}}}
|
25 |
#advanced {{font-weight:600;background-color:#ffffff}}
|
26 |
#secondrow {{padding:0 6%;gap:30px}}
|
27 |
-
|
28 |
-
|
29 |
#name {{background-color: {bgcolor};border-style:none;border-width:0;box-shadow:none;padding-left:0;padding-right:0}}
|
30 |
#name .svelte-1gfkn6j {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
31 |
-
|
32 |
|
|
|
|
|
|
|
|
|
33 |
#question {{background-color: {bgcolor};border-style:none; !important;box-shadow:none !important;padding-left:0;padding-right:0}}
|
34 |
#question span {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
35 |
-
|
36 |
#output {{background-color: {bgcolor};border-style:none;border-width:0;box-shadow:none}}
|
37 |
#output span {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
38 |
-
|
39 |
#temp span {{background-color:#ffffff;color:{scolor}}}
|
40 |
#temp input {{accent-color:{scolor}}}
|
41 |
#tokens span {{background-color:#ffffff;color:{scolor}}}
|
42 |
#tokens input {{accent-color:{scolor}}}
|
43 |
-
|
44 |
#button {{background-color:{scolor};color:#ffffff;margin-top:29px}}
|
45 |
"""
|
46 |
formatted_css = mycss.format(bgcolor=bg_color, scolor=s_color)
|
47 |
|
48 |
|
49 |
-
def handleSubmit(brain_name, question, temperature, maxTokens):
|
50 |
print(brain_name)
|
51 |
if (brain_name == "" and question == ""):
|
52 |
return "Please select Brain Name & Enter Question"
|
@@ -54,6 +63,9 @@ def handleSubmit(brain_name, question, temperature, maxTokens):
|
|
54 |
return "Please select Brain Name"
|
55 |
if (question == ""):
|
56 |
return "Please Enter Question"
|
|
|
|
|
|
|
57 |
return askQuestion(brain_name, question, temperature, maxTokens)
|
58 |
|
59 |
|
@@ -72,6 +84,8 @@ with gr.Blocks(theme=gr.themes.Soft(), css=formatted_css) as block_demo:
|
|
72 |
|
73 |
brain_name = gr.Dropdown(
|
74 |
label="Brain Name", choices=None, elem_id="name", multiselect=False, interactive=True)
|
|
|
|
|
75 |
question = gr.Textbox(
|
76 |
label="Question", lines=2, elem_id="question")
|
77 |
|
@@ -85,11 +99,11 @@ with gr.Blocks(theme=gr.themes.Soft(), css=formatted_css) as block_demo:
|
|
85 |
|
86 |
with gr.Column(scale=1, elem_id="outputCol",):
|
87 |
output_text = gr.TextArea(
|
88 |
-
label="Brain Output", lines=
|
89 |
|
90 |
submit_button.click(
|
91 |
-
handleSubmit, [brain_name, question, temperature, maxTokens], output_text)
|
92 |
|
93 |
block_demo.load(getBrains, [], brain_name)
|
94 |
|
95 |
-
block_demo.launch(show_api=False)
|
|
|
16 |
return gr.update(choices=active_indexes)
|
17 |
|
18 |
|
19 |
+
prompt_names = ["Research & Summarize"]
|
20 |
+
prompt_enhancers = ["""Please act as a researcher and summarizer for the [TOPIC] I list at the end of this prompt. Create a concise, accurate, and objective summary of the main points and findings. Use clear headlines, bullet points, and sub-bullet points where needed. Keep in mind the following guidelines:
|
21 |
+
Avoid personal opinions or interpretations; focus on objectively presenting the information.
|
22 |
+
Write the summary in your own words.
|
23 |
+
Reference data sources when necessary.
|
24 |
+
Ensure the summary is clear and concise.
|
25 |
+
Please write in English language.
|
26 |
+
"""]
|
27 |
+
|
28 |
+
|
29 |
bg_color = "#c5dde0"
|
30 |
s_color = "#1d2230"
|
31 |
mycss = """
|
32 |
.gradio-container {{background-color: {bgcolor}}}
|
33 |
#title {{margin-top:33%;margin-bottom:25px;display:flex;justify-content:center;align-items:center}}
|
34 |
+
.gap.svelte-vt1mxs {{gap:0}}
|
35 |
#title h1 {{font-weight:900;color:{scolor}}}
|
36 |
#advanced {{font-weight:600;background-color:#ffffff}}
|
37 |
#secondrow {{padding:0 6%;gap:30px}}
|
|
|
|
|
38 |
#name {{background-color: {bgcolor};border-style:none;border-width:0;box-shadow:none;padding-left:0;padding-right:0}}
|
39 |
#name .svelte-1gfkn6j {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
|
|
40 |
|
41 |
+
#enhancer-name {{background-color: {bgcolor};border-style:none;border-width:0;box-shadow:none;padding-left:0;padding-right:0}}
|
42 |
+
#enhancer-name .svelte-1gfkn6j {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
43 |
+
#enhancer-name .svelte-e8n7p6 {{color:{scolor};padding-left:8px}}
|
44 |
+
|
45 |
#question {{background-color: {bgcolor};border-style:none; !important;box-shadow:none !important;padding-left:0;padding-right:0}}
|
46 |
#question span {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
|
|
47 |
#output {{background-color: {bgcolor};border-style:none;border-width:0;box-shadow:none}}
|
48 |
#output span {{background-color:{bgcolor};color:{scolor};font-size:18px}}
|
|
|
49 |
#temp span {{background-color:#ffffff;color:{scolor}}}
|
50 |
#temp input {{accent-color:{scolor}}}
|
51 |
#tokens span {{background-color:#ffffff;color:{scolor}}}
|
52 |
#tokens input {{accent-color:{scolor}}}
|
|
|
53 |
#button {{background-color:{scolor};color:#ffffff;margin-top:29px}}
|
54 |
"""
|
55 |
formatted_css = mycss.format(bgcolor=bg_color, scolor=s_color)
|
56 |
|
57 |
|
58 |
+
def handleSubmit(brain_name, enhancer, question, temperature, maxTokens):
|
59 |
print(brain_name)
|
60 |
if (brain_name == "" and question == ""):
|
61 |
return "Please select Brain Name & Enter Question"
|
|
|
63 |
return "Please select Brain Name"
|
64 |
if (question == ""):
|
65 |
return "Please Enter Question"
|
66 |
+
if (enhancer != ""):
|
67 |
+
promptIndex = prompt_names.index(enhancer)
|
68 |
+
question = prompt_enhancers[promptIndex]+question
|
69 |
return askQuestion(brain_name, question, temperature, maxTokens)
|
70 |
|
71 |
|
|
|
84 |
|
85 |
brain_name = gr.Dropdown(
|
86 |
label="Brain Name", choices=None, elem_id="name", multiselect=False, interactive=True)
|
87 |
+
enhancer_name = gr.Dropdown(
|
88 |
+
label="Prompt Template (Optional)", choices=prompt_names, elem_id="enhancer-name", multiselect=False, interactive=True)
|
89 |
question = gr.Textbox(
|
90 |
label="Question", lines=2, elem_id="question")
|
91 |
|
|
|
99 |
|
100 |
with gr.Column(scale=1, elem_id="outputCol",):
|
101 |
output_text = gr.TextArea(
|
102 |
+
label="Brain Output", lines=17, elem_id="output").style(show_copy_button=True)
|
103 |
|
104 |
submit_button.click(
|
105 |
+
handleSubmit, [brain_name, enhancer_name, question, temperature, maxTokens], output_text)
|
106 |
|
107 |
block_demo.load(getBrains, [], brain_name)
|
108 |
|
109 |
+
block_demo.launch(show_api=False)
|