mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-08 06:23:20 +00:00
FEATURE gpt researcher template (#13062)
Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
31
templates/research-assistant/research_assistant/writer.py
Normal file
31
templates/research-assistant/research_assistant/writer.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from langchain.chat_models import ChatOpenAI
|
||||
from langchain.prompts import ChatPromptTemplate
|
||||
from langchain.schema.output_parser import StrOutputParser
|
||||
|
||||
REPORT_TEMPLATE = """Information:
|
||||
--------
|
||||
{research_summary}
|
||||
--------
|
||||
|
||||
Using the above information, answer the following question or topic: "{question}" in a detailed report -- \
|
||||
The report should focus on the answer to the question, should be well structured, informative, \
|
||||
in depth, with facts and numbers if available and a minimum of 1,200 words.
|
||||
|
||||
You should strive to write the report as long as you can using all relevant and necessary information provided.
|
||||
You must write the report with markdown syntax.
|
||||
You MUST determine your own concrete and valid opinion based on the given information. Do NOT deter to general and meaningless conclusions.
|
||||
Write all used source urls at the end of the report, and make sure to not add duplicated sources, but only one reference for each.
|
||||
You must write the report in apa format.
|
||||
Please do your best, this is very important to my career.""" # noqa: E501
|
||||
|
||||
model = ChatOpenAI(temperature=0)
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
[
|
||||
(
|
||||
"system",
|
||||
"You are an AI critical thinker research assistant. Your sole purpose is to write well written, critically acclaimed, objective and structured reports on given text.", # noqa: E501
|
||||
),
|
||||
("user", REPORT_TEMPLATE),
|
||||
]
|
||||
)
|
||||
chain = prompt | model | StrOutputParser()
|
Reference in New Issue
Block a user