-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchains.py
More file actions
31 lines (27 loc) · 1.11 KB
/
chains.py
File metadata and controls
31 lines (27 loc) · 1.11 KB
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
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."
" Maximum characters in a twitter post must be 280."
" If the user provides critique, respond with a revised version of your previous attempts.",
),
MessagesPlaceholder(variable_name="messages"),
]
)
llm = ChatOpenAI()
generate_chain = generation_prompt | llm
reflect_chain = reflection_prompt | llm