* refactor(llamaindex): merge two packages into single hindsight-llamaindex Merge `llama-index-tools-hindsight` and `llama-index-memory-hindsight` into a single `hindsight-llamaindex` package following our naming convention. - Rename package to `hindsight-llamaindex` (Python module: `hindsight_llamaindex`) - Move HindsightToolSpec and HindsightMemory into the same package - Delete `llamaindex-memory/` directory - Add CI test job for llamaindex integration - Update docs, blog post, and integrations.json * fix(blog): update llamaindex blog post for merged package - Move date to 2026-03-30 - Add HindsightMemory (automatic BaseMemory) pattern - Fix "bank must exist first" pitfall — mission auto-creates - Align all code examples with docs page - Update architecture diagram to show both patterns * fix(docs): add llamaindex/openai icons, rename Codex - Add llamaindex.png and openai.png icons - Rename "OpenAI Codex CLI" to "Codex" in integrations.json and docs - Use openai.png icon for Codex integration
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""Shared Hindsight client resolution logic."""
|
|
|
|
from typing import Any, Optional
|
|
|
|
from hindsight_client import Hindsight
|
|
|
|
from .config import get_config
|
|
from .errors import HindsightError
|
|
|
|
# Per-operation timeouts (seconds)
|
|
TIMEOUT_RETAIN = 15.0
|
|
TIMEOUT_RECALL = 10.0
|
|
TIMEOUT_REFLECT = 30.0
|
|
TIMEOUT_BANK = 15.0
|
|
TIMEOUT_DEFAULT = 30.0
|
|
|
|
|
|
def resolve_client(
|
|
client: Optional[Hindsight],
|
|
hindsight_api_url: Optional[str],
|
|
api_key: Optional[str],
|
|
) -> Hindsight:
|
|
"""Resolve a Hindsight client from explicit args or global config."""
|
|
if client is not None:
|
|
return client
|
|
|
|
config = get_config()
|
|
url = hindsight_api_url or (config.hindsight_api_url if config else None)
|
|
key = api_key or (config.api_key if config else None)
|
|
|
|
if url is None:
|
|
raise HindsightError(
|
|
"No Hindsight API URL configured. Pass client= or hindsight_api_url=, or call configure() first."
|
|
)
|
|
|
|
kwargs: dict[str, Any] = {"base_url": url, "timeout": TIMEOUT_DEFAULT}
|
|
if key:
|
|
kwargs["api_key"] = key
|
|
return Hindsight(**kwargs)
|