langchain/libs/community/langchain_community
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
..
adapters community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
agent_toolkits langchain[patch],community[patch]: Move unit tests that depend on community to community (#21685) 2024-05-16 17:24:27 -04:00
callbacks community[patch]: Update UpTrain Callback Handler to support the new UpTrain evaluation schema (#21656) 2024-05-20 17:06:00 -07:00
chains langchain[minor]: Add PebbloRetrievalQA chain with Identity & Semantic Enforcement support (#20641) 2024-05-15 13:14:52 +00:00
chat_loaders community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
chat_message_histories community[patch]: chat message history mypy fixes #17048 (#20114) 2024-05-06 22:17:45 +00:00
chat_models community[patch]: standardized sparkllm init args (#21633) 2024-05-20 17:11:36 -07:00
cross_encoders multiple: langchain 0.2 in master (#21191) 2024-05-08 16:46:52 -04:00
docstore multiple: Remove unnecessary Ruff suppression comments (#21050) 2024-04-30 17:13:48 +00:00
document_compressors Harrison/move flashrank rerank (#21448) 2024-05-15 13:08:52 -07:00
document_loaders community[patch]: Remove redundant pebblo cloud api call (#21589) 2024-05-20 17:15:16 -07:00
document_transformers community: Add MarkdownifyTransformer to langchain_community.document_transformers (#21247) 2024-05-08 14:45:13 -07:00
embeddings community[patch]: fixed aleph alpha default emedding request (#21826) 2024-05-20 22:39:43 +00:00
example_selectors
graphs community[patch]: Fix neo4j enhanced schema (#21582) 2024-05-13 15:26:06 -04:00
indexes community[patch]: upgrade to recent version of mypy (#21616) 2024-05-13 14:55:07 -04:00
llms community[patch]: Fix MLX LLM Stream (#20575) 2024-05-20 17:17:08 -07:00
memory langchain[patch],community[minor]: Migrate memory implementations to community (#20845) 2024-05-02 10:46:50 -04:00
output_parsers
query_constructors multiple: langchain 0.2 in master (#21191) 2024-05-08 16:46:52 -04:00
retrievers community[minor]: add AskNews retriever and AskNews tool (#21581) 2024-05-20 18:23:06 -07:00
storage (all): update removal in deprecation warnings from 0.2 to 0.3 (#21265) 2024-05-03 14:29:36 -04:00
tools community[minor]: add AskNews retriever and AskNews tool (#21581) 2024-05-20 18:23:06 -07:00
utilities community[minor]: add AskNews retriever and AskNews tool (#21581) 2024-05-20 18:23:06 -07:00
utils
vectorstores community[minor]: add aerospike vectorstore integration (#21735) 2024-05-21 01:01:47 +00:00
__init__.py
cache.py community: init signature revision for Cassandra LLM cache classes + small maintenance (#17765) 2024-05-16 17:22:24 +00:00
py.typed