langchain-octen
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
Basic Search
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
langchain_octen-0.1.1.tar.gz
(5.9 kB
view details)
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_octen-0.1.1.tar.gz.
File metadata
- Download URL: langchain_octen-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.3.3 CPython/3.13.9 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0800021c34e18f3f1e6905dbdda7d5adfd724473288179f1aa01aff6c22eb6b
|
|
| MD5 |
60c247714cd3e95658b631c0d82bcb7f
|
|
| BLAKE2b-256 |
275aa6f107c09ad3121ae01d9c86e67fb224645bb81d9739fd83e77f23f8547c
|
File details
Details for the file langchain_octen-0.1.1-py3-none-any.whl.
File metadata
- Download URL: langchain_octen-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.3.3 CPython/3.13.9 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbeb418085d9b29980b45c3fe4f28df2f2ce0ded4ce49f73719c5838d18502c9
|
|
| MD5 |
0a391321c086c02a0dcc9693920119a9
|
|
| BLAKE2b-256 |
2e01ce5289cc4093a7f185bfc66fb362bd880e29e2d790cfbc66eef846726619
|