Pavan178 commited on
Commit
d43bb1b
·
verified ·
1 Parent(s): a526ade

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -8,6 +8,19 @@ from langchain.chains import ConversationalRetrievalChain
8
  from langchain.chat_models import ChatOpenAI
9
  from langchain.memory import ConversationBufferMemory
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  openai_api_key = os.environ.get("OPENAI_API_KEY")
12
 
13
  class AdvancedPdfChatbot:
@@ -15,7 +28,7 @@ class AdvancedPdfChatbot:
15
  os.environ["OPENAI_API_KEY"] = openai_api_key
16
  self.embeddings = OpenAIEmbeddings()
17
  self.text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
18
- self.llm = ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo")
19
  self.memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
20
  self.qa_chain = None
21
 
 
8
  from langchain.chat_models import ChatOpenAI
9
  from langchain.memory import ConversationBufferMemory
10
 
11
+ from langchain.prompts import PromptTemplate
12
+ template= """
13
+ You are a study partner assistant,students give you pdfs,web page links and youtube video links,
14
+ and you help them to answer their questions.
15
+
16
+ Answer the question based on the most recent provided ressources only.
17
+ Give the most relevant answer.
18
+ {context}
19
+ Question: {question}
20
+ Answer:
21
+ """
22
+
23
+
24
  openai_api_key = os.environ.get("OPENAI_API_KEY")
25
 
26
  class AdvancedPdfChatbot:
 
28
  os.environ["OPENAI_API_KEY"] = openai_api_key
29
  self.embeddings = OpenAIEmbeddings()
30
  self.text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=200)
31
+ self.llm = OpenAIChat(temperature=0,model_name='gpt-3.5-turbo',prompt = PromptTemplate(template=template)
32
  self.memory = ConversationBufferMemory(memory_key="chat_history", return_messages=True)
33
  self.qa_chain = None
34