File size: 914 Bytes
224ff63
a93b719
224ff63
 
 
a93b719
224ff63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from langchain_openai import ChatOpenAI
from agent.datastructures import parser,ResponseSchema


model = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=0)
model.with_structured_output(ResponseSchema)

from langchain.prompts import ChatPromptTemplate,PromptTemplate, MessagesPlaceholder,SystemMessagePromptTemplate

prompt = PromptTemplate(
    template="""

        {format_instructions} 
        Only provide a single JSON blob, beginning with '{{' and ending with '}}'
        /n {input} /n
        
    """,
    input_variables=["input"],
    partial_variables={"format_instructions": parser.get_format_instructions()},
    

)

prompt = ChatPromptTemplate.from_messages(
    [
        ("system", "You will be given the chat so far, you should render the final answer as a JSON object"),        
        MessagesPlaceholder(variable_name="conversation"),
    ]
)


json_parse_chain = prompt | model | parser