added the cover image
Browse files- app.py +21 -3
- procurement.png +0 -0
- requirements.txt +2 -1
app.py
CHANGED
@@ -2,6 +2,8 @@ import streamlit as st
|
|
2 |
import os
|
3 |
import google.generativeai as genai
|
4 |
from huggingface_hub import hf_hub_download
|
|
|
|
|
5 |
|
6 |
MODEL_ID = "gemini-2.0-flash-exp" # Keep the model ID as is
|
7 |
try:
|
@@ -37,8 +39,6 @@ if "uploaded_file_part" not in st.session_state: # Store the file *part*
|
|
37 |
if "uploaded_pdf_path" not in st.session_state:
|
38 |
st.session_state.uploaded_pdf_path = download_pdf()
|
39 |
|
40 |
-
|
41 |
-
|
42 |
def multimodal_prompt(pdf_path, text_prompt):
|
43 |
"""
|
44 |
Sends a multimodal prompt to Gemini, handling file uploads efficiently.
|
@@ -75,6 +75,17 @@ procurement_types = ["Competitive Bidding", "Limited Source Bidding", "Competiti
|
|
75 |
"Repeat Order", "Small Value Procurement", "Negotiated Procurement",
|
76 |
"Direct Sales", "Direct Procurement for Science, Technology and Innovation"]
|
77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
# --- Sidebar ---
|
80 |
st.sidebar.title("🤖 Visual Q and A")
|
@@ -102,6 +113,10 @@ Key features:
|
|
102 |
with st.expander("How to use this App"):
|
103 |
st.markdown(about)
|
104 |
|
|
|
|
|
|
|
|
|
105 |
# --- Tabs ---
|
106 |
tab1, tab2, tab3 = st.tabs(["Q and A", "Glossary", "Checklists"])
|
107 |
|
@@ -337,4 +352,7 @@ with tab3:
|
|
337 |
filepath = st.session_state.uploaded_pdf_path
|
338 |
text_prompt = f"Use the provided document to create a checklist in the context of {selected_role} and {selected_procurement_type} task: {user_task}"
|
339 |
response = multimodal_prompt(filepath, text_prompt) # Use the downloaded filepath
|
340 |
-
st.markdown(f"**Response:** {response}")
|
|
|
|
|
|
|
|
2 |
import os
|
3 |
import google.generativeai as genai
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
+
from PIL import Image
|
6 |
+
import base64
|
7 |
|
8 |
MODEL_ID = "gemini-2.0-flash-exp" # Keep the model ID as is
|
9 |
try:
|
|
|
39 |
if "uploaded_pdf_path" not in st.session_state:
|
40 |
st.session_state.uploaded_pdf_path = download_pdf()
|
41 |
|
|
|
|
|
42 |
def multimodal_prompt(pdf_path, text_prompt):
|
43 |
"""
|
44 |
Sends a multimodal prompt to Gemini, handling file uploads efficiently.
|
|
|
75 |
"Repeat Order", "Small Value Procurement", "Negotiated Procurement",
|
76 |
"Direct Sales", "Direct Procurement for Science, Technology and Innovation"]
|
77 |
|
78 |
+
def display_download_button(file_path, file_name):
|
79 |
+
try:
|
80 |
+
with open(file_path, "rb") as f:
|
81 |
+
file_bytes = f.read()
|
82 |
+
b64 = base64.b64encode(file_bytes).decode()
|
83 |
+
href = f'<a href="data:application/pdf;base64,{b64}" download="{file_name}">Download the source document (PDF)</a>'
|
84 |
+
st.markdown(href, unsafe_allow_html=True)
|
85 |
+
except FileNotFoundError:
|
86 |
+
st.error("File not found for download.")
|
87 |
+
except Exception as e:
|
88 |
+
st.error(f"Error during download: {e}")
|
89 |
|
90 |
# --- Sidebar ---
|
91 |
st.sidebar.title("🤖 Visual Q and A")
|
|
|
113 |
with st.expander("How to use this App"):
|
114 |
st.markdown(about)
|
115 |
|
116 |
+
# --- Load the image ---
|
117 |
+
image = Image.open("procurement.png")
|
118 |
+
st.image(image, width=400)
|
119 |
+
|
120 |
# --- Tabs ---
|
121 |
tab1, tab2, tab3 = st.tabs(["Q and A", "Glossary", "Checklists"])
|
122 |
|
|
|
352 |
filepath = st.session_state.uploaded_pdf_path
|
353 |
text_prompt = f"Use the provided document to create a checklist in the context of {selected_role} and {selected_procurement_type} task: {user_task}"
|
354 |
response = multimodal_prompt(filepath, text_prompt) # Use the downloaded filepath
|
355 |
+
st.markdown(f"**Response:** {response}")
|
356 |
+
|
357 |
+
if st.session_state.uploaded_pdf_path:
|
358 |
+
display_download_button(st.session_state.uploaded_pdf_path, "Generative_AI_and_Education.pdf")
|
procurement.png
ADDED
![]() |
requirements.txt
CHANGED
@@ -2,4 +2,5 @@ streamlit
|
|
2 |
requests
|
3 |
pdfplumber
|
4 |
huggingface_hub
|
5 |
-
google-generativeai
|
|
|
|
2 |
requests
|
3 |
pdfplumber
|
4 |
huggingface_hub
|
5 |
+
google-generativeai
|
6 |
+
Pillow
|