Skip to main content

llama-index tools Octen web search integration

Project description

LlamaIndex Tools Integration: Octen

This tool connects to Octen, a fast real-time web search API for AI, to enable your agent to search and retrieve content from the Internet.

To begin, you need to obtain an API key at octen.ai.

Installation

pip install llama-index-tools-octen

Usage

import os
from llama_index.tools.octen import OctenToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

octen_tool = OctenToolSpec(
    api_key=os.environ["OCTEN_API_KEY"],
)
agent = FunctionAgent(
    tools=octen_tool.to_tool_list(),
    llm=OpenAI(model="gpt-4.1"),
)

response = await agent.run(
    "What are the latest developments in AI?"
)
print(response)

Basic Search

from llama_index.tools.octen import OctenToolSpec

tool = OctenToolSpec(api_key=os.environ["OCTEN_API_KEY"])

results = tool.search("latest AI research papers", num_results=5)
for r in results:
    print(r["title"], r["url"])

Search with Domain Filtering

results = tool.search(
    "machine learning",
    include_domains=["arxiv.org", "papers.nips.cc"],
)

results = tool.search(
    "Python tutorial",
    exclude_domains=["youtube.com", "reddit.com"],
)

Search with Time Filter

tool = OctenToolSpec(api_key=os.environ["OCTEN_API_KEY"])

results = tool.search(
    "Python release notes",
    start_time="2025-01-01",
    end_time="2026-03-31",
    time_basis="published",
)

Retrieve Full Page Content

tool = OctenToolSpec(api_key=os.environ["OCTEN_API_KEY"], max_characters=3000)

# Returns List[Document], each Document.text contains the full page content
docs = tool.search_and_retrieve_documents(
    query="Python 3.13 new features",
    num_results=3,
    include_domains=["docs.python.org"],
)

for doc in docs:
    print(doc.metadata["title"], doc.metadata["url"])
    print(doc.text[:200])

Retrieve Highlighted Snippets

# Returns List[Document], each Document.text contains a concise snippet
highlights = tool.search_and_retrieve_highlights(
    query="LlamaIndex agent tutorial",
    num_results=5,
    highlight_max_tokens=300,
)

for doc in highlights:
    print(doc.metadata["title"])
    print(doc.text)

Text Filters and Safe Search

results = tool.search(
    "Python web framework",
    include_text=["async"],
    exclude_text=["deprecated"],
    safesearch="strict",
    format="markdown",
)

Available Tools

  • search: Search the web using Octen for a list of results matching a natural language query.

  • search_and_retrieve_documents: Search and retrieve full page content as LlamaIndex Documents.

  • search_and_retrieve_highlights: Search and retrieve highlighted snippets as LlamaIndex Documents.

  • current_date: Utility for the agent to get today's date (useful for time-filtered searches).

Configuration

Parameter Type Default Description
api_key str required Octen API key
verbose bool True Print search metadata
max_results int 5 Default number of results
max_characters int 2000 Max characters for full content retrieval
timeout float None Request timeout in seconds

Per-query Parameters

All search functions support:

Parameter Type Description
query str Natural language search query
num_results int Number of results (overrides default)
include_domains list[str] Restrict to these domains
exclude_domains list[str] Exclude these domains
search_type str auto, keyword, or semantic
start_time str Start date filter (ISO 8601)
end_time str End date filter (ISO 8601)
time_basis str auto, published, or crawled
include_text list[str] Text that must appear in results
exclude_text list[str] Text to exclude from results
safesearch str off or strict
format str text or markdown

search_and_retrieve_highlights additionally supports:

Parameter Type Description
highlight_max_tokens int Max tokens for highlighted snippets (default: 200)

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

llama_index_tools_octen-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

llama_index_tools_octen-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_octen-0.1.0.tar.gz.

File metadata

  • Download URL: llama_index_tools_octen-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for llama_index_tools_octen-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f524a873e74c9a8669aebadb5defdf6be37b001c23ddb6780434e1111616fb36
MD5 6c908d954cbd0a2a76fe88e3b8d92f84
BLAKE2b-256 85e5ff563f134d92faad87f170d421259de64655b9afa8c06df6f90c6b4da6bc

See more details on using hashes here.

File details

Details for the file llama_index_tools_octen-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_tools_octen-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab4b7556abe630137f5873eecf242c6a8cd6497e6f6087cf4525fe230f39840a
MD5 17252315af0594b5186c6e3d7a9a90a2
BLAKE2b-256 1911e246ea4762acc3025702b5fc06ca06987f373808980882d0d6979737a8c7

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