Skip to main content

langchain-octen

PyPI version License: MIT

LangChain integration for Octen Web Search. Use Octen's fast, real-time web search inside LangChain agents and chains.

Installation

pip install langchain-octen

Setup

Get an API key from octen.ai and set it as an environment variable:

export OCTEN_API_KEY="your-api-key"

Or pass it directly when creating the tool:

from langchain_octen import OctenSearchResults

tool = OctenSearchResults(octen_api_key="your-api-key")

Usage

from langchain_octen import OctenSearchResults

tool = OctenSearchResults(max_results=5)
results = tool.invoke({"query": "latest AI research papers"})
for r in results:
    print(r["title"], r["url"])

With Domain Filtering

# Only include results from specific domains
results = tool.invoke({
    "query": "machine learning",
    "include_domains": ["arxiv.org", "papers.nips.cc"],
})

# Exclude results from specific domains
results = tool.invoke({
    "query": "Python tutorial",
    "exclude_domains": ["youtube.com", "reddit.com"],
})

In a LangChain Agent

from langchain_octen import OctenSearchResults
from langgraph.prebuilt import create_react_agent

tool = OctenSearchResults(max_results=5)
agent = create_react_agent(llm, [tool])
response = agent.invoke({"messages": [("user", "What happened in AI today?")]})

Async Support

import asyncio
from langchain_octen import OctenSearchResults

tool = OctenSearchResults(max_results=3)

async def main():
    results = await tool.ainvoke({"query": "Python 3.13 new features"})
    print(results)

asyncio.run(main())

Advanced Options

from langchain_octen import OctenSearchResults

# Time-filtered search
tool = OctenSearchResults(
    max_results=5,
    time_basis="published",
    start_time="2025-01-01",
    end_time="2026-03-30",
)
results = tool.invoke({"query": "Python release notes"})

# Search with highlighted snippets
tool = OctenSearchResults(
    max_results=5,
    highlight_enabled=True,
    highlight_max_tokens=200,
)
results = tool.invoke({"query": "LangChain tutorial"})

# Search with full page content
tool = OctenSearchResults(
    max_results=3,
    full_content_enabled=True,
    full_content_max_tokens=1000,
)
results = tool.invoke({"query": "Python documentation"})

Configuration

Parameter Type Default Description
octen_api_key str env OCTEN_API_KEY Octen API key
max_results int 5 Number of results (1-100)
search_type str None auto, keyword, or semantic
include_domains list[str] None Restrict to these domains
exclude_domains list[str] None Exclude these domains
include_text list[str] None Text that must appear in results
exclude_text list[str] None Text to exclude from results
time_basis str None auto, published, or crawled
start_time str None Start time (ISO 8601)
end_time str None End time (ISO 8601)
format str None text or markdown
safesearch str None off or strict
highlight_enabled bool None Return highlighted snippets
highlight_max_tokens int None Max tokens for highlights
full_content_enabled bool None Return full page content
full_content_max_tokens int None Max tokens for full content
timeout float None Request timeout in seconds

Development

# Install dependencies
poetry install --with test,dev

# Run unit tests (no API key needed)
make test

# Run integration tests (requires OCTEN_API_KEY)
export OCTEN_API_KEY="your-api-key"
make integration_tests

# Run all tests with coverage
poetry run pytest tests/ --cov=langchain_octen --cov-report=term-missing

# Lint and format
make lint
make format

License

MIT

Metadata

Release files for langchain-octen 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-octen 0.1.1
File Size Uploaded Provenance
langchain_octen-0.1.1.tar.gz 5.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-octen 0.1.1
File Interpreter ABI Platform
langchain_octen-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / langchain_octen-0.1.1.tar.gz

Download URL langchain_octen-0.1.1.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
f0800021c34e18f3f1e6905dbdda7d5adfd724473288179f1aa01aff6c22eb6b
BLAKE2b-256 checksum
How to use checksums
275aa6f107c09ad3121ae01d9c86e67fb224645bb81d9739fd83e77f23f8547c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.3 CPython/3.13.9 Darwin/25.3.0

Release files / langchain_octen-0.1.1-py3-none-any.whl

Download URL langchain_octen-0.1.1-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cbeb418085d9b29980b45c3fe4f28df2f2ce0ded4ce49f73719c5838d18502c9
BLAKE2b-256 checksum
How to use checksums
2e01ce5289cc4093a7f185bfc66fb362bd880e29e2d790cfbc66eef846726619
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.3 CPython/3.13.9 Darwin/25.3.0

Security for langchain-octen 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page