LangChain integration for The Polaris Report — verified news intelligence tools and retriever
Project description
langchain-polaris
LangChain integration for The Polaris Report — verified news intelligence with confidence scores, bias ratings, and source analysis.
Installation
pip install langchain-polaris
Quick Start
Agent with Tools
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_core.prompts import ChatPromptTemplate
from langchain_polaris import PolarisSearchTool, PolarisBriefTool, PolarisCompareTool
tools = [
PolarisSearchTool(api_key="your-api-key"),
PolarisBriefTool(api_key="your-api-key"),
PolarisCompareTool(api_key="your-api-key"),
]
prompt = ChatPromptTemplate.from_messages([
("system", "You are a news research assistant with access to verified intelligence."),
("human", "{input}"),
("placeholder", "{agent_scratchpad}"),
])
llm = ChatOpenAI(model="gpt-4o")
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
result = executor.invoke({"input": "What's happening with AI regulation?"})
print(result["output"])
Retriever for RAG
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser
from langchain_polaris import PolarisRetriever
retriever = PolarisRetriever(
api_key="your-api-key",
category="ai_ml",
min_confidence=0.7,
limit=5,
)
prompt = ChatPromptTemplate.from_template(
"Answer based on these verified news briefs:\n\n{context}\n\nQuestion: {question}"
)
chain = (
{"context": retriever, "question": RunnablePassthrough()}
| prompt
| ChatOpenAI(model="gpt-4o")
| StrOutputParser()
)
print(chain.invoke("What are the latest developments in AI?"))
Tools
| Tool | Description |
|---|---|
PolarisSearchTool |
Search verified news intelligence across 18 verticals. Supports category filtering and speed tiers (depth: fast, standard, deep). |
PolarisFeedTool |
Get latest verified news briefs, optionally filtered by category or source domain. |
PolarisEntityTool |
Look up entities (companies, people, technologies) mentioned in verified news coverage. |
PolarisBriefTool |
Get a specific verified news brief by ID with full analysis, sources, and counter-arguments. |
PolarisExtractTool |
Extract clean article content from URLs. Returns structured text with metadata. |
PolarisCompareTool |
Compare how different news outlets covered the same story. Shows framing, bias, and what each side emphasizes or omits. |
Retriever
PolarisRetriever implements LangChain's BaseRetriever interface, returning Document objects with:
- page_content: Headline, summary, and body text
- metadata:
brief_id,confidence,bias_score,category,published_at,counter_argument,sources,entities
Retriever Options
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key |
str | required | Polaris API key |
category |
str | None | Category filter |
min_confidence |
float | None | Minimum confidence score (0-1) |
limit |
int | 10 | Max results to return |
include_sources |
str | None | Comma-separated source domains to include |
exclude_sources |
str | None | Comma-separated source domains to exclude |
Documentation
Full API docs at thepolarisreport.com/docs
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_polaris-0.1.0.tar.gz.
File metadata
- Download URL: langchain_polaris-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2ac744851c8becda448169e72a2150f3d5f4b59b6c9753e5ae65ce4354486a8
|
|
| MD5 |
cb31d5f9a310e5dd46bc0bfc15d78c4a
|
|
| BLAKE2b-256 |
503d7479fc6eb2e8fef0d60a6f7f8d5c96af6eccf795163516a918fb2fbc2e80
|
File details
Details for the file langchain_polaris-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_polaris-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a60dd725607daee645d8c31cb08cb63cbb13b340388595cd2e7789deb166b39
|
|
| MD5 |
8ed1e2e902d2487d6f2f1fdba5e9abf2
|
|
| BLAKE2b-256 |
381bfcc698ae8bb275e6a145856c0681e4be004e8693d3dfbc408039f262e1f3
|