Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from langchain_groq import ChatGroq
|
| 3 |
from langchain.document_loaders import PyPDFLoader
|
|
@@ -7,6 +8,14 @@ from langchain.vectorstores import FAISS
|
|
| 7 |
from langchain.chains import RetrievalQA
|
| 8 |
|
| 9 |
def main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
st.title("PDF Chat with Groq LLM")
|
| 11 |
|
| 12 |
# File uploader
|
|
@@ -36,10 +45,11 @@ def main():
|
|
| 36 |
# Create vector store
|
| 37 |
vectorstore = FAISS.from_documents(texts, embeddings)
|
| 38 |
|
| 39 |
-
# Initialize Groq LLM
|
| 40 |
llm = ChatGroq(
|
| 41 |
temperature=0.7,
|
| 42 |
-
model_name='llama3-70b-8192'
|
|
|
|
| 43 |
)
|
| 44 |
|
| 45 |
# Create QA chain
|
|
|
|
| 1 |
+
import os
|
| 2 |
import streamlit as st
|
| 3 |
from langchain_groq import ChatGroq
|
| 4 |
from langchain.document_loaders import PyPDFLoader
|
|
|
|
| 8 |
from langchain.chains import RetrievalQA
|
| 9 |
|
| 10 |
def main():
|
| 11 |
+
# Retrieve Groq API key from environment variable
|
| 12 |
+
groq_api_key = os.getenv("GROQ_API_KEY")
|
| 13 |
+
|
| 14 |
+
# Check if API key is available
|
| 15 |
+
if not groq_api_key:
|
| 16 |
+
st.error("GROQ_API_KEY not found. Please set the environment variable.")
|
| 17 |
+
return
|
| 18 |
+
|
| 19 |
st.title("PDF Chat with Groq LLM")
|
| 20 |
|
| 21 |
# File uploader
|
|
|
|
| 45 |
# Create vector store
|
| 46 |
vectorstore = FAISS.from_documents(texts, embeddings)
|
| 47 |
|
| 48 |
+
# Initialize Groq LLM with API key
|
| 49 |
llm = ChatGroq(
|
| 50 |
temperature=0.7,
|
| 51 |
+
model_name='llama3-70b-8192',
|
| 52 |
+
groq_api_key=groq_api_key # Pass the API key explicitly
|
| 53 |
)
|
| 54 |
|
| 55 |
# Create QA chain
|