Update app.py
Browse files
app.py
CHANGED
@@ -17,8 +17,8 @@ from dotenv import load_dotenv
|
|
17 |
load_dotenv()
|
18 |
|
19 |
## Load the Groq API key
|
20 |
-
|
21 |
-
|
22 |
|
23 |
st.title("Ask your questions from pdf(s) or website")
|
24 |
option = None
|
@@ -34,9 +34,9 @@ def get_pdf_processed(pdf_docs):
|
|
34 |
for page in pdf_reader.pages:
|
35 |
text += page.extract_text()
|
36 |
return text
|
37 |
-
|
38 |
def llm_model():
|
39 |
-
llm = ChatGroq(model="mixtral-8x7b-32768")
|
40 |
prompt = ChatPromptTemplate.from_template(
|
41 |
"""
|
42 |
Answer the question based on the provided context only.
|
@@ -59,8 +59,8 @@ def llm_model():
|
|
59 |
response = retrieval_chain.invoke({"input":prompt})
|
60 |
print("Response time :", time.process_time()-start)
|
61 |
st.write(response['answer'])
|
62 |
-
|
63 |
-
st.session_state.embeddings =GoogleGenerativeAIEmbeddings(model = 'models/embedding-001')
|
64 |
st.session_state.text_splitter = RecursiveCharacterTextSplitter(chunk_size =1000, chunk_overlap= 200)
|
65 |
|
66 |
if option:
|
|
|
17 |
load_dotenv()
|
18 |
|
19 |
## Load the Groq API key
|
20 |
+
groq_api_key = os.environ['GROQ_API_KEY']
|
21 |
+
google_api_key = os.environ['GOOGLE_API_KEY']
|
22 |
|
23 |
st.title("Ask your questions from pdf(s) or website")
|
24 |
option = None
|
|
|
34 |
for page in pdf_reader.pages:
|
35 |
text += page.extract_text()
|
36 |
return text
|
37 |
+
|
38 |
def llm_model():
|
39 |
+
llm = ChatGroq(model="mixtral-8x7b-32768",groq_api_key=groq_api_key)
|
40 |
prompt = ChatPromptTemplate.from_template(
|
41 |
"""
|
42 |
Answer the question based on the provided context only.
|
|
|
59 |
response = retrieval_chain.invoke({"input":prompt})
|
60 |
print("Response time :", time.process_time()-start)
|
61 |
st.write(response['answer'])
|
62 |
+
|
63 |
+
st.session_state.embeddings =GoogleGenerativeAIEmbeddings(model = 'models/embedding-001',google_api_key=google_api_key)
|
64 |
st.session_state.text_splitter = RecursiveCharacterTextSplitter(chunk_size =1000, chunk_overlap= 200)
|
65 |
|
66 |
if option:
|