Foresight.Embedders.Remote (Foresight v0.1.0)

Copy Markdown View Source

OpenAI-compatible remote embedder: POSTs to <base_url>/embeddings (LM Studio, vLLM, Ollama's OpenAI shim, or a cloud provider). Mirrors the LLM local↔cloud fork (Foresight.LLMs.LlmCore) for embeddings, so a single endpoint can serve both the reader and the embedder in dev, and a cloud provider can serve both in production — closing the "embeddings are local-only" gap.

Configuration

Connection config is operator-provided via application env (typically wired from the profile builder), and may be overridden per call:

config :foresight, Foresight.Embedders.Remote,
  base_url: System.get_env("FORESIGHT_EMBED_BASE_URL"),
  api_key: System.get_env("FORESIGHT_EMBED_API_KEY"),
  model: System.get_env("FORESIGHT_EMBED_MODEL"),
  dimension: 384,
  timeout_ms: 30_000

base_url must include the version prefix (e.g. http://127.0.0.1:1234/v1), exactly like the LLM fork. Per-call opts from EmbeddingProfile.embedder_opts/1 (model_id, embedding_dim) override model/dimension.

Dimension guard

dimension is authoritative: every returned vector is checked against it and a mismatch is an error, never a silently-stored wrong-dim vector. This keeps a misconfigured or drifting provider from poisoning a bank whose profile is pinned to one dimension.