Skip to main content

LangChain integration for NewsCatcher CatchAll API

Project description

🦜🔗 LangChain CatchAll

License: MIT

The official LangChain integration for CatchAll by NewsCatcher.

Build autonomous web search agents, financial analysts, and research assistants that can find, read, and analyze millions of web pages.


🌟 Features

  • Smart Caching: "Fetch Once, Query Many." Search for a topic, then ask infinite follow-up questions instantly using the local cache.
  • Agent Toolkit: Ready-to-use CatchAllTools for LangGraph agents.
  • Dual-Mode: Supports both granular control (for scripts) and autonomous agents.
  • LLM Agnostic: Works with OpenAI, Gemini, Anthropic, or any LangChain-compatible model.

🚀 Quick Start

Installation

pip install langchain-catchall

Basic Usage (One-Shot Search)

import os
from langchain_catchall import CatchAllClient

os.environ["CATCHALL_API_KEY"] = "your_key"

client = CatchAllClient(api_key=os.environ["CATCHALL_API_KEY"])

# Search and wait for results
result = client.search("Find all articles about security incidents (data breaches, ransomware, hacks) disclosed between November 3 and November 5")

print(f"Found {result.valid_records} records.")
for record in result.all_records[:3]:
    print(f"- {record.record_title}")

🤖 Building an Autonomous Agent

The real power comes when you connect CatchAll to a LangGraph agent. The agent can decide when to search for new data and when to just analyze what it already found.

from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent
from langchain_core.messages import SystemMessage
from langchain_catchall import CatchAllTools, CATCHALL_AGENT_PROMPT

# Here is CATCHALL_AGENT_PROMPT:
"""You are a News Research Assistant powered by CatchAll.

Your workflow is strictly defined:
1. SEARCH: Use `catchall_search_data` ONLY to get a broad initial dataset (e.g., 'Find all US office openings').
   - WARNING: This tool takes 15 minutes. NEVER call it twice in a row.
   
2. ANALYZE: Use `catchall_analyze_data` for ALL follow-up questions.
   - FILTERING & SORTING: 'Show me only Florida deals', 'Sort by date', 'Find top 3'.
   - AGGREGATION: 'Group by state', 'Count by industry'.
   - QA: 'What are the main trends?', 'Summarize key findings'.
   
CRITICAL RULES:
- If the user asks for a subset of data (like 'only Florida deals'), assume it is ALREADY in your search results.
- NEVER use `catchall_search_data` to filter data. Always use `catchall_analyze_data`.
- Only use `catchall_search_data` if the user explicitly asks for a 'new search' or a completely different topic.
"""

# 1. Setup Tools
llm = ChatOpenAI(model="gpt-4o")
toolkit = CatchAllTools(api_key="...", llm=llm, verbose=True)
tools = toolkit.get_tools()

# 2. Create Agent
agent = create_react_agent(
    model=ChatOpenAI(model="gpt-4o"), 
    tools=tools
)

# 3. Run
messages = [SystemMessage(content=CATCHALL_AGENT_PROMPT)]
messages.append(("user", "Find all articles about corporate HQ relocations or office closures in the US for last 3 days"))

response = agent.invoke({"messages": messages})
print(response["messages"][-1].content)

📚 Advanced Patterns

Fetch Once, Query Many (Financial Analyst Mode)

Perfect for deep dives where you don't want to re-run the search every time.

from langchain_catchall import CatchAllClient, query_with_llm
from langchain_openai import ChatOpenAI

# 1. Set up LLM
llm = ChatOpenAI(model="gpt-4o")

# 2. Grab needed data using CatchAllClient
client = CatchAllClient(api_key="...")
result = client.search("Find all articles about seed rounds over $5M announced this week")

# 3. The Fast Analysis (Local Cache)
# Ask as many questions as you want
print(query_with_llm(result, "List top 3 deals", llm))
print(query_with_llm(result, "Who are the CEOs?", llm))
print(query_with_llm(result, "What is total amount of money raised in the US market", llm))

📄 License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_catchall-0.1.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_catchall-0.1.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file langchain_catchall-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_catchall-0.1.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_catchall-0.1.1.tar.gz
Algorithm Hash digest
SHA256 564f6b32145a789b7c2765db6a924d13f3aa9c97c71ed997cc6a4ee3e0f82fd6
MD5 96558965f30ebc28c9ee98d1c161b0f3
BLAKE2b-256 6d81332cec94295b66eac0c9ebbdc8ccd5328aed0eede8a15a1b5e04c8c9349c

See more details on using hashes here.

File details

Details for the file langchain_catchall-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_catchall-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 007c83dfaaa998d91b67a7090c77a596f03df09a563fe0e436d277b0e78265ed
MD5 0783e50c8e14df610042ac6f839b1a08
BLAKE2b-256 e366992459f12bea6170d3b179586e62327b2f5db2312122184e56141f8789e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page