Skip to main content

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="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

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_polaris-0.2.0.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

langchain_polaris-0.2.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_polaris-0.2.0.tar.gz.

File metadata

  • Download URL: langchain_polaris-0.2.0.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for langchain_polaris-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ca0598c4cbe96bfb7695b2405ab916d2f19e3356ab2d49d8ced060e998883573
MD5 c2fbf545c49845b3c3dc556f1859ef04
BLAKE2b-256 a83b06dcbe69a304575f25280530b5ad25b4ed8bae0f81d4adee9af21c62f4b8

See more details on using hashes here.

File details

Details for the file langchain_polaris-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_polaris-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8dd100e22e426e2ccf1897c788012fc153ebf46f1c6f2be8692c158d9525c3f2
MD5 f82c52633db32d9ec3b4a21052ec58d7
BLAKE2b-256 7c3d4b718c15b72e9918b7befcb5d4d76c9d12b32e9f69a4aaf609c456f59dec

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