Akilesh commited on
Commit
c6d2ec1
1 Parent(s): d5fdaa0

system prompt

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import logging
3
  from dotenv import load_dotenv
@@ -22,11 +23,16 @@ I am Akilesh, your assistant for question-answering tasks! I'll respond as if yo
22
  """
23
 
24
  # Create a PromptTemplate with the custom system prompt
25
- prompt_template = PromptTemplate(
26
- template=f"{
27
- CUSTOM_SYSTEM_PROMPT}\n\nContext: {{context}}\n\nQuestion: {{question}}\n\nAnswer:",
28
- input_variables=["context", "question"]
29
- )
 
 
 
 
 
30
 
31
 
32
  # Initialize the ChatOpenAI model
 
1
+ from langchain.prompts import ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate
2
  import os
3
  import logging
4
  from dotenv import load_dotenv
 
23
  """
24
 
25
  # Create a PromptTemplate with the custom system prompt
26
+
27
+ system_template = SystemMessagePromptTemplate.from_template(
28
+ CUSTOM_SYSTEM_PROMPT)
29
+ human_template = HumanMessagePromptTemplate.from_template(
30
+ "Context: {context}\n\nQuestion: {question}")
31
+
32
+ prompt_template = ChatPromptTemplate.from_messages([
33
+ system_template,
34
+ human_template
35
+ ])
36
 
37
 
38
  # Initialize the ChatOpenAI model