Nina
commited on
Commit
β’
af9539a
1
Parent(s):
2de3b80
test layout in huggingface
Browse files
app.py
CHANGED
@@ -90,61 +90,69 @@ css_code = ".gradio-container {background-image: url('file=background.png');back
|
|
90 |
with gr.Blocks(title="π ClimateGPT Ekimetrics", css=css_code) as demo:
|
91 |
|
92 |
openai.api_key = os.environ["api_key"]
|
93 |
-
gr.Markdown("### Welcome to Climate GPT π ! ")
|
94 |
-
gr.Markdown(
|
95 |
-
"""
|
96 |
-
Climate GPT is an interactive exploration tool designed to help you easily find relevant information based on of Environmental reports such as IPCCs and other environmental reports.
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
)
|
104 |
-
gr.Markdown(
|
105 |
-
"β οΈ Warning: Always refer to the source (on the right side) to ensure the validity of the information communicated."
|
106 |
-
)
|
107 |
-
# gr.Markdown("""### Ask me anything, I'm a climate expert""")
|
108 |
-
with gr.Row():
|
109 |
-
with gr.Column(scale=2):
|
110 |
-
chatbot = gr.Chatbot()
|
111 |
-
state = gr.State([system_template])
|
112 |
-
|
113 |
-
with gr.Row():
|
114 |
-
ask = gr.Textbox(
|
115 |
-
show_label=False,
|
116 |
-
placeholder="Enter text and press enter",
|
117 |
-
sample_inputs=["which country polutes the most ?"],
|
118 |
-
).style(container=False)
|
119 |
-
print(f"Type from ask textbox {ask.type}")
|
120 |
-
|
121 |
-
with gr.Column(scale=1, variant="panel"):
|
122 |
-
gr.Markdown("### Sources")
|
123 |
-
sources_textbox = gr.Textbox(
|
124 |
-
interactive=False, show_label=False, max_lines=50
|
125 |
-
)
|
126 |
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
)
|
147 |
-
openai_api_key_textbox.change(set_openai_api_key, inputs=[openai_api_key_textbox])
|
148 |
-
openai_api_key_textbox.submit(set_openai_api_key, inputs=[openai_api_key_textbox])
|
149 |
|
|
|
|
|
150 |
demo.launch()
|
|
|
90 |
with gr.Blocks(title="π ClimateGPT Ekimetrics", css=css_code) as demo:
|
91 |
|
92 |
openai.api_key = os.environ["api_key"]
|
|
|
|
|
|
|
|
|
93 |
|
94 |
+
with gr.Tab("App"):
|
95 |
+
gr.Markdown("### Welcome to Climate GPT π ! ")
|
96 |
+
gr.Markdown(
|
97 |
+
"""
|
98 |
+
Climate GPT is an interactive exploration tool designed to help you easily find relevant information based on of Environmental reports such as IPCCs and other environmental reports.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
+
IPCC is a United Nations body that assesses the science related to climate change, including its impacts and possible response options. The IPCC is considered the leading scientific authority on all things related to global climate change.
|
101 |
+
"""
|
102 |
+
)
|
103 |
+
gr.Markdown(
|
104 |
+
"**How does it work:** This Chatbot is a combination of two technologies. FAISS search applied to a vast amount of scientific climate reports and TurboGPT to generate human-like text from the part of the document extracted from the database."
|
105 |
+
)
|
106 |
+
gr.Markdown(
|
107 |
+
"β οΈ Warning: Always refer to the source (on the right side) to ensure the validity of the information communicated."
|
108 |
+
)
|
109 |
+
# gr.Markdown("""### Ask me anything, I'm a climate expert""")
|
110 |
+
with gr.Row():
|
111 |
+
with gr.Column(scale=2):
|
112 |
+
chatbot = gr.Chatbot()
|
113 |
+
state = gr.State([system_template])
|
114 |
+
|
115 |
+
with gr.Row():
|
116 |
+
ask = gr.Textbox(
|
117 |
+
show_label=False,
|
118 |
+
placeholder="Enter text and press enter",
|
119 |
+
sample_inputs=["which country polutes the most ?"],
|
120 |
+
).style(container=False)
|
121 |
+
print(f"Type from ask textbox {ask.type}")
|
122 |
+
|
123 |
+
with gr.Column(scale=1, variant="panel"):
|
124 |
+
gr.Markdown("### Sources")
|
125 |
+
sources_textbox = gr.Textbox(
|
126 |
+
interactive=False, show_label=False, max_lines=50
|
127 |
+
)
|
128 |
+
|
129 |
+
ask.submit(
|
130 |
+
fn=gen_conv,
|
131 |
+
inputs=[
|
132 |
+
ask,
|
133 |
+
gr.inputs.Dropdown(
|
134 |
+
["IPCC only", "All available"],
|
135 |
+
default="All available",
|
136 |
+
label="Select reports",
|
137 |
+
),
|
138 |
+
state,
|
139 |
+
],
|
140 |
+
outputs=[chatbot, state, sources_textbox],
|
141 |
+
)
|
142 |
+
with gr.Accordion("Add your personal openai api key", open=False):
|
143 |
+
openai_api_key_textbox = gr.Textbox(
|
144 |
+
placeholder="Paste your OpenAI API key (sk-...) and hit Enter",
|
145 |
+
show_label=False,
|
146 |
+
lines=1,
|
147 |
+
type="password",
|
148 |
+
)
|
149 |
+
openai_api_key_textbox.change(
|
150 |
+
set_openai_api_key, inputs=[openai_api_key_textbox]
|
151 |
+
)
|
152 |
+
openai_api_key_textbox.submit(
|
153 |
+
set_openai_api_key, inputs=[openai_api_key_textbox]
|
154 |
)
|
|
|
|
|
155 |
|
156 |
+
with gr.Tab("Information"):
|
157 |
+
gr.Markdown("Here write information ")
|
158 |
demo.launch()
|