You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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>
4 months ago
..
audio community[minor]: add hugging face text-to-speech inference API (#18880) 6 months ago
eden_ai community[patch]: upgrade to recent version of mypy (#21616) 4 months ago
file_management infra: Fix test filesystem paths incompatible with windows (#14388) 9 months ago
gmail community: add args_schema to GmailSendMessage (#14973) 9 months ago
openai_dalle_image_generation community[patch]: add Integration for OpenAI image gen with v1 sdk (#17771) 6 months ago
openapi community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 10 months ago
powerbi community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 10 months ago
requests Add dangerous parameter to requests tool (#18697) 7 months ago
shell community[patch]: Basic Logging and Human input to ShellTool (#15932) 8 months ago
__init__.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 10 months ago
test_exported.py community: Vectara summarization (#14970) 9 months ago
test_imports.py community[minor]: add AskNews retriever and AskNews tool (#21581) 4 months ago
test_json.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 10 months ago
test_public_api.py community[minor]: add AskNews retriever and AskNews tool (#21581) 4 months ago
test_signatures.py community[major], core[patch], langchain[patch], experimental[patch]: Create langchain-community (#14463) 10 months ago
test_you.py community[patch]: upgrade to recent version of mypy (#21616) 4 months ago
test_zapier.py community[patch]: upgrade to recent version of mypy (#21616) 4 months ago