shah1zil commited on
Commit
99f74aa
·
verified ·
1 Parent(s): 3eda2a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -62
app.py CHANGED
@@ -70,65 +70,3 @@ if uploaded_file:
70
  except Exception as e:
71
  st.error(f"An error occurred: {e}")
72
 
73
-
74
- # # Install dependencies
75
- # # pip install streamlit PyPDF2 groq
76
-
77
- # import streamlit as st
78
- # from PyPDF2 import PdfReader
79
- # import os
80
- # from groq import Groq
81
-
82
- # # Set the API key
83
- # os.environ["GROQ_API_KEY"] = "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"
84
-
85
- # # Initialize Groq client
86
- # client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
87
-
88
- # # Streamlit App
89
- # st.title("Pakistani Constitution Q&A App")
90
- # st.write("Upload the PDF of the Pakistani Constitution and ask questions about it.")
91
-
92
- # # Upload PDF
93
- # uploaded_file = st.file_uploader("Upload PDF", type="pdf")
94
- # if uploaded_file:
95
- # # Extract text from the PDF
96
- # pdf_reader = PdfReader(uploaded_file)
97
- # constitution_text = ""
98
- # for page in pdf_reader.pages:
99
- # constitution_text += page.extract_text()
100
-
101
- # st.success("PDF Uploaded and Processed Successfully!")
102
-
103
- # # Split text into chunks to handle token limits
104
- # chunk_size = 5000 # Number of characters per chunk
105
- # chunks = [constitution_text[i:i+chunk_size] for i in range(0, len(constitution_text), chunk_size)]
106
-
107
- # # Let user select a chunk to ask questions about
108
- # st.write("The document is too large, so it's split into smaller parts. Select one to ask questions:")
109
- # selected_chunk = st.selectbox("Select a part of the document:", range(len(chunks)))
110
- # current_chunk = chunks[selected_chunk]
111
-
112
- # st.write("You selected part:", selected_chunk + 1)
113
- # st.text_area("Selected Text Segment", current_chunk, height=200)
114
-
115
- # # Ask a question about the selected chunk
116
- # user_question = st.text_input("Ask a question about the selected part:")
117
-
118
- # if user_question:
119
- # st.write("Processing your question...")
120
-
121
- # # Send the selected chunk and question to Groq API
122
- # try:
123
- # chat_completion = client.chat.completions.create(
124
- # messages=[
125
- # {"role": "user", "content": f"Context: {current_chunk}\nQuestion: {user_question}"}
126
- # ],
127
- # model="llama3-8b-8192",
128
- # )
129
- # # Display the answer
130
- # answer = chat_completion.choices[0].message.content
131
- # st.write("### Answer:")
132
- # st.write(answer)
133
- # except Exception as e:
134
- # st.error(f"An error occurred: {e}")
 
70
  except Exception as e:
71
  st.error(f"An error occurred: {e}")
72