From 3e27c9c824d7acf2b69c7b27aa58aa5373949158 Mon Sep 17 00:00:00 2001 From: Sri Charan Thoutam Date: Tue, 14 Jan 2025 20:28:18 +0530 Subject: [PATCH] Updated streamlit UI --- rag_tutorials/rag_chain/README.md | 18 +++++------------- rag_tutorials/rag_chain/app.py | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/rag_tutorials/rag_chain/README.md b/rag_tutorials/rag_chain/README.md index 4a0f1ca..c253d73 100644 --- a/rag_tutorials/rag_chain/README.md +++ b/rag_tutorials/rag_chain/README.md @@ -3,8 +3,8 @@ ## Overview PharmaQuery is an advanced Pharmaceutical Insight Retrieval System designed to help users gain meaningful insights from research papers and documents in the pharmaceutical domain. -## PharmaQuery Architecture -![PharmaQuery-Architecture](https://github.com/user-attachments/assets/c8a2cff7-f004-415c-8b1e-5387999680b4) +## Demo +https://github.com/user-attachments/assets/c12ee305-86fe-4f71-9219-57c7f438f291 ## Features - **Natural Language Querying**: Ask complex questions about the pharmaceutical industry and get concise, accurate answers. @@ -28,21 +28,13 @@ PharmaQuery is an advanced Pharmaceutical Insight Retrieval System designed to h pip install -r requirements.txt ``` -2. **Set Up Environment Variables**: - Create a `.env` file in the project root directory with the following variables: - - ```bash - GOOGLE_API_KEY="your_google_gemini_api_key" - ``` - - `Note:` Replace `your_google_gemini_api_key` with actual key. - -3. **Run the Application**: +2. **Run the Application**: ```bash streamlit run app.py ``` -4. **Use the Application**: +3. **Use the Application**: + - Paste your Google API Key in the sidebar. - Enter your query in the main interface. - Optionally, upload research papers in the sidebar to enhance the database. diff --git a/rag_tutorials/rag_chain/app.py b/rag_tutorials/rag_chain/app.py index 1c1c962..2a16b73 100644 --- a/rag_tutorials/rag_chain/app.py +++ b/rag_tutorials/rag_chain/app.py @@ -84,6 +84,7 @@ def run_rag_chain(query): # Initialize a Generator (i.e. Chat Model) chat_model = ChatGoogleGenerativeAI( model="gemini-1.5-pro", + api_key=st.session_state.get("gemini_api_key"), temperature=1 ) @@ -117,8 +118,20 @@ def main(): st.write(result) with st.sidebar: - st.title("Upload your research documents (Optional) :memo:") - pdf_docs = st.file_uploader("Enhance your query by uploading PDF files related to Pharmaceutical Sciences.", + st.title("API Keys") + gemini_api_key = st.text_input("Enter your Gemini API key:", type="password") + + if st.button("Enter"): + if gemini_api_key: + st.session_state.gemini_api_key = gemini_api_key + st.success("API key saved!") + + else: + st.warning("Please enter your Gemini API key to proceed.") + + with st.sidebar: + st.markdown("---") + pdf_docs = st.file_uploader("Upload your research documents related to Pharmaceutical Sciences (Optional) :memo:", type=["pdf"], accept_multiple_files=True )