AskNews Logo Dark

LangChain support

We have support for LangChain Retrievers and Tools. Notebooks are available for both on LangChain documentation at:

Details can also be found below for each of these LangChain integrations. In summary, the Retriever is good for having direct control over your AskNews RAG chain. The Tool, on the other hand, is more adaptive and allows your LLM agent to choose whether or not it even needs AskNews, and if it does, it can intelligently choose the query parameters. That includes knowing if it needs to search the historical news archive and how far back to look.

To get started, install LangChain and AskNews:

pip install langchain-community asknews

Retriever

The retriever gives you direct control over AskNews similar to how you might use the AskNews SDK. However, the retriever works well in LLM chains out of the box.


Chain output

"According to the information provided in the second news article, the impact of Federal Reserve policy on the technology sector has been negative. The article mentions that due to expectations that interest rates will remain high for a longer period, the US stock market has experienced a significant decline. This rise in interest rates has particularly affected the technology sector, with companies such as Intel and Microsoft experiencing declines. High interest rates can lead to increased borrowing costs for businesses, which can dampen investment and spending. In the technology sector, where companies often rely on borrowing to fund research and development and other growth initiatives, higher rates can be especially challenging.\n\nTherefore, the Federal Reserve's policy of maintaining high interest rates has had a detrimental effect on tech stocks, contributing to a decrease in their market valuations."


Tool

The tool is a more adaptive approach to using AskNews. This allows your LLM agent to choose whether or not it even needs AskNews, and if it does, it can intelligently choose the query parameters. Most interestingly, your LLM agent will even decide if you need historical news or not, and how far back in the archive to look.


Agent execution

{'input': 'How is the tech sector being affected by fed policy?', 'output': 'The tech sector is being affected by federal policy in various ways, particularly in relation to artificial intelligence (AI) regulation and investment. Here are some recent news articles related to the tech sector and federal policy:\n\n1. The US Senate has released a bipartisan AI policy roadmap, addressing areas of consensus and disagreement on AI use and development. The roadmap includes recommendations for intellectual property reforms, funding for AI research, sector-specific rules, and transparency requirements. It also emphasizes the need for increased funding for AI innovation and investments in national defense. [Source: The National Law Review]\n\n2. A bipartisan group of US senators, led by Senate Majority Leader Chuck Schumer, has proposed allocating at least $32 billion over the next three years to develop AI and establish safeguards around it. The proposal aims to regulate and promote AI development to maintain US competitiveness and improve quality of life. [Source: Cointelegraph]\n\n3. The US administration is planning to restrict the export of advanced AI models to prevent China and Russia from accessing the technology. This move is part of efforts to protect national security and prevent the misuse of AI by foreign powers. [Source: O Cafezinho]\n\n4. The US and China have discussed the risks of AI technologies, with the US taking the lead in the AI arms race. The US has proposed a $32 billion increase in federal spending on AI to maintain its lead, despite concerns about stifling innovation. [Source: AOL]\n\nThese articles highlight the ongoing discussions and actions related to AI regulation, investment, and export restrictions that are impacting the tech sector in response to federal policy decisions.'}


    We use cookies

    We use cookies to ensure you get the best experience on our website. Some of these cookies are provided by third parties. You are free to decide which categories you would like to permit and can withdraw this consent at any time (via cookie preferences link on the footer).

    You can either accept all cookies, reject all but the necessary cookies or click the "Preferences" button to decide which cookie categories you would like to enable or disable.
    Learn more on our privacy policy page.