File size: 703 Bytes
9efba8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
from langchain_core.prompts import ChatPromptTemplate
from langchain.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder
import yaml

current_dir = os.path.dirname(os.path.abspath(__file__))
with open(f"{current_dir}/rag_template.yaml", "r") as yaml_file:
    templates = yaml.safe_load(yaml_file)

# RAG Agent
sys_msg_template: str = templates["sys_msg"]
human_msg_template: str = templates["human_msg"]
rag_agent_prompt = ChatPromptTemplate.from_messages([
    SystemMessagePromptTemplate.from_template(sys_msg_template),
    HumanMessagePromptTemplate.from_template(human_msg_template),
    MessagesPlaceholder(variable_name = "agent_scratchpad")
])