langchain
langchain copied to clipboard
community: add AskNews retriever and AskNews tool
We add a tool and retriever for the AskNews platform with example notebooks.
The retriever can be invoked with:
from langchain_community.retrievers import AskNewsRetriever
retriever = AskNewsRetriever(k=3)
retriever.invoke("impact of fed policy on the tech sector")
To retrieve 3 documents in then news related to fed policy impacts on the tech sector. The included notebook also includes deeper details about controlling filters such as category and time, as well as including the retriever in a chain.
The tool is quite interesting, as it allows the agent to decide how to obtain the news by forming a query and deciding how far back in time to look for the news:
from langchain_community.tools.asknews import AskNewsSearch
from langchain import hub
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain_openai import ChatOpenAI
tool = AskNewsSearch()
instructions = """You are an assistant."""
base_prompt = hub.pull("langchain-ai/openai-functions-template")
prompt = base_prompt.partial(instructions=instructions)
llm = ChatOpenAI(temperature=0)
asknews_tool = AskNewsSearch()
tools = [asknews_tool]
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(
agent=agent,
tools=tools,
verbose=True,
)
agent_executor.invoke({"input": "How is the tech sector being affected by fed policy?"})
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
langchain | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | May 17, 2024 7:18pm |
Hey @efriis , I am unable to inspect the failed Vercel deployment. When I click "Inspect", it brings me to a 404 error on Vercel.
Do you have any idea why that piece might be failing?
Hey @efriis , I am unable to inspect the failed Vercel deployment. When I click "Inspect", it brings me to a 404 error on Vercel.
Do you have any idea why that piece might be failing?
@hwchase17 @baskaryan @efriis @eyurtsev can we have a feedback on this? thanks
Hey @hwchase17 @baskaryan @efriis @eyurtsev, this PR is ready for review.