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

langchain_polaris-0.1.1.tar.gz (6.3 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.1.1-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_polaris-0.1.1.tar.gz
  • Upload date:
  • Size: 6.3 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.1.1.tar.gz
Algorithm Hash digest
SHA256 f5f8b16932c9a6e81563330cab602a0ed760c0e56d0b61bdb28cec3ce8efae38
MD5 adbf80d476b58eed0fa92d569b386d84
BLAKE2b-256 2d76795c2295a033ec2160f29846941aae7de64a0e6bc994e5906ee2a2ed5b67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for langchain_polaris-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd2a782d76b5dd6257708db29377c8c9fd87684aa74597e2fdbd9e7e5cf65822
MD5 da0b8a55d29ee0f6eb895878341ae7c8
BLAKE2b-256 bc91a263de3402ee2db4403aca0e387cf5840436cbdc9249d08fa661121d8cd9

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