rag edit
Browse files- .DS_Store +0 -0
- appStore/__pycache__/rag.cpython-310.pyc +0 -0
- appStore/__pycache__/target.cpython-310.pyc +0 -0
- appStore/rag.py +16 -3
- appStore/target.py +6 -1
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
appStore/__pycache__/rag.cpython-310.pyc
CHANGED
Binary files a/appStore/__pycache__/rag.cpython-310.pyc and b/appStore/__pycache__/rag.cpython-310.pyc differ
|
|
appStore/__pycache__/target.cpython-310.pyc
CHANGED
Binary files a/appStore/__pycache__/target.cpython-310.pyc and b/appStore/__pycache__/target.cpython-310.pyc differ
|
|
appStore/rag.py
CHANGED
@@ -10,13 +10,26 @@ from tenacity import retry, stop_after_attempt, wait_random_exponential
|
|
10 |
|
11 |
# Get openai API key
|
12 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
13 |
-
model_select = "gpt-3.5-turbo-
|
14 |
|
15 |
|
16 |
# define a special function for putting the prompt together (as we can't use haystack)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def get_prompt(context, label):
|
18 |
-
base_prompt="Summarize the following context efficiently in bullet points, the less the better
|
19 |
-
Summarize only activities that address the vulnerability of "+label+" to climate change. \
|
20 |
Formatting example: \
|
21 |
- Bullet point 1 \
|
22 |
- Bullet point 2 \
|
|
|
10 |
|
11 |
# Get openai API key
|
12 |
openai.api_key = os.environ["OPENAI_API_KEY"]
|
13 |
+
model_select = "gpt-3.5-turbo-0125"
|
14 |
|
15 |
|
16 |
# define a special function for putting the prompt together (as we can't use haystack)
|
17 |
+
# def get_prompt(context, label):
|
18 |
+
# base_prompt="Summarize the following context efficiently in bullet points, the less the better - but keep concrete goals. \
|
19 |
+
# Summarize only activities that address the vulnerability of "+label+" to climate change. \
|
20 |
+
# Formatting example: \
|
21 |
+
# - Bullet point 1 \
|
22 |
+
# - Bullet point 2 \
|
23 |
+
# "
|
24 |
+
|
25 |
+
# # Add the meta data for references
|
26 |
+
# # context = ' - '.join([d.content for d in docs])
|
27 |
+
# prompt = base_prompt+"; Context: "+context+"; Answer:"
|
28 |
+
|
29 |
+
# return prompt
|
30 |
+
|
31 |
def get_prompt(context, label):
|
32 |
+
base_prompt="Summarize the following context efficiently in bullet points, the less the better. \
|
|
|
33 |
Formatting example: \
|
34 |
- Bullet point 1 \
|
35 |
- Bullet point 2 \
|
appStore/target.py
CHANGED
@@ -92,10 +92,15 @@ def target_display():
|
|
92 |
### RAG Output by group ##
|
93 |
|
94 |
# Expand the DataFrame
|
95 |
-
df_expand =
|
|
|
|
|
|
|
96 |
# Group by 'Vulnerability Label' and concatenate 'text'
|
97 |
df_agg = df_expand.groupby('Vulnerability Label')['text'].agg('; '.join).reset_index()
|
98 |
|
|
|
|
|
99 |
st.markdown("----")
|
100 |
st.markdown('**DOCUMENT FINDINGS SUMMARY BY VULNERABILITY LABEL:**')
|
101 |
|
|
|
92 |
### RAG Output by group ##
|
93 |
|
94 |
# Expand the DataFrame
|
95 |
+
df_expand = (
|
96 |
+
df.query("`Specific action/target/measure mentioned` == 'YES'")
|
97 |
+
.explode('Vulnerability Label')
|
98 |
+
)
|
99 |
# Group by 'Vulnerability Label' and concatenate 'text'
|
100 |
df_agg = df_expand.groupby('Vulnerability Label')['text'].agg('; '.join).reset_index()
|
101 |
|
102 |
+
# st.write(df_agg)
|
103 |
+
|
104 |
st.markdown("----")
|
105 |
st.markdown('**DOCUMENT FINDINGS SUMMARY BY VULNERABILITY LABEL:**')
|
106 |
|