Manage GoodMem RAG Resources

Use GoodMemResources when you want the LangChain integration to manage the GoodMem resources needed for the normal RAG/search workflow: embedders, spaces, memories, and a clean-slate server-side bootstrap path.

This facade is deliberately narrower than the full GoodMem SDK. It does not cover API key lifecycle, server init, migrations, system operations, or LLM/reranker/OCR/extension administration.

GoodMem resource helpers for normal LangChain RAG workflows.

GoodMemResources is the public GoodMem-specific companion to the LangChain-facing GoodMemVectorStore and GoodMemEmbeddings classes. It covers the resources needed to get from a clean GoodMem instance to a first query without asking users to import the GoodMem SDK directly:

  • embedders used by LangChain embedding and retrieval flows

  • spaces that scope writes and searches

  • memories written and deleted through LangChain workflows

The facade intentionally stops at the RAG/search boundary. It does not expose broader GoodMem platform administration such as API key lifecycle management, server initialization, migrations, system operations, or LLM/reranker/OCR administration.

class GoodMemEmbedderInfo(embedder_id, display_name, provider_type, endpoint_url, model_identifier, dimensionality, supported_modalities)[source]

Stable public summary of a GoodMem embedder.

Parameters:
  • embedder_id (str | None) – GoodMem embedder identifier, or None if missing from an unexpected backend response.

  • display_name (str | None) – User-facing embedder name.

  • provider_type (str | None) – Provider type such as OPENAI.

  • endpoint_url (str | None) – Upstream embeddings endpoint URL.

  • model_identifier (str | None) – Upstream embeddings model identifier.

  • dimensionality (int | None) – Embedding vector dimensionality.

  • supported_modalities (tuple[str, ...]) – Supported content modalities.

class GoodMemSpaceInfo(space_id, name, labels, embedder_ids)[source]

Stable public summary of a GoodMem space.

Parameters:
  • space_id (str | None) – GoodMem space identifier, or None if missing from an unexpected backend response.

  • name (str | None) – User-facing space name.

  • labels (dict[str, str]) – Space labels normalized to a plain dictionary.

  • embedder_ids (tuple[str, ...]) – GoodMem embedder IDs attached to the space.

class GoodMemMemoryInfo(memory_id, space_id, metadata, content, processing_status)[source]

Stable public summary of a GoodMem memory.

Parameters:
  • memory_id (str | None) – GoodMem memory identifier, or None if missing from an unexpected backend response.

  • space_id (str | None) – Parent GoodMem space identifier.

  • metadata (dict[str, Any]) – Memory metadata normalized to a plain dictionary.

  • content (str | bytes | None) – Original content when the backend response includes it.

  • processing_status (str | None) – GoodMem processing status when available.

class GoodMemResources(connection)[source]

Facade for GoodMem resources used by LangChain RAG workflows.

Parameters:

connection (GoodMemConnection) – Shared GoodMem transport configuration.

classmethod from_env(*, verify=True)[source]

Build a resources facade from GOODMEM_API_KEY and GOODMEM_BASE_URL.

Parameters:

verify (bool | str) – TLS verification setting forwarded to GoodMemConnection.from_env.

Returns:

GoodMemResources – A resources facade using environment-provided GoodMem credentials.

create_embedder(*, endpoint_url, model_identifier, dimensionality, upstream_api_key=None, display_name=None)[source]

Create one OPENAI-compatible GoodMem embedder.

Parameters:
  • endpoint_url (str) – Upstream provider endpoint URL.

  • model_identifier (str) – Upstream embedding model identifier.

  • dimensionality (int) – Required embedding dimensionality.

  • upstream_api_key (str | None) – Optional upstream API key stored on the embedder.

  • display_name (str | None) – Optional user-facing name. A stable package default is used when omitted.

Returns:

GoodMemEmbedderInfo – A package-owned embedder summary.

Raises:
  • ValueError – If local inputs are malformed.

  • GoodMemDuplicateIDError – If GoodMem reports that the embedder already exists.

  • GoodMemAPIError – If GoodMem rejects the create request.

get_embedder(embedder_id)[source]

Return one GoodMem embedder by ID.

Parameters:

embedder_id (str) – GoodMem embedder identifier to load.

Returns:

GoodMemEmbedderInfo – A package-owned embedder summary.

Raises:
  • ValueError – If embedder_id is blank or not a string.

  • GoodMemAPIError – If GoodMem rejects the lookup.

list_embedders(*, label=None, owner_id=None, provider_type=None)[source]

List embedders visible to the current GoodMem credentials.

Parameters:
  • label (Mapping[str, str] | None) – Optional GoodMem label filter.

  • owner_id (str | None) – Optional GoodMem owner ID filter.

  • provider_type (str | None) – Optional GoodMem provider type filter such as OPENAI.

Returns:

list[GoodMemEmbedderInfo] – Package-owned embedder summaries.

Raises:
  • ValueError – If local filter inputs have invalid shapes.

  • GoodMemAPIError – If GoodMem rejects the listing.

delete_embedder(embedder_id)[source]

Delete one GoodMem embedder by ID.

Parameters:

embedder_id (str) – GoodMem embedder identifier to delete.

Raises:
  • ValueError – If embedder_id is blank or not a string.

  • GoodMemAPIError – If GoodMem rejects the delete.

Return type:

None

create_space(name, embedders=None, embedding=None, labels=None)[source]

Create one GoodMem space for LangChain writes and retrieval.

Exactly one embedder source is accepted: explicit embedders or a single GoodMemEmbeddings instance.

Parameters:
  • name (str) – Requested GoodMem space name.

  • embedders (list[GoodMemSpaceEmbedder] | None) – Explicit GoodMem space-embedder declarations.

  • embedding (GoodMemEmbeddings | None) – Existing GoodMemEmbeddings instance whose embedder ID should be attached to the new space.

  • labels (Mapping[str, str] | None) – Optional GoodMem labels for the new space.

Returns:

GoodMemSpaceInfo – A package-owned space summary.

Raises:
  • ValueError – If name or labels are invalid.

  • GoodMemConfigurationError – If embedder inputs are missing, mixed, or incompatible.

  • GoodMemAPIError – If GoodMem rejects the create request.

get_space(space_id)[source]

Return one GoodMem space by ID.

Parameters:

space_id (str) – GoodMem space identifier to load.

Returns:

GoodMemSpaceInfo – A package-owned space summary.

Raises:
  • ValueError – If space_id is blank or not a string.

  • GoodMemAPIError – If GoodMem rejects the lookup.

list_spaces(*, label=None, name_filter=None, max_items=None)[source]

List spaces visible to the current GoodMem credentials.

Parameters:
  • label (Mapping[str, str] | None) – Optional GoodMem label filter.

  • name_filter (str | None) – Optional GoodMem name filter.

  • max_items (int | None) – Optional positive result limit.

Returns:

list[GoodMemSpaceInfo] – Package-owned space summaries. When GoodMem returns a paginated SDK list object, this method follows subsequent pages automatically until all visible results are collected or max_items is reached.

Raises:
  • ValueError – If local filter inputs have invalid shapes.

  • GoodMemAPIError – If GoodMem rejects the listing.

delete_space(space_id)[source]

Delete one GoodMem space by ID.

Parameters:

space_id (str) – GoodMem space identifier to delete.

Raises:
  • ValueError – If space_id is blank or not a string.

  • GoodMemAPIError – If GoodMem rejects the delete.

Return type:

None

create_memory(space_id, content, metadata=None, memory_id=None)[source]

Create one GoodMem memory in a space.

Parameters:
  • space_id (str) – Target GoodMem space identifier.

  • content (str) – Non-empty memory content. The original text is preserved after validation.

  • metadata (Mapping[str, Any] | None) – Optional memory metadata mapping.

  • memory_id (str | None) – Optional caller-supplied GoodMem memory ID.

Returns:

GoodMemMemoryInfo – A package-owned memory summary.

Raises:
  • ValueError – If inputs are malformed or blank where required.

  • GoodMemDuplicateIDError – If GoodMem reports that memory_id already exists.

  • GoodMemAPIError – If GoodMem rejects the create request.

get_memory(memory_id, *, include_content=False)[source]

Return one GoodMem memory by ID.

Parameters:
  • memory_id (str) – GoodMem memory identifier to load.

  • include_content (bool) – Whether to request original memory content from GoodMem when the backend supports it.

Returns:

GoodMemMemoryInfo – A package-owned memory summary.

Raises:
  • ValueError – If memory_id or include_content is invalid.

  • GoodMemAPIError – If GoodMem rejects the lookup.

list_memories(space_id, filter=None, max_items=None)[source]

List memories in one GoodMem space.

Parameters:
  • space_id (str) – GoodMem space identifier to list memories from.

  • filter (str | None) – Optional raw GoodMem memory filter expression.

  • max_items (int | None) – Optional positive result limit.

Returns:

list[GoodMemMemoryInfo] – Package-owned memory summaries. When GoodMem returns a paginated SDK list object, this method follows subsequent pages automatically until all visible results are collected or max_items is reached.

Raises:
  • ValueError – If local filter inputs have invalid shapes.

  • GoodMemAPIError – If GoodMem rejects the listing.

delete_memory(memory_id)[source]

Delete one GoodMem memory by ID.

Parameters:

memory_id (str) – GoodMem memory identifier to delete.

Raises:
  • ValueError – If memory_id is blank or not a string.

  • GoodMemAPIError – If GoodMem rejects the delete.

Return type:

None

delete_memories(memory_ids)[source]

Delete multiple GoodMem memories by ID.

Parameters:

memory_ids (list[str]) – Non-empty GoodMem memory IDs to delete.

Raises:
  • ValueError – If memory_ids is empty or contains invalid values.

  • GoodMemDuplicateIDError – If duplicate memory IDs are supplied after trimming.

  • GoodMemAPIError – If GoodMem rejects the delete request or returns a malformed batch-delete response.

Return type:

None

bootstrap_vector_store(space_name, endpoint_url, model_identifier, dimensionality, upstream_api_key=None, embedder_display_name=None)[source]

Create or reuse an embedder, create a space, and return a vector store.

Parameters:
  • space_name (str) – Requested GoodMem space name.

  • endpoint_url (str) – Upstream embeddings endpoint URL.

  • model_identifier (str) – Upstream embeddings model identifier.

  • dimensionality (int) – Required embedding dimensionality.

  • upstream_api_key (str | None) – Optional upstream API key used when a compatible embedder must be created. When omitted, GOODMEM_EMBEDDINGS_API_KEY is used as a creation fallback.

  • embedder_display_name (str | None) – Optional display name used when creating a new compatible embedder.

Returns:

GoodMemVectorStore – A GoodMemVectorStore bound to the newly created space. This server-side bootstrap path does not retain a local embeddings object, so store.embeddings is None.

Raises:
  • ValueError – If space_name is malformed.

  • GoodMemConfigurationError – If embedder bootstrap inputs are malformed, if no compatible embedder can be used, or if the created space response is missing a usable ID.

  • GoodMemAPIError – If GoodMem rejects an embedder or space request.