Perigon은 전 세계 수천 개의 소스에서 뉴스 기사, 스토리, 메타데이터 및 위키백과 페이지의 실시간 맥락 정보에 대한 액세스를 제공하는 포괄적인 뉴스 API입니다.

Installation and Setup

Perigon integration은 자체 partner package로 존재합니다. 다음과 같이 설치할 수 있습니다:
pip install -qU langchain-perigon
패키지를 사용하려면 PERIGON_API_KEY 환경 변수를 Perigon API key로 설정해야 합니다.

Retrievers

Perigon은 두 가지 retriever를 제공합니다:

ArticlesRetriever

이 retriever는 주어진 query와 선택적 filter를 기반으로 기사를 검색합니다. 전체 사용 예제를 참조하세요.
# Make sure PERIGON_API_KEY environment variable is set to your Perigon API key
from langchain_perigon import ArticlesRetriever, ArticlesFilter

# Create retriever with specific number of results
retriever = ArticlesRetriever(k=12)

# Configure filter options to exclude reprints and focus on US articles
options: ArticlesFilter = {
    "showReprints": False,  # Exclude duplicate/reprint articles
    "filter": {"country": "us"},  # Only US-based news
}

try:
    documents = retriever.invoke("Recent big tech layoffs", options=options)

    # Check if we got results before accessing
    if documents:
        print(f"First document: {documents[0].page_content[:200]}...")
    else:
        print("No articles found for the given query.")
except Exception as e:
    print(f"Error retrieving articles: {e}")
표준 retrieval pipeline에서 ArticlesRetriever를 사용할 수 있습니다:

WikipediaRetriever

이 retriever는 주어진 query와 선택적 filter를 기반으로 위키백과 페이지를 검색합니다. 전체 사용 예제를 참조하세요.
# Make sure PERIGON_API_KEY environment variable is set to your Perigon API key
from langchain_perigon import WikipediaRetriever

# Create retriever with specific number of results
retriever = WikipediaRetriever(k=12)

try:
    documents = retriever.invoke("machine learning")

    # Safely access results with error handling
    if documents:
        print(f"First document: {documents[0].page_content[:200]}...")
    else:
        print("No Wikipedia articles found for the given query.")
except Exception as e:
    print(f"Error retrieving Wikipedia articles: {e}")
표준 retrieval pipeline에서 WikipediaRetriever를 사용할 수 있습니다:
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I