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="pr_live_xxx"),
PolarisBriefTool(api_key="pr_live_xxx"),
PolarisCompareTool(api_key="pr_live_xxx"),
]
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="pr_live_xxx",
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. |
PolarisVerifyTool |
Fact-check a claim against the brief corpus. Returns verdict, confidence, evidence, and nuances. Costs 3 API credits. |
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 | None | Polaris API key (auto-reads from POLARIS_API_KEY env var or ~/.polaris/credentials if omitted) |
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
Metadata
Release files for langchain-polaris 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langchain_polaris-0.2.0.tar.gz | 6.8 kB | Without provenance | Details for langchain_polaris-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langchain_polaris-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for langchain_polaris-0.2.0-py3-none-any.whl |
Total release size: 18.5 kB
Release files / langchain_polaris-0.2.0.tar.gz
| Download URL | langchain_polaris-0.2.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca0598c4cbe96bfb7695b2405ab916d2f19e3356ab2d49d8ced060e998883573
|
|
BLAKE2b-256 checksum How to use checksums |
a83b06dcbe69a304575f25280530b5ad25b4ed8bae0f81d4adee9af21c62f4b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / langchain_polaris-0.2.0-py3-none-any.whl
| Download URL | langchain_polaris-0.2.0-py3-none-any.whl |
|---|---|
| Size | 11.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8dd100e22e426e2ccf1897c788012fc153ebf46f1c6f2be8692c158d9525c3f2
|
|
BLAKE2b-256 checksum How to use checksums |
7c3d4b718c15b72e9918b7befcb5d4d76c9d12b32e9f69a4aaf609c456f59dec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for langchain-polaris 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.