TheoLvs commited on
Commit
fa9f031
1 Parent(s): a99cd5f

Updated CSS

Browse files
Files changed (4) hide show
  1. app.py +54 -56
  2. climateqa/llm.py +7 -5
  3. climateqa/vectorstore.py +6 -4
  4. style.css +16 -2
app.py CHANGED
@@ -342,66 +342,65 @@ with gr.Blocks(title="🌍 Climate Q&A", css="style.css", theme=theme) as demo:
342
  # gr.Markdown("<h1><center>Climate Q&A 🌍</center></h1>")
343
  # gr.Markdown("<h4><center>Ask climate-related questions to the IPCC and IPBES reports using AI</center></h4>")
344
 
345
- with gr.Tab("💬 Chatbot"):
346
 
347
- with gr.Row():
348
  with gr.Column(scale=2):
349
  # state = gr.State([system_template])
350
- bot = gr.Chatbot(height=600,show_copy_button=True,show_label = False,elem_id="chatbot")
351
-
352
- with gr.Row():
353
- with gr.Column(scale = 7):
354
- textbox=gr.Textbox(placeholder="Ask me a question about climate change or biodiversity in any language!",show_label=False)
355
- with gr.Column(scale = 1):
356
- submit_button = gr.Button("Submit")
357
-
358
- examples_hidden = gr.Textbox(elem_id="hidden-message")
359
-
360
- examples_questions = gr.Examples(
361
- [
362
- "Is climate change caused by humans?",
363
- "What evidence do we have of climate change?",
364
- "What are the impacts of climate change?",
365
- "Can climate change be reversed?",
366
- "What is the difference between climate change and global warming?",
367
- "What can individuals do to address climate change?",
368
- "What are the main causes of climate change?",
369
- "What is the Paris Agreement and why is it important?",
370
- "Which industries have the highest GHG emissions?",
371
- "Is climate change a hoax created by the government or environmental organizations?",
372
- "What is the relationship between climate change and biodiversity loss?",
373
- "What is the link between gender equality and climate change?",
374
- "Is the impact of climate change really as severe as it is claimed to be?",
375
- "What is the impact of rising sea levels?",
376
- "What are the different greenhouse gases (GHG)?",
377
- "What is the warming power of methane?",
378
- "What is the jet stream?",
379
- "What is the breakdown of carbon sinks?",
380
- "How do the GHGs work ? Why does temperature increase ?",
381
- "What is the impact of global warming on ocean currents?",
382
- "How much warming is possible in 2050?",
383
- "What is the impact of climate change in Africa?",
384
- "Will climate change accelerate diseases and epidemics like COVID?",
385
- "What are the economic impacts of climate change?",
386
- "How much is the cost of inaction ?",
387
- "What is the relationship between climate change and poverty?",
388
- "What are the most effective strategies and technologies for reducing greenhouse gas (GHG) emissions?",
389
- "Is economic growth possible? What do you think about degrowth?",
390
- "Will technology save us?",
391
- "Is climate change a natural phenomenon ?",
392
- "Is climate change really happening or is it just a natural fluctuation in Earth's temperature?",
393
- "Is the scientific consensus on climate change really as strong as it is claimed to be?",
394
- ],
395
- [examples_hidden],
396
- examples_per_page=10,
397
- )
398
-
399
- with gr.Column(scale=1, variant="panel"):
400
 
401
- with gr.Tab("📚 Citations"):
402
  sources_textbox = gr.Markdown(show_label=False, elem_id="sources-textbox")
403
 
404
- with gr.Tab("⚙️ Configuration"):
405
 
406
  gr.Markdown("Reminder: You can talk in any language, ClimateQ&A is multi-lingual!")
407
 
@@ -613,5 +612,4 @@ Or around 2 to 4 times more than a typical Google search.
613
 
614
  demo.queue(concurrency_count=16)
615
 
616
- if __name__ == "__main__":
617
- demo.launch()
 
342
  # gr.Markdown("<h1><center>Climate Q&A 🌍</center></h1>")
343
  # gr.Markdown("<h4><center>Ask climate-related questions to the IPCC and IPBES reports using AI</center></h4>")
344
 
345
+ with gr.Tab("🌍 ClimateQ&A"):
346
 
347
+ with gr.Row(elem_id="chatbot-row"):
348
  with gr.Column(scale=2):
349
  # state = gr.State([system_template])
350
+ bot = gr.Chatbot(height="100%",show_copy_button=True,show_label = False,elem_id="chatbot")
351
+ textbox=gr.Textbox(placeholder="Ask me a question about climate change or biodiversity in any language!",show_label=False)
352
+ submit_button = gr.Button("Submit")
353
+
354
+
355
+ with gr.Column(scale=1, variant="panel",elem_id = "right-panel"):
356
+
357
+ with gr.Tab("📝 Examples",elem_id = "tab-examples"):
358
+
359
+ examples_hidden = gr.Textbox(elem_id="hidden-message")
360
+
361
+ examples_questions = gr.Examples(
362
+ [
363
+ "Is climate change caused by humans?",
364
+ "What evidence do we have of climate change?",
365
+ "What are the impacts of climate change?",
366
+ "Can climate change be reversed?",
367
+ "What is the difference between climate change and global warming?",
368
+ "What can individuals do to address climate change?",
369
+ "What are the main causes of climate change?",
370
+ "What is the Paris Agreement and why is it important?",
371
+ "Which industries have the highest GHG emissions?",
372
+ "Is climate change a hoax created by the government or environmental organizations?",
373
+ "What is the relationship between climate change and biodiversity loss?",
374
+ "What is the link between gender equality and climate change?",
375
+ "Is the impact of climate change really as severe as it is claimed to be?",
376
+ "What is the impact of rising sea levels?",
377
+ "What are the different greenhouse gases (GHG)?",
378
+ "What is the warming power of methane?",
379
+ "What is the jet stream?",
380
+ "What is the breakdown of carbon sinks?",
381
+ "How do the GHGs work ? Why does temperature increase ?",
382
+ "What is the impact of global warming on ocean currents?",
383
+ "How much warming is possible in 2050?",
384
+ "What is the impact of climate change in Africa?",
385
+ "Will climate change accelerate diseases and epidemics like COVID?",
386
+ "What are the economic impacts of climate change?",
387
+ "How much is the cost of inaction ?",
388
+ "What is the relationship between climate change and poverty?",
389
+ "What are the most effective strategies and technologies for reducing greenhouse gas (GHG) emissions?",
390
+ "Is economic growth possible? What do you think about degrowth?",
391
+ "Will technology save us?",
392
+ "Is climate change a natural phenomenon ?",
393
+ "Is climate change really happening or is it just a natural fluctuation in Earth's temperature?",
394
+ "Is the scientific consensus on climate change really as strong as it is claimed to be?",
395
+ ],
396
+ [examples_hidden],
397
+ examples_per_page=10,
398
+ )
 
399
 
400
+ with gr.Tab("📚 Citations",elem_id = "tab-citations"):
401
  sources_textbox = gr.Markdown(show_label=False, elem_id="sources-textbox")
402
 
403
+ with gr.Tab("⚙️ Configuration",elem_id = "tab-config"):
404
 
405
  gr.Markdown("Reminder: You can talk in any language, ClimateQ&A is multi-lingual!")
406
 
 
612
 
613
  demo.queue(concurrency_count=16)
614
 
615
+ demo.launch()
 
climateqa/llm.py CHANGED
@@ -1,9 +1,11 @@
1
  from langchain.chat_models import AzureChatOpenAI
2
-
3
- # LOAD ENVIRONMENT VARIABLES
4
- from dotenv import load_dotenv
5
  import os
6
- load_dotenv()
 
 
 
 
 
7
 
8
 
9
  def get_llm(max_tokens = 1024,temperature = 0.0,verbose = True,streaming = False, **kwargs):
@@ -20,4 +22,4 @@ def get_llm(max_tokens = 1024,temperature = 0.0,verbose = True,streaming = False
20
  streaming = streaming,
21
  **kwargs,
22
  )
23
- return llm
 
1
  from langchain.chat_models import AzureChatOpenAI
 
 
 
2
  import os
3
+ # LOAD ENVIRONMENT VARIABLES
4
+ try:
5
+ from dotenv import load_dotenv
6
+ load_dotenv()
7
+ except:
8
+ pass
9
 
10
 
11
  def get_llm(max_tokens = 1024,temperature = 0.0,verbose = True,streaming = False, **kwargs):
 
22
  streaming = streaming,
23
  **kwargs,
24
  )
25
+ return llm
climateqa/vectorstore.py CHANGED
@@ -1,14 +1,16 @@
1
  # Pinecone
2
  # More info at https://docs.pinecone.io/docs/langchain
3
  # And https://python.langchain.com/docs/integrations/vectorstores/pinecone
4
-
5
  import pinecone
6
  from langchain.vectorstores import Pinecone
7
 
8
  # LOAD ENVIRONMENT VARIABLES
9
- from dotenv import load_dotenv
10
- import os
11
- load_dotenv()
 
 
12
 
13
 
14
  def get_pinecone_vectorstore(embeddings,text_key = "content"):
 
1
  # Pinecone
2
  # More info at https://docs.pinecone.io/docs/langchain
3
  # And https://python.langchain.com/docs/integrations/vectorstores/pinecone
4
+ import os
5
  import pinecone
6
  from langchain.vectorstores import Pinecone
7
 
8
  # LOAD ENVIRONMENT VARIABLES
9
+ try:
10
+ from dotenv import load_dotenv
11
+ load_dotenv()
12
+ except:
13
+ pass
14
 
15
 
16
  def get_pinecone_vectorstore(embeddings,text_key = "content"):
style.css CHANGED
@@ -166,7 +166,21 @@ label.selected{
166
  background:none !important;
167
  }
168
 
 
 
 
 
 
 
169
  div#sources-textbox{
170
- height:100vh;
171
  overflow-y: auto;
172
- }
 
 
 
 
 
 
 
 
 
166
  background:none !important;
167
  }
168
 
169
+
170
+ div#tab-examples{
171
+ height:calc(100vh - 190px) !important;
172
+ overflow-y: auto;
173
+ }
174
+
175
  div#sources-textbox{
176
+ height:calc(100vh - 190px) !important;
177
  overflow-y: auto;
178
+ }
179
+
180
+ div#chatbot-row{
181
+ height:calc(100vh - 120px);
182
+ }
183
+
184
+ div#chatbot{
185
+ height:calc(100vh - 270px)
186
+ }