Repository navigation
Perigon integration #627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Lauren Hirata Singh (lnhsingh)
merged 4 commits into
langchain-ai:main
from
goperigon:perigon-integration
Sep 25, 2025
Merged
Perigon integration #627
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| title: Perigon | ||
| --- | ||
|
|
||
| >[Perigon](https://perigon.io/) is a comprehensive news API that provides access to real-time contextual information in news articles, stories, metadata and wikipedia pages from thousands of sources worldwide. | ||
| > | ||
|
|
||
| ## Installation and Setup | ||
|
|
||
| `Perigon` integration exists in its own [partner package](https://pypi.org/project/langchain-perigon/). You can install it with: | ||
|
|
||
| ```python | ||
| %pip install -qU langchain-perigon | ||
| ``` | ||
|
|
||
| In order to use the package, you will also need to set the `PERIGON_API_KEY` environment variable to your Perigon API key. | ||
|
|
||
| ## Retrievers | ||
|
|
||
| Perigon provides two retrievers: | ||
|
|
||
| ### ArticlesRetriever | ||
|
|
||
| This retriever retrieves articles based on a given query and optional filters. | ||
|
|
||
| See a [full usage example](/oss/integrations/retrievers/perigon#using-articlesretriever). | ||
|
|
||
| ```python | ||
| # 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}") | ||
| ``` | ||
|
|
||
| You can use the `ArticlesRetriever` in a standard retrieval pipeline: | ||
|
|
||
| ### WikipediaRetriever | ||
|
|
||
| This retriever retrieves wikipedia pages based on a given query and optional filters. | ||
|
|
||
| See a [full usage example](/oss/integrations/retrievers/perigon#using-wikipediaretriever). | ||
|
|
||
| ```python | ||
| # 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}") | ||
| ``` | ||
|
|
||
| You can use the `WikipediaRetriever` in a standard retrieval pipeline: |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this in alphabetical order