langchain/libs/community/tests/unit_tests/tools
Robert Caulk 54adcd9e82
community[minor]: add AskNews retriever and AskNews tool (#21581)
We add a tool and retriever for the [AskNews](https://asknews.app)
platform with example notebooks.

The retriever can be invoked with:

```py
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:

```py
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?"})
```

---------

Co-authored-by: Emre <e@emre.pm>
2024-05-20 18:23:06 -07:00
..
audio community[minor]: add hugging face text-to-speech inference API (#18880) 2024-03-29 15:02:29 +00:00
eden_ai community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
file_management
gmail
openai_dalle_image_generation community[patch]: add Integration for OpenAI image gen with v1 sdk (#17771) 2024-03-29 00:23:14 +00:00
openapi
powerbi
requests Add dangerous parameter to requests tool (#18697) 2024-03-07 15:10:56 -05:00
shell
__init__.py
test_exported.py
test_imports.py community[minor]: add AskNews retriever and AskNews tool (#21581) 2024-05-20 18:23:06 -07:00
test_json.py
test_public_api.py community[minor]: add AskNews retriever and AskNews tool (#21581) 2024-05-20 18:23:06 -07:00
test_signatures.py
test_you.py community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
test_zapier.py community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00