Spaces:
Sleeping
Sleeping
Update app_web.py
Browse files- app_web.py +210 -1
app_web.py
CHANGED
|
@@ -59,6 +59,10 @@ def init_session():
|
|
| 59 |
st.session_state.stata_options = None
|
| 60 |
if "stata_file" not in st.session_state:
|
| 61 |
st.session_state.stata_file = None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
|
| 63 |
# ── Sidebar ──────────────────────────────────────────────────────────────────
|
| 64 |
def render_landing_page():
|
|
@@ -656,6 +660,85 @@ def render_db():
|
|
| 656 |
row1 = st.columns((2,6), gap='medium')
|
| 657 |
row2 = st.container()
|
| 658 |
row3 = st.container()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 659 |
|
| 660 |
with row0[0]:
|
| 661 |
st.markdown(f"#### Pillar 1: Value Chain Alignment with Political Incentives")
|
|
@@ -819,7 +902,133 @@ def main():
|
|
| 819 |
is your first time working with PERI please proceed by letting me know what your particular interests are.")
|
| 820 |
|
| 821 |
if not st.session_state.bot_launched:
|
| 822 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 823 |
|
| 824 |
else:
|
| 825 |
# render_sidebar()
|
|
|
|
| 59 |
st.session_state.stata_options = None
|
| 60 |
if "stata_file" not in st.session_state:
|
| 61 |
st.session_state.stata_file = None
|
| 62 |
+
if "carousel_index" not in st.session_state:
|
| 63 |
+
st.session_state.carousel_index = 0
|
| 64 |
+
if "selected_items" not in st.session_state:
|
| 65 |
+
st.session_state.selected_items = set()
|
| 66 |
|
| 67 |
# ── Sidebar ──────────────────────────────────────────────────────────────────
|
| 68 |
def render_landing_page():
|
|
|
|
| 660 |
row1 = st.columns((2,6), gap='medium')
|
| 661 |
row2 = st.container()
|
| 662 |
row3 = st.container()
|
| 663 |
+
row4 = st.container()
|
| 664 |
+
|
| 665 |
+
with row4:
|
| 666 |
+
@st.cache_data
|
| 667 |
+
def fetch_results():
|
| 668 |
+
return [
|
| 669 |
+
{"id": 1, "title": "Option A", "desc": "Description for option A", "img": "https://picsum.photos"},
|
| 670 |
+
{"id": 2, "title": "Option B", "desc": "Description for option B", "img": "https://picsum.photos"},
|
| 671 |
+
{"id": 3, "title": "Option C", "desc": "Description for option C", "img": "https://picsum.photos"},
|
| 672 |
+
{"id": 4, "title": "Option D", "desc": "Description for option D", "img": "https://picsum.photos"},
|
| 673 |
+
{"id": 5, "title": "Option E", "desc": "Description for option E", "img": "https://picsum.photos"},
|
| 674 |
+
]
|
| 675 |
+
|
| 676 |
+
items = fetch_results()
|
| 677 |
+
ITEMS_PER_PAGE = 3 # Number of visible items in the carousel window
|
| 678 |
+
total_items = len(items)
|
| 679 |
+
|
| 680 |
+
# 3. Carousel Navigation Callbacks
|
| 681 |
+
def next_slide():
|
| 682 |
+
if st.session_state.carousel_index + ITEMS_PER_PAGE < total_items:
|
| 683 |
+
st.session_state.carousel_index += 1
|
| 684 |
+
|
| 685 |
+
def prev_slide():
|
| 686 |
+
if st.session_state.carousel_index > 0:
|
| 687 |
+
st.session_state.carousel_index -= 1
|
| 688 |
+
|
| 689 |
+
# --- UI Layout ---
|
| 690 |
+
st.title("Native Streamlit Multi-Select Carousel")
|
| 691 |
+
|
| 692 |
+
# 4. Create the Carousel Header & Navigation Controls
|
| 693 |
+
col_title, col_prev, col_next = st.columns([6, 1, 1])
|
| 694 |
+
|
| 695 |
+
with col_title:
|
| 696 |
+
st.subheader("Fetched Results")
|
| 697 |
+
|
| 698 |
+
with col_prev:
|
| 699 |
+
# Disable button if at the beginning
|
| 700 |
+
st.button("◀", on_click=prev_slide, disabled=(st.session_state.carousel_index == 0), use_container_width=True)
|
| 701 |
+
|
| 702 |
+
with col_next:
|
| 703 |
+
# Disable button if reached the end window
|
| 704 |
+
st.button("▶", on_click=next_slide, disabled=(st.session_state.carousel_index + ITEMS_PER_PAGE >= total_items), use_container_width=True)
|
| 705 |
+
|
| 706 |
+
st.write("---")
|
| 707 |
+
|
| 708 |
+
# 5. Render Visible Carousel Items Side-by-Side
|
| 709 |
+
visible_items = items[st.session_state.carousel_index : st.session_state.carousel_index + ITEMS_PER_PAGE]
|
| 710 |
+
carousel_cols = st.columns(ITEMS_PER_PAGE)
|
| 711 |
+
|
| 712 |
+
for i, col in enumerate(carousel_cols):
|
| 713 |
+
if i < len(visible_items):
|
| 714 |
+
item = visible_items[i]
|
| 715 |
+
with col:
|
| 716 |
+
# Custom container styling using native st.container(border=True)
|
| 717 |
+
with st.container(border=True):
|
| 718 |
+
st.image(item["img"], use_container_width=True)
|
| 719 |
+
st.markdown(f"**{item['title']}**")
|
| 720 |
+
st.caption(item["desc"])
|
| 721 |
+
|
| 722 |
+
# Checkbox for multi-selection tied directly to session state
|
| 723 |
+
is_selected = item["id"] in st.session_state.selected_items
|
| 724 |
+
checked = st.checkbox("Select", value=is_selected, key=f"check_{item['id']}")
|
| 725 |
+
|
| 726 |
+
# Update selections set based on checkbox value
|
| 727 |
+
if checked:
|
| 728 |
+
st.session_state.selected_items.add(item["id"])
|
| 729 |
+
else:
|
| 730 |
+
st.session_state.selected_items.discard(item["id"])
|
| 731 |
+
|
| 732 |
+
# 6. Display Selections
|
| 733 |
+
st.write("---")
|
| 734 |
+
st.subheader("Your Multi-Selected Options")
|
| 735 |
+
if st.session_state.selected_items:
|
| 736 |
+
# Map IDs back to full objects to show what is selected
|
| 737 |
+
selected_objects = [item for item in items if item["id"] in st.session_state.selected_items]
|
| 738 |
+
for sel in selected_objects:
|
| 739 |
+
st.success(f"Selected: **{sel['title']}** (ID: {sel['id']})")
|
| 740 |
+
else:
|
| 741 |
+
st.info("No options selected yet. Click the checkboxes above!")
|
| 742 |
|
| 743 |
with row0[0]:
|
| 744 |
st.markdown(f"#### Pillar 1: Value Chain Alignment with Political Incentives")
|
|
|
|
| 902 |
is your first time working with PERI please proceed by letting me know what your particular interests are.")
|
| 903 |
|
| 904 |
if not st.session_state.bot_launched:
|
| 905 |
+
st.session_state.bot_launched = True
|
| 906 |
+
# render_landing_page()
|
| 907 |
+
st.session_state.c2vc = {'cotton': {'financial_commitment': [{'budget_year': '2020',
|
| 908 |
+
'budget_value': 8.62,
|
| 909 |
+
'currency': 'Ushs Billion',
|
| 910 |
+
'responsible_institution': 'Cotton Development Organization (under MAAIF)',
|
| 911 |
+
'evidence': [{'quote': 'MAAIF_Budget_Trend__FY2020_21___FY2025_26__Ushs_Billion__Approved_Estimates = Cotton (CDO / Cotton Development), col_ = 8.62, col__2 = 8.04, col__3 = 7.73, col__4 = 5.37, col__5 = 5.08, col__6 = 3.03',
|
| 912 |
+
'source_document': 'Budget data/uganda_maaif_budget_trend.xlsx',
|
| 913 |
+
'page_or_section': 'CHUNK-SQL-001'}]},
|
| 914 |
+
{'budget_year': '2021',
|
| 915 |
+
'budget_value': 8.04,
|
| 916 |
+
'currency': 'Ushs Billion',
|
| 917 |
+
'responsible_institution': 'Cotton Development Organization (under MAAIF)',
|
| 918 |
+
'evidence': [{'quote': 'MAAIF_Budget_Trend__FY2020_21___FY2025_26__Ushs_Billion__Approved_Estimates = Cotton (CDO / Cotton Development), col_ = 8.62, col__2 = 8.04, col__3 = 7.73, col__4 = 5.37, col__5 = 5.08, col__6 = 3.03',
|
| 919 |
+
'source_document': 'Budget data/uganda_maaif_budget_trend.xlsx',
|
| 920 |
+
'page_or_section': 'CHUNK-SQL-001'}]},
|
| 921 |
+
{'budget_year': '2022',
|
| 922 |
+
'budget_value': 7.73,
|
| 923 |
+
'currency': 'Ushs Billion',
|
| 924 |
+
'responsible_institution': 'Cotton Development Organization (under MAAIF)',
|
| 925 |
+
'evidence': [{'quote': 'MAAIF_Budget_Trend__FY2020_21___FY2025_26__Ushs_Billion__Approved_Estimates = Cotton (CDO / Cotton Development), col_ = 8.62, col__2 = 8.04, col__3 = 7.73, col__4 = 5.37, col__5 = 5.08, col__6 = 3.03',
|
| 926 |
+
'source_document': 'Budget data/uganda_maaif_budget_trend.xlsx',
|
| 927 |
+
'page_or_section': 'CHUNK-SQL-001'}]},
|
| 928 |
+
{'budget_year': '2023',
|
| 929 |
+
'budget_value': 5.37,
|
| 930 |
+
'currency': 'Ushs Billion',
|
| 931 |
+
'responsible_institution': 'Cotton Development Organization (under MAAIF)',
|
| 932 |
+
'evidence': [{'quote': 'MAAIF_Budget_Trend__FY2020_21___FY2025_26__Ushs_Billion__Approved_Estimates = Cotton (CDO / Cotton Development), col_ = 8.62, col__2 = 8.04, col__3 = 7.73, col__4 = 5.37, col__5 = 5.08, col__6 = 3.03',
|
| 933 |
+
'source_document': 'Budget data/uganda_maaif_budget_trend.xlsx',
|
| 934 |
+
'page_or_section': 'CHUNK-SQL-001'}]},
|
| 935 |
+
{'budget_year': '2024',
|
| 936 |
+
'budget_value': 5.08,
|
| 937 |
+
'currency': 'Ushs Billion',
|
| 938 |
+
'responsible_institution': 'Cotton Development Organization (under MAAIF)',
|
| 939 |
+
'evidence': [{'quote': 'MAAIF_Budget_Trend__FY2020_21___FY2025_26__Ushs_Billion__Approved_Estimates = Cotton (CDO / Cotton Development), col_ = 8.62, col__2 = 8.04, col__3 = 7.73, col__4 = 5.37, col__5 = 5.08, col__6 = 3.03',
|
| 940 |
+
'source_document': 'Budget data/uganda_maaif_budget_trend.xlsx',
|
| 941 |
+
'page_or_section': 'CHUNK-SQL-001'}]},
|
| 942 |
+
{'budget_year': '2025',
|
| 943 |
+
'budget_value': 3.03,
|
| 944 |
+
'currency': 'Ushs Billion',
|
| 945 |
+
'responsible_institution': 'Cotton Development Organization (under MAAIF)',
|
| 946 |
+
'evidence': [{'quote': 'MAAIF_Budget_Trend__FY2020_21___FY2025_26__Ushs_Billion__Approved_Estimates = Cotton (CDO / Cotton Development), col_ = 8.62, col__2 = 8.04, col__3 = 7.73, col__4 = 5.37, col__5 = 5.08, col__6 = 3.03',
|
| 947 |
+
'source_document': 'Budget data/uganda_maaif_budget_trend.xlsx',
|
| 948 |
+
'page_or_section': 'CHUNK-SQL-001'}]},
|
| 949 |
+
{'budget_year': '2023',
|
| 950 |
+
'budget_value': 0.3,
|
| 951 |
+
'currency': 'Ushs Billion',
|
| 952 |
+
'responsible_institution': 'Cotton Development Organization',
|
| 953 |
+
'evidence': [{'quote': 'Domestic Development Funding for Project 0.300 0.300 0.360',
|
| 954 |
+
'source_document': 'Readings/Budgets & Macroeconomy/Public Investment Plan FY 2023-24.pdf',
|
| 955 |
+
'page_or_section': 'CHUNK-LOCAL-010'}]},
|
| 956 |
+
{'budget_year': '2024',
|
| 957 |
+
'budget_value': 0.3,
|
| 958 |
+
'currency': 'Ushs Billion',
|
| 959 |
+
'responsible_institution': 'Cotton Development Organization',
|
| 960 |
+
'evidence': [{'quote': 'Domestic Development Funding for Project 0.300 0.300 0.360',
|
| 961 |
+
'source_document': 'Readings/Budgets & Macroeconomy/Public Investment Plan FY 2023-24.pdf',
|
| 962 |
+
'page_or_section': 'CHUNK-LOCAL-010'}]},
|
| 963 |
+
{'budget_year': '2025',
|
| 964 |
+
'budget_value': 0.36,
|
| 965 |
+
'currency': 'Ushs Billion',
|
| 966 |
+
'responsible_institution': 'Cotton Development Organization',
|
| 967 |
+
'evidence': [{'quote': 'Domestic Development Funding for Project 0.300 0.300 0.360',
|
| 968 |
+
'source_document': 'Readings/Budgets & Macroeconomy/Public Investment Plan FY 2023-24.pdf',
|
| 969 |
+
'page_or_section': 'CHUNK-LOCAL-010'}]},
|
| 970 |
+
{'budget_year': '2024',
|
| 971 |
+
'budget_value': 0.27,
|
| 972 |
+
'currency': 'Ushs Billion',
|
| 973 |
+
'responsible_institution': 'Cotton Development Organization',
|
| 974 |
+
'evidence': [{'quote': 'Total Funding for Project 0.270 0.284 0.326',
|
| 975 |
+
'source_document': 'Readings/Budgets & Macroeconomy/Public Investment Plan FY 2024-25.pdf',
|
| 976 |
+
'page_or_section': 'CHUNK-LOCAL-007'}]},
|
| 977 |
+
{'budget_year': '2025',
|
| 978 |
+
'budget_value': 0.284,
|
| 979 |
+
'currency': 'Ushs Billion',
|
| 980 |
+
'responsible_institution': 'Cotton Development Organization',
|
| 981 |
+
'evidence': [{'quote': 'Total Funding for Project 0.270 0.284 0.326',
|
| 982 |
+
'source_document': 'Readings/Budgets & Macroeconomy/Public Investment Plan FY 2024-25.pdf',
|
| 983 |
+
'page_or_section': 'CHUNK-LOCAL-007'}]},
|
| 984 |
+
{'budget_year': '2026',
|
| 985 |
+
'budget_value': 0.326,
|
| 986 |
+
'currency': 'Ushs Billion',
|
| 987 |
+
'responsible_institution': 'Cotton Development Organization',
|
| 988 |
+
'evidence': [{'quote': 'Total Funding for Project 0.270 0.284 0.326',
|
| 989 |
+
'source_document': 'Readings/Budgets & Macroeconomy/Public Investment Plan FY 2024-25.pdf',
|
| 990 |
+
'page_or_section': 'CHUNK-LOCAL-007'}]},
|
| 991 |
+
{'budget_year': '2022',
|
| 992 |
+
'budget_value': 2035500,
|
| 993 |
+
'currency': 'Thousands Uganda Shillings',
|
| 994 |
+
'responsible_institution': 'Cotton Development Organization',
|
| 995 |
+
'evidence': [{'quote': 'Total Cost of Budget Output 010018 0 2,035,500 2,035,500',
|
| 996 |
+
'source_document': 'Readings/Budgets & Macroeconomy/Approved Budget Estimates FY 2022-23 Volume 1- Central Government.pdf',
|
| 997 |
+
'page_or_section': 'CHUNK-LOCAL-006'}]}],
|
| 998 |
+
'strategic_commitment': {'development_plan': [],
|
| 999 |
+
'agricultural_strategy': [{'quote': 'Strengthening cotton research in collaborati on with NARO. This is to strengthen cotton research and refocusing research priorities for provision of specialised facilities and production technology in order to achieve high productivity and incomes at farm levels. This intervention will be implemented by NARO.',
|
| 1000 |
+
'document': 'Ag Sector Strategic Plan_2015.pdf',
|
| 1001 |
+
'page_or_section': '81',
|
| 1002 |
+
'year': '2015',
|
| 1003 |
+
'citation': '[1]'},
|
| 1004 |
+
{'quote': 'Cotton lint production in 2014/15 amounted to 17,275 mt, of which 12,674 mt were exported. This generated US$21,918million for the country. The sector targets to produce 64,750 mt by 2020. In order to achieve these targets, the following activities need to be undertaken: completion of the seed processing plant in Pader district; provision of co tton inputs to farmers; support to value addition through implementation of the revolving lint buffer stock fund to ensure all year round supply of lint; strengthening cotton research; strengthening cotton farmers support programmes through extension and training in good agronomic practices; support to mechanisation in cotton. The total amount of funds required to implement these interventions are UGX95,82 billion.',
|
| 1005 |
+
'document': 'Ag Sector Strategic Plan_2015.pdf',
|
| 1006 |
+
'page_or_section': '17',
|
| 1007 |
+
'year': '2015',
|
| 1008 |
+
'citation': '[2]'}],
|
| 1009 |
+
'standalone_strategy': [],
|
| 1010 |
+
'flagship_project': []},
|
| 1011 |
+
'institutional_commitment': {'dedicated_agency': [{'agency_name': 'Cotton Development Organization (CDO)',
|
| 1012 |
+
'document': 'Public Investment Plan FY 2023-24.pdf',
|
| 1013 |
+
'page_or_section': 'Page 885',
|
| 1014 |
+
'quote': '"VOTE: 155 Cotton Development Organization"[1]'},
|
| 1015 |
+
{'agency_name': 'Cotton Development Organisation (CDO)',
|
| 1016 |
+
'document': 'Public Investment Plan FY 2021-22_0.pdf',
|
| 1017 |
+
'page_or_section': 'Page 95',
|
| 1018 |
+
'quote': '"Cotton Development Organisation (CDO), an agency under the Ministry of Agriculture, Animal Industry and Fisheries (MAAIF)"[2]'},
|
| 1019 |
+
{'agency_name': 'Uganda Cotton Development Organisation',
|
| 1020 |
+
'document': '18_19_ApprovedBudget_Nat.xlsx',
|
| 1021 |
+
'page_or_section': 'Approved_budget_rows_18647-18658',
|
| 1022 |
+
'quote': '"Vote: Uganda Cotton Development Organisation"[3]'},
|
| 1023 |
+
{'agency_name': 'Cotton Development Organization (CDO)',
|
| 1024 |
+
'document': 'Public Investment Plan FY 2023-24.pdf',
|
| 1025 |
+
'page_or_section': 'Page 884',
|
| 1026 |
+
'quote': '"VOTE: 155 Cotton Development Organization"[5]'}],
|
| 1027 |
+
'dedicated_research_institute': [{'institution_name': 'Cotton Research Institute',
|
| 1028 |
+
'document': 'Thesis-doc-Enzama-defended-17-12-2015.pdf',
|
| 1029 |
+
'page_or_section': 'Page 135',
|
| 1030 |
+
'quote': '"Most of its cotton related roles are vested in the Cotton Research Institute"[4]'}],
|
| 1031 |
+
'dedicated_ministerial_department': []}}}
|
| 1032 |
|
| 1033 |
else:
|
| 1034 |
# render_sidebar()
|