* feat: add AutoGen integration for Hindsight Adds hindsight-autogen package providing FunctionTool instances that give AutoGen agents persistent long-term memory via retain/recall/reflect APIs. - Package: hindsight_autogen with create_hindsight_tools() factory - 31 unit tests covering tool creation, invocation, config fallback, errors - Docs page and integrations.json entry - README with quickstart and configuration reference Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address PR review feedback for autogen integration - Fix install instructions to include autogen-agentchat and autogen-ext[openai] - Add autogen.svg icon to prevent broken image in integrations grid - Change icon reference from .png to .svg in integrations.json Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: add sleep between retain/recall and close clients in examples - Add time.sleep(3) between retain and recall to wait for async processing - Close Hindsight client and model client to avoid unclosed session warnings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: use asyncio.sleep instead of time.sleep in async examples time.sleep blocks the event loop; asyncio.sleep yields control. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address PR review feedback - validation, defaults, release script - Add autogen to VALID_INTEGRATIONS in release-integration.sh - Remove unused verbose config field - Extract DEFAULT_BUDGET/MAX_TOKENS/RECALL_TAGS_MATCH constants in config.py, import from tools.py to eliminate default duplication - Add Literal types for budget and recall_tags_match validation - Modernize type hints to X | None with from __future__ import annotations - Add [tool.ruff] line-length = 120 to match monorepo convention - Add py.typed PEP 561 marker - Re-raise HindsightError before broad Exception catch - Expand asyncio.sleep(3) comment explaining when/why it's needed - Remove verbose from docs configure() reference table Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
95 lines
3 KiB
Python
95 lines
3 KiB
Python
"""Global configuration for Hindsight-AutoGen integration."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
from dataclasses import dataclass
|
|
from typing import Literal
|
|
|
|
DEFAULT_HINDSIGHT_API_URL = "https://api.hindsight.vectorize.io"
|
|
HINDSIGHT_API_KEY_ENV = "HINDSIGHT_API_KEY"
|
|
|
|
DEFAULT_BUDGET: Literal["low", "mid", "high"] = "mid"
|
|
DEFAULT_MAX_TOKENS = 4096
|
|
DEFAULT_RECALL_TAGS_MATCH: Literal["any", "all", "any_strict", "all_strict"] = "any"
|
|
|
|
Budget = Literal["low", "mid", "high"]
|
|
TagsMatch = Literal["any", "all", "any_strict", "all_strict"]
|
|
|
|
|
|
@dataclass
|
|
class HindsightAutoGenConfig:
|
|
"""Connection and default settings for the AutoGen integration.
|
|
|
|
Attributes:
|
|
hindsight_api_url: URL of the Hindsight API server.
|
|
api_key: API key for Hindsight authentication.
|
|
budget: Default recall budget level (low/mid/high).
|
|
max_tokens: Default maximum tokens for recall results.
|
|
tags: Default tags applied when storing memories.
|
|
recall_tags: Default tags to filter when searching memories.
|
|
recall_tags_match: Tag matching mode (any/all/any_strict/all_strict).
|
|
"""
|
|
|
|
hindsight_api_url: str = DEFAULT_HINDSIGHT_API_URL
|
|
api_key: str | None = None
|
|
budget: Budget = DEFAULT_BUDGET
|
|
max_tokens: int = DEFAULT_MAX_TOKENS
|
|
tags: list[str] | None = None
|
|
recall_tags: list[str] | None = None
|
|
recall_tags_match: TagsMatch = DEFAULT_RECALL_TAGS_MATCH
|
|
|
|
|
|
_global_config: HindsightAutoGenConfig | None = None
|
|
|
|
|
|
def configure(
|
|
hindsight_api_url: str | None = None,
|
|
api_key: str | None = None,
|
|
budget: Budget = DEFAULT_BUDGET,
|
|
max_tokens: int = DEFAULT_MAX_TOKENS,
|
|
tags: list[str] | None = None,
|
|
recall_tags: list[str] | None = None,
|
|
recall_tags_match: TagsMatch = DEFAULT_RECALL_TAGS_MATCH,
|
|
) -> HindsightAutoGenConfig:
|
|
"""Configure Hindsight connection and default settings.
|
|
|
|
Args:
|
|
hindsight_api_url: Hindsight API URL (default: production).
|
|
api_key: API key. Falls back to HINDSIGHT_API_KEY env var.
|
|
budget: Default recall budget (low/mid/high).
|
|
max_tokens: Default max tokens for recall.
|
|
tags: Default tags for retain operations.
|
|
recall_tags: Default tags to filter recall/search.
|
|
recall_tags_match: Tag matching mode.
|
|
|
|
Returns:
|
|
The configured HindsightAutoGenConfig.
|
|
"""
|
|
global _global_config
|
|
|
|
resolved_url = hindsight_api_url or DEFAULT_HINDSIGHT_API_URL
|
|
resolved_key = api_key or os.environ.get(HINDSIGHT_API_KEY_ENV)
|
|
|
|
_global_config = HindsightAutoGenConfig(
|
|
hindsight_api_url=resolved_url,
|
|
api_key=resolved_key,
|
|
budget=budget,
|
|
max_tokens=max_tokens,
|
|
tags=tags,
|
|
recall_tags=recall_tags,
|
|
recall_tags_match=recall_tags_match,
|
|
)
|
|
|
|
return _global_config
|
|
|
|
|
|
def get_config() -> HindsightAutoGenConfig | None:
|
|
"""Get the current global configuration."""
|
|
return _global_config
|
|
|
|
|
|
def reset_config() -> None:
|
|
"""Reset global configuration to None."""
|
|
global _global_config
|
|
_global_config = None
|