Azmathussainthebo commited on
Commit
c844c11
·
verified ·
1 Parent(s): 68c2078

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -38
app.py CHANGED
@@ -1,42 +1,4 @@
1
- pip install langchain_groq
2
- GROQ_API_KEY=your_groq_api_key_here
3
- from dotenv import load_dotenv
4
  import os
5
-
6
- # Load environment variables
7
- load_dotenv()
8
-
9
- # Access the Groq API key
10
- groq_api_key = os.getenv("GROQ_API_KEY")
11
- from langchain_groq import ChatGroq
12
- from langchain.memory import ConversationBufferMemory
13
- from langchain.chains import ConversationalRetrievalChain
14
-
15
- def get_conversation_chain(vectorstore):
16
- try:
17
- # Initialize Groq's Chat model
18
- llm = ChatGroq(
19
- model="llama2-70b-4096", # You can use other models like "mixtral-8x7b-32768"
20
- temperature=0.5,
21
- groq_api_key=groq_api_key
22
- )
23
-
24
- # Set up memory for the conversation
25
- memory = ConversationBufferMemory(memory_key='chat_history', return_messages=True)
26
-
27
- # Create the conversational retrieval chain
28
- conversation_chain = ConversationalRetrievalChain.from_llm(
29
- llm=llm,
30
- retriever=vectorstore.as_retriever(),
31
- memory=memory
32
- )
33
-
34
- logging.info("Conversation chain created successfully.")
35
- return conversation_chain
36
- except Exception as e:
37
- logging.error(f"Error creating conversation chain: {e}")
38
- st.error("An error occurred while setting up the conversation chain.")
39
- import os
40
  import logging
41
  from dotenv import load_dotenv
42
  import streamlit as st
 
 
 
 
1
  import os
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  import logging
3
  from dotenv import load_dotenv
4
  import streamlit as st