Spaces:
Sleeping
Sleeping
Update search_queries_generator.py
Browse files- search_queries_generator.py +31 -31
search_queries_generator.py
CHANGED
|
@@ -1,32 +1,32 @@
|
|
| 1 |
-
from langchain_core.prompts import PromptTemplate
|
| 2 |
-
|
| 3 |
-
queries_prompt_template = PromptTemplate.from_template("""
|
| 4 |
-
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.
|
| 5 |
-
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.
|
| 6 |
-
|
| 7 |
-
# The queries should cover:
|
| 8 |
-
- Latest trends and emerging topics
|
| 9 |
-
- Recent news and noteworthy events
|
| 10 |
-
- New or updated laws and regulations
|
| 11 |
-
- Market insights and innovations
|
| 12 |
-
- Expert opinions and industry reports
|
| 13 |
-
|
| 14 |
-
# Generate at least 5 specific, diverse, and concise search queries that capture different aspects of the Topic.
|
| 15 |
-
# Use variations in phrasing to ensure comprehensive search results.
|
| 16 |
-
# Make sure the queries are unique So that we get diverse search results.
|
| 17 |
-
# Don't include any irrelevant information in the queries like Markdown, Newlines etc. Only give the search queries.
|
| 18 |
-
|
| 19 |
-
Topic = {topic}
|
| 20 |
-
""")
|
| 21 |
-
|
| 22 |
-
# Generate Queries
|
| 23 |
-
from datetime import date
|
| 24 |
-
current_year = date.today().strftime("%Y")
|
| 25 |
-
|
| 26 |
-
def generate_queries(llm, state):
|
| 27 |
-
topic = state["topic"][0].content
|
| 28 |
-
prompt = queries_prompt_template.invoke({"topic": topic, "year": current_year})
|
| 29 |
-
response = llm.invoke(prompt)
|
| 30 |
-
content = response.content
|
| 31 |
-
response_list = [item.strip('"') for item in content.split('\n')]
|
| 32 |
return {"search_queries": response_list}
|
|
|
|
| 1 |
+
from langchain_core.prompts import PromptTemplate
|
| 2 |
+
|
| 3 |
+
queries_prompt_template = PromptTemplate.from_template("""
|
| 4 |
+
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.
|
| 5 |
+
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.
|
| 6 |
+
|
| 7 |
+
# The queries should cover:
|
| 8 |
+
- Latest trends and emerging topics
|
| 9 |
+
- Recent news and noteworthy events
|
| 10 |
+
- New or updated laws and regulations
|
| 11 |
+
- Market insights and innovations
|
| 12 |
+
- Expert opinions and industry reports
|
| 13 |
+
|
| 14 |
+
# Generate at least 5 specific, diverse, and concise search queries that capture different aspects of the Topic.
|
| 15 |
+
# Use variations in phrasing to ensure comprehensive search results.
|
| 16 |
+
# Make sure the queries are unique So that we get diverse search results.
|
| 17 |
+
# Don't include any irrelevant information in the queries like Markdown, Newlines etc. Only give the search queries.
|
| 18 |
+
|
| 19 |
+
Topic = {topic}
|
| 20 |
+
""")
|
| 21 |
+
|
| 22 |
+
# Generate Queries
|
| 23 |
+
from datetime import date
|
| 24 |
+
current_year = date.today().strftime("%Y")
|
| 25 |
+
|
| 26 |
+
def generate_queries(llm, state):
|
| 27 |
+
topic = state["topic"][0].content
|
| 28 |
+
prompt = queries_prompt_template.invoke({"topic": topic, "year": current_year})
|
| 29 |
+
response = llm.invoke(prompt)
|
| 30 |
+
content = response.content
|
| 31 |
+
response_list = [item.strip('"') for item in content.split('\n')]
|
| 32 |
return {"search_queries": response_list}
|