annikwag commited on
Commit
53d69f4
·
verified ·
1 Parent(s): 043c4b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -9
app.py CHANGED
@@ -7,6 +7,8 @@ from appStore.search import hybrid_search
7
  from appStore.region_utils import load_region_data, get_country_name
8
  from torch import cuda
9
  import json
 
 
10
 
11
  # get the device to be used eithe gpu or cpu
12
  device = 'cuda' if cuda.is_available() else 'cpu'
@@ -70,7 +72,15 @@ col1, col2, col3 = st.columns([1, 1, 4])
70
  with col1:
71
  country_filter = st.selectbox("Country", ["All/Not allocated"] + unique_country_names) # Display country names
72
  with col2:
73
- end_year_range = st.slider("Project End Year", min_value=2010, max_value=2030, value=(2010, 2030))
 
 
 
 
 
 
 
 
74
 
75
  # Checkbox to control whether to show only exact matches
76
  show_exact_matches = st.checkbox("Show only exact matches", value=False)
@@ -112,7 +122,16 @@ if button:
112
  project_name = res.payload['metadata'].get('project_name', 'Project Link')
113
  url = res.payload['metadata'].get('url', '#')
114
  st.markdown(f"#### [{project_name}]({url})")
115
- st.write(res.payload['page_content'])
 
 
 
 
 
 
 
 
 
116
 
117
  # Additional text below the content
118
  metadata = res.payload.get('metadata', {})
@@ -134,9 +153,10 @@ if button:
134
  start_year = f"{int(round(float(start_year)))}" if start_year else "Unknown"
135
  end_year = f"{int(round(float(end_year)))}" if end_year else "Unknown"
136
 
137
- # Generate additional text
138
- additional_text = f"{', '.join(country_names)}, commissioned by {client}, {start_year}-{end_year}"
139
- st.write(additional_text)
 
140
 
141
  st.divider()
142
  else:
@@ -147,7 +167,16 @@ if button:
147
  project_name = res.payload['metadata'].get('project_name', 'Project Link')
148
  url = res.payload['metadata'].get('url', '#')
149
  st.markdown(f"#### [{project_name}]({url})")
150
- st.write(res.payload['page_content'])
 
 
 
 
 
 
 
 
 
151
 
152
  # Additional text below the content
153
  metadata = res.payload.get('metadata', {})
@@ -168,9 +197,10 @@ if button:
168
  start_year = f"{int(round(float(start_year)))}" if start_year else "Unknown"
169
  end_year = f"{int(round(float(end_year)))}" if end_year else "Unknown"
170
 
171
- # Generate additional text
172
- additional_text = f"{', '.join(country_names)}, commissioned by {client}, {start_year}-{end_year}"
173
- st.write(additional_text)
 
174
 
175
  st.divider()
176
 
 
7
  from appStore.region_utils import load_region_data, get_country_name
8
  from torch import cuda
9
  import json
10
+ from datetime import datetime
11
+
12
 
13
  # get the device to be used eithe gpu or cpu
14
  device = 'cuda' if cuda.is_available() else 'cpu'
 
72
  with col1:
73
  country_filter = st.selectbox("Country", ["All/Not allocated"] + unique_country_names) # Display country names
74
  with col2:
75
+ current_year = datetime.now().year
76
+ default_start_year = current_year - 5 # Default to 5 years ago
77
+
78
+ end_year_range = st.slider(
79
+ "Project End Year",
80
+ min_value=2010,
81
+ max_value=2030,
82
+ value=(default_start_year, current_year)
83
+ )
84
 
85
  # Checkbox to control whether to show only exact matches
86
  show_exact_matches = st.checkbox("Show only exact matches", value=False)
 
122
  project_name = res.payload['metadata'].get('project_name', 'Project Link')
123
  url = res.payload['metadata'].get('url', '#')
124
  st.markdown(f"#### [{project_name}]({url})")
125
+ # Show only the first 4 lines of text by default
126
+ page_content = res.payload['page_content']
127
+ lines = page_content.split('\n') # Split into lines
128
+ first_4_lines = '\n'.join(lines[:4]) # Get the first 4 lines
129
+
130
+ # Use expander for the rest of the content
131
+ st.write(first_4_lines) # Display the first 4 lines
132
+ if len(lines) > 4:
133
+ with st.expander("Read more"):
134
+ st.write('\n'.join(lines[4:])) # Display the remaining content
135
 
136
  # Additional text below the content
137
  metadata = res.payload.get('metadata', {})
 
153
  start_year = f"{int(round(float(start_year)))}" if start_year else "Unknown"
154
  end_year = f"{int(round(float(end_year)))}" if end_year else "Unknown"
155
 
156
+ # Generate additional text with Markdown for bold formatting
157
+ additional_text = f"**{', '.join(country_names)}**, commissioned by **{client}**, **{start_year}-{end_year}**"
158
+ st.markdown(additional_text)
159
+
160
 
161
  st.divider()
162
  else:
 
167
  project_name = res.payload['metadata'].get('project_name', 'Project Link')
168
  url = res.payload['metadata'].get('url', '#')
169
  st.markdown(f"#### [{project_name}]({url})")
170
+ # Show only the first 4 lines of text by default
171
+ page_content = res.payload['page_content']
172
+ lines = page_content.split('\n') # Split into lines
173
+ first_4_lines = '\n'.join(lines[:4]) # Get the first 4 lines
174
+
175
+ # Use expander for the rest of the content
176
+ st.write(first_4_lines) # Display the first 4 lines
177
+ if len(lines) > 4:
178
+ with st.expander("Read more"):
179
+ st.write('\n'.join(lines[4:])) # Display the remaining content
180
 
181
  # Additional text below the content
182
  metadata = res.payload.get('metadata', {})
 
197
  start_year = f"{int(round(float(start_year)))}" if start_year else "Unknown"
198
  end_year = f"{int(round(float(end_year)))}" if end_year else "Unknown"
199
 
200
+ # Generate additional text with Markdown for bold formatting
201
+ additional_text = f"**{', '.join(country_names)}**, commissioned by **{client}**, **{start_year}-{end_year}**"
202
+ st.markdown(additional_text)
203
+
204
 
205
  st.divider()
206