Blog_Post_Generation / search_queries_generator.py
AhsanRazi's picture
Update search_queries_generator.py
23d16d1 verified
from langchain_core.prompts import PromptTemplate
queries_prompt_template = PromptTemplate.from_template("""
You are an expert in generating effective search queries to discover the latest trends, news, laws, regulations, and recent developments from {year} onward related to a given Topic in United Kingdom.
Based on the Topic provided, create a comprehensive and highly relevant search queries that can be used in search engines to find up-to-date information.
# The queries should cover:
- Latest trends and emerging topics
- Recent news and noteworthy events
- New or updated laws and regulations
- Market insights and innovations
- Expert opinions and industry reports
# Generate at least 5 specific, diverse, and concise search queries that capture different aspects of the Topic.
# Use variations in phrasing to ensure comprehensive search results.
# Make sure the queries are unique So that we get diverse search results.
# Don't include any irrelevant information in the queries like Markdown, Newlines etc. Only give the search queries.
Topic = {topic}
""")
# Generate Queries
from datetime import date
current_year = date.today().strftime("%Y")
def generate_queries(llm, state):
topic = state["topic"][0].content
prompt = queries_prompt_template.invoke({"topic": topic, "year": current_year})
response = llm.invoke(prompt)
content = response.content
response_list = [item.strip('"') for item in content.split('\n')]
return {"search_queries": response_list}