Added sample questions
Browse files- climateqa/constants.py +45 -0
- climateqa/sample_questions.py +78 -0
- climateqa/utils.py +22 -0
- climateqa/vectorstore.py +0 -44
climateqa/constants.py
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
POSSIBLE_REPORTS = [
|
2 |
+
"IPCC AR6 WGI SPM",
|
3 |
+
"IPCC AR6 WGI FR",
|
4 |
+
"IPCC AR6 WGI TS",
|
5 |
+
"IPCC AR6 WGII SPM",
|
6 |
+
"IPCC AR6 WGII TS",
|
7 |
+
"IPCC AR6 WGII FR",
|
8 |
+
"IPCC AR6 WGIII SPM",
|
9 |
+
"IPCC AR6 WGIII TS",
|
10 |
+
"IPCC AR6 WGIII FR",
|
11 |
+
"IPCC AR6 SYR",
|
12 |
+
"IPCC SR GW SPM",
|
13 |
+
"IPCC SR CCL SPM",
|
14 |
+
"IPCC SR OC SPM",
|
15 |
+
"IPCC SR OC TS",
|
16 |
+
"IPCC SR OC C1",
|
17 |
+
"IPCC SR OC C2",
|
18 |
+
"IPCC SR OC C3",
|
19 |
+
"IPCC SR OC C4",
|
20 |
+
"IPCC SR OC C5",
|
21 |
+
"IPCC SR OC C6",
|
22 |
+
"IPCC SR OC CC B9",
|
23 |
+
"IPCC SR OC A1 G",
|
24 |
+
"IPBES GAR FR",
|
25 |
+
"IPBES GAR SPM",
|
26 |
+
"IPBES TAM SW FR",
|
27 |
+
"IPBES TAM SW SPM",
|
28 |
+
"IPBES RAR AF FR",
|
29 |
+
"IPBES RAR AF SPM",
|
30 |
+
"IPBES RAR AM FR",
|
31 |
+
"IPBES RAR AM SPM",
|
32 |
+
"IPBES RAR AP FR",
|
33 |
+
"IPBES RAR AP SPM",
|
34 |
+
"IPBES RAR ECA FR",
|
35 |
+
"IPBES RAR ECA SPM",
|
36 |
+
"IPBES AR LDR FR",
|
37 |
+
"IPBES AR LDR SPM",
|
38 |
+
"IPBES IAS A C1",
|
39 |
+
"IPBES IAS A C2",
|
40 |
+
"IPBES IAS A C3",
|
41 |
+
"IPBES IAS A C4",
|
42 |
+
"IPBES IAS A C5",
|
43 |
+
"IPBES IAS A C6",
|
44 |
+
"IPBES IAS A SPM"
|
45 |
+
]
|
climateqa/sample_questions.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
QUESTIONS = {
|
3 |
+
"Popular Questions": [
|
4 |
+
"What are the main causes of climate change?",
|
5 |
+
"What evidence do we have of climate change?",
|
6 |
+
"What are the impacts of climate change?",
|
7 |
+
"Can climate change be reversed?",
|
8 |
+
"What is the difference between climate change and global warming?",
|
9 |
+
"What can individuals do to address climate change?",
|
10 |
+
"What is the Paris Agreement and why is it important?",
|
11 |
+
"Is climate change a hoax created by the government or environmental organizations?",
|
12 |
+
"What is the relationship between climate change and biodiversity loss?",
|
13 |
+
"Is climate change caused by humans?",
|
14 |
+
"What is the link between gender equality and climate change?",
|
15 |
+
"Is the impact of climate change really as severe as it is claimed to be?",
|
16 |
+
"What is the impact of rising sea levels?",
|
17 |
+
"What are the different greenhouse gases (GHG)?",
|
18 |
+
"What is the warming power of methane?",
|
19 |
+
"What is the jet stream?",
|
20 |
+
"What is the breakdown of carbon sinks?",
|
21 |
+
"How do the GHGs work ? Why does temperature increase ?",
|
22 |
+
"What is the impact of global warming on ocean currents?",
|
23 |
+
"How much warming is possible in 2050?",
|
24 |
+
"Will climate change accelerate diseases and epidemics like COVID?",
|
25 |
+
"What are the economic impacts of climate change?",
|
26 |
+
"What are the most effective strategies and technologies for reducing greenhouse gas (GHG) emissions?",
|
27 |
+
"Is climate change a natural phenomenon ?",
|
28 |
+
"Is climate change really happening or is it just a natural fluctuation in Earth's temperature?",
|
29 |
+
"Is the scientific consensus on climate change really as strong as it is claimed to be?",
|
30 |
+
],
|
31 |
+
"Climate Science":[
|
32 |
+
"How do climate models project the interaction between atmospheric CO2 levels and global temperature changes over the next century?",
|
33 |
+
"What are the projected impacts of arctic permafrost thawing on global methane emissions?",
|
34 |
+
"How does the IPCC assess the efficacy of different carbon capture and storage technologies in mitigating climate change?",
|
35 |
+
"What are the predicted changes in oceanic thermohaline circulation under various greenhouse gas emission scenarios?",
|
36 |
+
"How does increased atmospheric CO2 concentration affect the acidification of oceans and its impact on marine biodiversity?",
|
37 |
+
"What role do cloud formations play in modulating the Earth's radiative balance, and how are they represented in current climate models?",
|
38 |
+
"What are the implications of polar ice sheet dynamics for global sea-level rise under high-emission scenarios?",
|
39 |
+
"How do feedback mechanisms in the climate system, such as the albedo effect, influence global warming projections?",
|
40 |
+
"What are the latest findings on the sensitivity of the climate to a doubling of pre-industrial CO2 levels?",
|
41 |
+
"How do regional climate projections differ in terms of extreme weather events like droughts, floods, and heatwaves?",
|
42 |
+
],
|
43 |
+
"Economy":[
|
44 |
+
"Which industries have the highest GHG emissions?",
|
45 |
+
"How much is the cost of inaction ?",
|
46 |
+
"Will technology save us?",
|
47 |
+
"What is the relationship between climate change and poverty?",
|
48 |
+
"Is economic growth possible? What do you think about degrowth?",
|
49 |
+
],
|
50 |
+
"Invasive Species": [
|
51 |
+
"What are invasive alien species and how do they threaten biodiversity and ecosystems?",
|
52 |
+
"How do invasive alien species contribute to global and local species extinctions?",
|
53 |
+
"In what ways do invasive species lead to biotic homogenization?",
|
54 |
+
"What are the economic impacts of invasive alien species on global economies?",
|
55 |
+
"How do invasive alien species affect food and water security and human health?",
|
56 |
+
"What are the challenges in managing invasive alien species in different regions?",
|
57 |
+
"How are human activities contributing to the spread of invasive alien species?",
|
58 |
+
"What are the current trends and future predictions regarding the threats from invasive alien species?",
|
59 |
+
"How can we predict the future impact of invasive alien species given their complex interactions with other factors?",
|
60 |
+
"What is the role of international trade in facilitating the introduction of invasive alien species?",
|
61 |
+
"What are some effective strategies for managing invasive alien species?",
|
62 |
+
"How crucial is prevention in managing the threats from invasive alien species?",
|
63 |
+
"What are some successful examples of eradication of invasive alien species?",
|
64 |
+
"What are the limitations and successes of containment and control strategies for invasive alien species?",
|
65 |
+
"How does adaptive management, including ecosystem restoration, help in dealing with invasive species?",
|
66 |
+
"Why is stakeholder and community engagement important in managing biological invasions?",
|
67 |
+
"What is integrated governance in the context of biological invasion management?",
|
68 |
+
"How can international and regional collaboration improve the management of biological invasions?",
|
69 |
+
"What opportunities does the Kunming-Montreal Global Biodiversity Framework provide in addressing invasive species?",
|
70 |
+
"How does managing invasive alien species intersect with achieving Sustainable Development Goals?",
|
71 |
+
"What are the implications of biological invasions for policies aimed at conserving marine and terrestrial biodiversity?",
|
72 |
+
"How do demographic changes influence the spread of invasive alien species?",
|
73 |
+
"What are the impacts of invasive alien species on Indigenous Peoples and local communities?",
|
74 |
+
"What technologies and tools are available for managing invasive alien species?",
|
75 |
+
"How do economic and land-use changes facilitate the introduction and spread of invasive alien species?"
|
76 |
+
]
|
77 |
+
|
78 |
+
}
|
climateqa/utils.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import io
|
3 |
+
import os
|
4 |
+
from PIL import Image
|
5 |
+
from azure.storage.blob import ContainerClient
|
6 |
+
|
7 |
+
|
8 |
+
def get_file_from_azure_blob_storage(path):
|
9 |
+
AZURE_SAS_URL_TRD = os.environ["AZURE_SAS_URL_TRD"]
|
10 |
+
container_client = ContainerClient.from_container_url(AZURE_SAS_URL_TRD)
|
11 |
+
blob_client = container_client.get_blob_client(path)
|
12 |
+
stream = blob_client.download_blob().readall()
|
13 |
+
file_object = io.BytesIO(stream)
|
14 |
+
return file_object
|
15 |
+
|
16 |
+
|
17 |
+
def get_image_from_azure_blob_storage(path):
|
18 |
+
base_path = "search_demo/climateq&a/processed_image/"
|
19 |
+
path = os.path.join(base_path, path)
|
20 |
+
file_object = get_file_from_azure_blob_storage(path)
|
21 |
+
image = Image.open(file_object)
|
22 |
+
return image
|
climateqa/vectorstore.py
DELETED
@@ -1,44 +0,0 @@
|
|
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"):
|
17 |
-
|
18 |
-
# initialize pinecone
|
19 |
-
pinecone.init(
|
20 |
-
api_key=os.getenv("PINECONE_API_KEY"), # find at app.pinecone.io
|
21 |
-
environment=os.getenv("PINECONE_API_ENVIRONMENT"), # next to api key in console
|
22 |
-
)
|
23 |
-
|
24 |
-
index_name = os.getenv("PINECONE_API_INDEX")
|
25 |
-
vectorstore = Pinecone.from_existing_index(index_name, embeddings,text_key = text_key)
|
26 |
-
return vectorstore
|
27 |
-
|
28 |
-
|
29 |
-
# def get_pinecone_retriever(vectorstore,k = 10,namespace = "vectors",sources = ["IPBES","IPCC"]):
|
30 |
-
|
31 |
-
# assert isinstance(sources,list)
|
32 |
-
|
33 |
-
# # Check if all elements in the list are either IPCC or IPBES
|
34 |
-
# filter = {
|
35 |
-
# "source": { "$in":sources},
|
36 |
-
# }
|
37 |
-
|
38 |
-
# retriever = vectorstore.as_retriever(search_kwargs={
|
39 |
-
# "k": k,
|
40 |
-
# "namespace":"vectors",
|
41 |
-
# "filter":filter
|
42 |
-
# })
|
43 |
-
|
44 |
-
# return retriever
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|