Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,3 @@
|
|
| 1 |
-
pip install langchain-groq
|
| 2 |
-
!pip install langchain-groq
|
| 3 |
-
pip show langchain-groq
|
| 4 |
-
# For Python 3.x
|
| 5 |
-
pip3 install langchain-groq
|
| 6 |
-
pip install --user langchain-groq
|
| 7 |
-
sudo pip install langchain-groq
|
| 8 |
-
from langchain_groq import ChatGroq
|
| 9 |
import os
|
| 10 |
import logging
|
| 11 |
from dotenv import load_dotenv
|
|
@@ -16,34 +8,8 @@ from langchain_cohere import CohereEmbeddings
|
|
| 16 |
from langchain.vectorstores import FAISS
|
| 17 |
from langchain.memory import ConversationBufferMemory
|
| 18 |
from langchain.chains import ConversationalRetrievalChain
|
| 19 |
-
from langchain_groq import ChatGroq
|
| 20 |
-
from langchain.memory import ConversationBufferMemory
|
| 21 |
-
from langchain.chains import ConversationalRetrievalChain
|
| 22 |
|
| 23 |
-
def get_conversation_chain(vectorstore):
|
| 24 |
-
try:
|
| 25 |
-
# Initialize Groq's Chat model
|
| 26 |
-
llm = ChatGroq(
|
| 27 |
-
model="llama2-70b-4096", # You can use other models like "mixtral-8x7b-32768"
|
| 28 |
-
temperature=0.5,
|
| 29 |
-
groq_api_key=groq_api_key
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
# Set up memory for the conversation
|
| 33 |
-
memory = ConversationBufferMemory(memory_key='chat_history', return_messages=True)
|
| 34 |
-
|
| 35 |
-
# Create the conversational retrieval chain
|
| 36 |
-
conversation_chain = ConversationalRetrievalChain.from_llm(
|
| 37 |
-
llm=llm,
|
| 38 |
-
retriever=vectorstore.as_retriever(),
|
| 39 |
-
memory=memory
|
| 40 |
-
)
|
| 41 |
-
|
| 42 |
-
logging.info("Conversation chain created successfully.")
|
| 43 |
-
return conversation_chain
|
| 44 |
-
except Exception as e:
|
| 45 |
-
logging.error(f"Error creating conversation chain: {e}")
|
| 46 |
-
st.error("An error occurred while setting up the conversation chain.")
|
| 47 |
# Load environment variables
|
| 48 |
load_dotenv()
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import logging
|
| 3 |
from dotenv import load_dotenv
|
|
|
|
| 8 |
from langchain.vectorstores import FAISS
|
| 9 |
from langchain.memory import ConversationBufferMemory
|
| 10 |
from langchain.chains import ConversationalRetrievalChain
|
| 11 |
+
from langchain_groq import ChatGroq # Ensure this is installed
|
|
|
|
|
|
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
# Load environment variables
|
| 14 |
load_dotenv()
|
| 15 |
|