Langchain news tools extract old news articles even specify a date range. #27440
Replies: 1 comment 2 replies
-
Hey @jiagaoxiang! I'm here to help you out with any bugs, questions, or contributions you might have. Let's tackle this issue together! To address the issue of retrieving old news articles despite specifying a date range, you can adjust the configuration settings in LangChain to improve the accuracy of date filtering. For instance, if you are using the AskNews integration, you can set the Here's an example of how you can configure these parameters: from datetime import datetime, timedelta
start = (datetime.now() - timedelta(days=7)).timestamp()
end = datetime.now().timestamp()
retriever = AskNewsRetriever(
k=3,
categories=["Business", "Technology"],
start_timestamp=int(start), # defaults to 48 hours ago
end_timestamp=int(end), # defaults to now
method="kw", # defaults to "nl", natural language, can also be "kw" for keyword search
offset=10, # allows you to paginate results
)
retriever.invoke("Google") Additionally, if you are using the Exa Search integration, you can use the @tool
def search_and_contents(
query: str,
start_published_date: str = None,
end_published_date: str = None,
):
return exa.search_and_contents(
query,
start_published_date=start_published_date,
end_published_date=end_published_date,
text=True,
highlights=True,
) These configurations should help improve the relevance and accuracy of the retrieved articles [1][2]. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using duckduckgo and yahoo finance news tools to extract news articles about something, for example, news articles about Google after 10/13/2024. But the returned articles are very old articles like published on 6/18/2024, but the date field shows very recent date like 10/14/2024. What's the problem here? How to fix? It seems these tools don't have access to the most recent results.
Beta Was this translation helpful? Give feedback.
All reactions