Environment:24kchengYe MemoMind LLM Provider
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, LLMs |
| Last Updated | 2026-10-28 14:45 GMT |
Overview
OpenAI-compatible LLM API endpoint for fact extraction, reflect agent tool-calling, structured output generation, and memory consolidation.
Description
This environment provides access to a Large Language Model via an OpenAI-compatible API. MemoMind supports multiple providers — OpenAI, Anthropic, Gemini, Groq, Ollama, LMStudio, MiniMax, Vertex AI, Claude Code, and OpenAI Codex — all abstracted behind a unified `LLMInterface`. The default provider is OpenAI with model `gpt-4o-mini`. Per-operation LLM configuration is supported (retain, reflect, consolidation can each use a different provider/model/key). The production deployment routes LLM calls through an internal proxy (`sub2api`) at `http://sub2api:8080/v1`.
Usage
Use this environment for any LLM-based operation: fact extraction from text (`retain`), the reflect agent's iterative tool-calling loop, structured output/JSON extraction, and memory consolidation (observation synthesis). It is the mandatory prerequisite for all implementations that call an LLM.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Any (calls remote API) | No GPU required for remote providers |
| Hardware | Minimal CPU/RAM | LLM inference is offloaded to the provider |
| Network | Internet access to LLM API | Or internal proxy (e.g., sub2api) for production |
Dependencies
Python Packages
- `openai` >= 1.0 — AsyncOpenAI client (used by OpenAI-compatible provider)
- `httpx` — HTTP client for non-OpenAI providers (Anthropic, Gemini, Cohere)
- `anthropic` — Anthropic Claude provider (optional)
- `google-generativeai` — Google Gemini provider (optional)
- `litellm` — LiteLLM proxy support (optional)
Provider Models
Default models per provider (from `config.py:350-362`):
- `openai`: `gpt-4o-mini`
- `anthropic`: `claude-haiku-4-5-20251001`
- `gemini`: `gemini-2.5-flash`
- `groq`: `openai/gpt-oss-120b`
- `minimax`: `MiniMax-M2.5`
- `ollama`: `gemma3:12b`
- `lmstudio`: `local-model`
- `vertexai`: `google/gemini-2.5-flash-lite`
- `openai-codex`: `gpt-5.2-codex`
- `claude-code`: `claude-sonnet-4-5-20250929`
Credentials
The following environment variables must be set in `.env`:
- `HINDSIGHT_API_LLM_PROVIDER`: Provider name (default: `openai`)
- `HINDSIGHT_API_LLM_API_KEY`: API key for the LLM provider
- `HINDSIGHT_API_LLM_MODEL`: Model name (default: `gpt-4o-mini`)
- `HINDSIGHT_API_LLM_BASE_URL`: API base URL (optional; for proxies/local models)
Per-operation overrides (optional):
- `HINDSIGHT_API_RETAIN_LLM_*` — Fact extraction LLM config
- `HINDSIGHT_API_REFLECT_LLM_*` — Reflect agent LLM config
- `HINDSIGHT_API_CONSOLIDATION_LLM_*` — Consolidation LLM config
Vertex AI (optional):
- `HINDSIGHT_API_LLM_VERTEXAI_PROJECT_ID`
- `HINDSIGHT_API_LLM_VERTEXAI_REGION` (default: `us-central1`)
- `HINDSIGHT_API_LLM_VERTEXAI_SERVICE_ACCOUNT_KEY`
Service tier tuning:
- `HINDSIGHT_API_LLM_OPENAI_SERVICE_TIER` (default: None; `flex` = 50% cheaper)
- `HINDSIGHT_API_LLM_GROQ_SERVICE_TIER` (default: `auto`; `on_demand` or `flex`)
Quick Install
# Core LLM dependencies
pip install openai httpx
# Provider-specific (optional)
pip install anthropic # Anthropic Claude
pip install google-generativeai # Google Gemini
Code Evidence
LLM provider configuration from `config.py:119-133`:
ENV_LLM_PROVIDER = "HINDSIGHT_API_LLM_PROVIDER"
ENV_LLM_API_KEY = "HINDSIGHT_API_LLM_API_KEY"
ENV_LLM_MODEL = "HINDSIGHT_API_LLM_MODEL"
ENV_LLM_BASE_URL = "HINDSIGHT_API_LLM_BASE_URL"
Provider default models from `config.py:350-362`:
PROVIDER_DEFAULT_MODELS = {
"openai": "gpt-4o-mini",
"anthropic": "claude-haiku-4-5-20251001",
"gemini": "gemini-2.5-flash",
"groq": "openai/gpt-oss-120b",
"minimax": "MiniMax-M2.5",
"ollama": "gemma3:12b",
"lmstudio": "local-model",
"vertexai": "google/gemini-2.5-flash-lite",
"openai-codex": "gpt-5.2-codex",
"claude-code": "claude-sonnet-4-5-20250929",
"mock": "mock-model",
}
Abstract LLM interface from `llm_interface.py:14-46`:
class LLMInterface(ABC):
def __init__(self, provider, api_key, base_url, model, reasoning_effort="low", **kwargs):
self.provider = provider.lower()
self.api_key = api_key
self.base_url = base_url
self.model = model
Retry/backoff defaults from `config.py:364-368`:
DEFAULT_LLM_MAX_RETRIES = 10
DEFAULT_LLM_INITIAL_BACKOFF = 1.0
DEFAULT_LLM_MAX_BACKOFF = 60.0
DEFAULT_LLM_TIMEOUT = 120.0
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `RuntimeError: LLM connection test failed` | Invalid API key or unreachable endpoint | Verify `HINDSIGHT_API_LLM_API_KEY` and `HINDSIGHT_API_LLM_BASE_URL` |
| `LengthFinishReasonError` | Model output exceeded max tokens | Increase `HINDSIGHT_API_RETAIN_MAX_COMPLETION_TOKENS` (default 64000) |
| `APIConnectionError` | Network issue to LLM API | Check network/proxy; increase `HINDSIGHT_API_LLM_TIMEOUT` |
| Rate limit (429) | Too many concurrent LLM calls | Reduce `HINDSIGHT_API_LLM_MAX_CONCURRENT` (default 32) |
Compatibility Notes
- Reasoning models (o1, o3, GPT-5): Support extended thinking; `reasoning_effort` parameter controls depth.
- Groq: Applies a fixed seed (4242) for deterministic behavior; supports `on_demand`/`flex` service tiers.
- Ollama/LMStudio: Local models via OpenAI-compatible API; no API key needed but requires local inference server.
- Vertex AI: Requires `HINDSIGHT_API_LLM_VERTEXAI_PROJECT_ID`; uses ADC if service account key not set.
- Per-operation config: Retain, reflect, and consolidation can each use different providers/models — useful for cost optimization (e.g., cheaper model for extraction, stronger model for consolidation).
Related Pages
- Implementation:24kchengYe_MemoMind_extract_facts_from_contents
- Implementation:24kchengYe_MemoMind_run_reflect_agent
- Implementation:24kchengYe_MemoMind_generate_structured_output
- Implementation:24kchengYe_MemoMind_run_consolidation_job
- Implementation:24kchengYe_MemoMind_build_batch_consolidation_prompt
- Implementation:24kchengYe_MemoMind_register_mcp_tools
- Implementation:24kchengYe_MemoMind_create_mcp_server
- Implementation:24kchengYe_MemoMind_serve_py