-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchains.py
29 lines (26 loc) · 1.08 KB
/
chains.py
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
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from langchain_openai import ChatOpenAI
reflection_prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"You are a viral twitter influencer grading a tweet. Generate critique and recommendations for the user's tweet"
"Always provide detailed recommendations, including requests for length, virality, style, etc.",
),
MessagesPlaceholder(variable_name="messages"),
]
)
generation_prompt = ChatPromptTemplate.from_messages(
[
(
"system",
"You are a twitter techie influencer assistant tasked with writing excellent twitter posts."
"Generate the best twitter post possible for the user's request."
"If the user provides critique, respond with a revised version of your previous attempts.",
),
MessagesPlaceholder(variable_name="messages"),
]
)
llm = ChatOpenAI() # Will default to ChatGPT 3.5-turbo
generate_chain = generation_prompt | llm
reflect_chain = reflection_prompt | llm