Created
November 4, 2024 04:40
-
-
Save jgoodie/f2ada087d3e4c784bc1253e8490b2906 to your computer and use it in GitHub Desktop.
Function to summarize Tavily search results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def TavilySummary(state): | |
# Get state | |
context = state["context"] | |
question = state["question"] | |
# Template | |
answer_template = """ | |
You are a competitive research analytist helping a team of product managers conduct competitive market research. | |
Answer the research question: | |
{question} | |
using this context: | |
{context} | |
""" | |
answer_instructions = answer_template.format(question=question, context=context) | |
# Answer | |
answer = llm.invoke([SystemMessage(content=answer_instructions)]+[HumanMessage(content=f"Answer the research question.")]) | |
# Append it to state | |
return {"answer": answer} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment