GoodMem
ReferenceClient SDKsPython SDK

Memories API

Memories API documentation for Python SDK

All URIs are relative to http://localhost:8080

MethodHTTP requestDescription
batch_create_memoryPOST /v1/memories:batchCreateCreate multiple memories in a batch
batch_delete_memoryPOST /v1/memories:batchDeleteDelete multiple memories by ID
batch_get_memoryPOST /v1/memories:batchGetGet multiple memories by ID
create_memoryPOST /v1/memoriesCreate a new memory
delete_memoryDELETE /v1/memories/{id}Delete a memory
get_memoryGET /v1/memories/{id}Get a memory by ID
get_memory_contentGET /v1/memories/{id}/contentDownload memory content
list_memoriesGET /v1/spaces/{spaceId}/memoriesList memories in a space
retrieve_memoryGET /v1/memories:retrieveStream semantic memory retrieval
retrieve_memory_advancedPOST /v1/memories:retrieveAdvanced semantic memory retrieval with JSON

batch_create_memory

batch_create_memory(batch_memory_creation_request)

Create multiple memories in a batch

Creates multiple memories in a single operation, with individual success/failure results.

Example

  • Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.batch_memory_creation_request import BatchMemoryCreationRequest
from goodmem_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
    host = "http://localhost:8080/v1/default"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = goodmem_client.MemoriesApi(api_client)
    batch_memory_creation_request = goodmem_client.BatchMemoryCreationRequest() # BatchMemoryCreationRequest | Batch memory creation details

    try:
        # Create multiple memories in a batch
        api_instance.batch_create_memory(batch_memory_creation_request)
    except Exception as e:
        print("Exception when calling MemoriesApi->batch_create_memory: %s\n" % e)

Parameters

NameTypeDescriptionNotes
batch_memory_creation_requestBatchMemoryCreationRequestBatch memory creation details

Return type

void (empty response body)

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Results of batch memory creation operation-
207Multi-Status - partial success in batch operation-
400Invalid request - issues with one or more requests-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to create memories-

↑ Back to Python SDK

batch_delete_memory

batch_delete_memory(batch_memory_deletion_request)

Delete multiple memories by ID

Deletes multiple memories in a single operation, with success/failure results for each ID.

Example

  • Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.batch_memory_deletion_request import BatchMemoryDeletionRequest
from goodmem_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
    host = "http://localhost:8080/v1/default"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = goodmem_client.MemoriesApi(api_client)
    batch_memory_deletion_request = goodmem_client.BatchMemoryDeletionRequest() # BatchMemoryDeletionRequest | Batch memory deletion details

    try:
        # Delete multiple memories by ID
        api_instance.batch_delete_memory(batch_memory_deletion_request)
    except Exception as e:
        print("Exception when calling MemoriesApi->batch_delete_memory: %s\n" % e)

Parameters

NameTypeDescriptionNotes
batch_memory_deletion_requestBatchMemoryDeletionRequestBatch memory deletion details

Return type

void (empty response body)

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Results of batch memory deletion operation-
207Multi-Status - partial success in batch operation-
400Invalid request - issues with one or more memory IDs-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to delete one or more memories-

↑ Back to Python SDK

batch_get_memory

batch_get_memory(batch_memory_retrieval_request)

Get multiple memories by ID

Retrieves multiple memories in a single operation, with individual success/failure results.

Example

  • Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.batch_memory_retrieval_request import BatchMemoryRetrievalRequest
from goodmem_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
    host = "http://localhost:8080/v1/default"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = goodmem_client.MemoriesApi(api_client)
    batch_memory_retrieval_request = goodmem_client.BatchMemoryRetrievalRequest() # BatchMemoryRetrievalRequest | Batch memory retrieval details

    try:
        # Get multiple memories by ID
        api_instance.batch_get_memory(batch_memory_retrieval_request)
    except Exception as e:
        print("Exception when calling MemoriesApi->batch_get_memory: %s\n" % e)

Parameters

NameTypeDescriptionNotes
batch_memory_retrieval_requestBatchMemoryRetrievalRequestBatch memory retrieval details

Return type

void (empty response body)

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Results of batch memory retrieval operation-
207Multi-Status - partial success in batch operation-
400Invalid request - issues with one or more memory IDs-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to access one or more memories-

↑ Back to Python SDK

create_memory

Memory create_memory(memory_creation_request)

Create a new memory

Creates a new memory in a specified space and starts asynchronous processing. The memory begins in PENDING status while a background job performs chunking and embedding generation. IMPORTANT: This operation is NOT idempotent - each request creates a new memory record. Returns INVALID_ARGUMENT if space_id, original_content, or content_type is missing or invalid. Returns NOT_FOUND if the specified space does not exist. Requires CREATE_MEMORY_OWN permission for spaces you own (or CREATE_MEMORY_ANY for admin users to create in any space). Side effects include creating the memory record, generating a unique UUID, and enqueuing a background processing job.

Example

  • Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.memory import Memory
from goodmem_client.models.memory_creation_request import MemoryCreationRequest
from goodmem_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
    host = "http://localhost:8080/v1/default"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = goodmem_client.MemoriesApi(api_client)
    memory_creation_request = {"spaceId":"550e8400-e29b-41d4-a716-446655440000","originalContent":"This is the content to be stored and processed as a memory.","contentType":"text/plain","metadata":{"source":"document","author":"John Doe","tags":["important","research"]},"chunkingConfig":{"recursive":{"chunkSize":"500","chunkOverlap":"50","separators":["\\n\\n","\\n","."],"keepStrategy":"KEEP_END","separatorIsRegex":"false","lengthMeasurement":"CHARACTER_COUNT"}}} # MemoryCreationRequest | Memory creation details

    try:
        # Create a new memory
        api_response = api_instance.create_memory(memory_creation_request)
        print("The response of MemoriesApi->create_memory:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling MemoriesApi->create_memory: %s\n" % e)

Parameters

NameTypeDescriptionNotes
memory_creation_requestMemoryCreationRequestMemory creation details

Return type

Memory

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
201Successfully created memory* Location - URI of the created memory resource
400Invalid request - missing required fields or invalid format-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to create memories-

↑ Back to Python SDK

delete_memory

delete_memory(id)

Delete a memory

Permanently deletes a memory and its associated chunks. This operation cannot be undone and immediately removes the memory record from the database. IDEMPOTENCY: This operation is safe to retry - may return NOT_FOUND if the memory was already deleted or never existed. Requires DELETE_MEMORY_OWN permission for memories in spaces you own (or DELETE_MEMORY_ANY for admin users to delete any memory). Side effects include permanent removal of the memory record and all associated chunk data.

Example

  • Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
    host = "http://localhost:8080/v1/default"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = goodmem_client.MemoriesApi(api_client)
    id = '550e8400-e29b-41d4-a716-446655440000' # str | The unique identifier of the memory to delete

    try:
        # Delete a memory
        api_instance.delete_memory(id)
    except Exception as e:
        print("Exception when calling MemoriesApi->delete_memory: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idstrThe unique identifier of the memory to delete

Return type

void (empty response body)

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

HTTP response details

Status codeDescriptionResponse headers
204Memory successfully deleted-
400Invalid request - memory ID in invalid format-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to delete this memory-
404Not found - memory with the specified ID does not exist-

↑ Back to Python SDK

get_memory

Memory get_memory(id, include_content=include_content, include_processing_history=include_processing_history)

Get a memory by ID

Retrieves a single memory by its ID. PERMISSION CLARIFICATION: With READ_MEMORY_OWN permission, access is granted if you own the parent space OR if the parent space is public (public_read=true). With READ_MEMORY_ANY permission, you can access any memory regardless of ownership. This is a read-only operation with no side effects and is safe to retry. Returns NOT_FOUND if the memory or its parent space does not exist.

Example

  • Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.memory import Memory
from goodmem_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
    host = "http://localhost:8080/v1/default"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = goodmem_client.MemoriesApi(api_client)
    id = '550e8400-e29b-41d4-a716-446655440000' # str | The unique identifier of the memory to retrieve
    include_content = false # bool | Whether to include the original content in the response (defaults to false) (optional)
    include_processing_history = false # bool | Whether to include background job processing history in the response (defaults to false) (optional)

    try:
        # Get a memory by ID
        api_response = api_instance.get_memory(id, include_content=include_content, include_processing_history=include_processing_history)
        print("The response of MemoriesApi->get_memory:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling MemoriesApi->get_memory: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idstrThe unique identifier of the memory to retrieve
include_contentboolWhether to include the original content in the response (defaults to false)[optional]
include_processing_historyboolWhether to include background job processing history in the response (defaults to false)[optional]

Return type

Memory

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Successfully retrieved memory-
400Invalid request - memory ID in invalid format-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to view this memory-
404Not found - memory with the specified ID does not exist-

↑ Back to Python SDK

get_memory_content

get_memory_content(id)

Download memory content

Streams the original binary payload for a memory. The response uses the memory's stored content type when available. Returns 404 when the memory does not have inline content; clients can check originalContentRef from the metadata endpoint to locate external content.

Example

  • Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
    host = "http://localhost:8080/v1/default"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = goodmem_client.MemoriesApi(api_client)
    id = '550e8400-e29b-41d4-a716-446655440000' # str | The unique identifier of the memory to download

    try:
        # Download memory content
        api_instance.get_memory_content(id)
    except Exception as e:
        print("Exception when calling MemoriesApi->get_memory_content: %s\n" % e)

Parameters

NameTypeDescriptionNotes
idstrThe unique identifier of the memory to download

Return type

void (empty response body)

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/octet-stream

HTTP response details

Status codeDescriptionResponse headers
200Memory content streamed successfully-
400Invalid request - memory ID in invalid format-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to view this memory-
404Not found - memory has no inline content or does not exist-

↑ Back to Python SDK

list_memories

MemoryListResponse list_memories(space_id, include_content=include_content, status_filter=status_filter, max_results=max_results, next_token=next_token, sort_by=sort_by, sort_order=sort_order)

List memories in a space

Lists all memories within a given space. CRITICAL: The current server implementation does NOT support pagination - the max_results and next_token parameters are IGNORED and all matching memories are returned. This is a read-only operation with no side effects and is safe to retry. Requires LIST_MEMORY_OWN or LIST_MEMORY_ANY permission. Returns NOT_FOUND if the specified space does not exist.

Example

  • Api Key Authentication (ApiKeyAuth):
import goodmem_client
from goodmem_client.models.memory_list_response import MemoryListResponse
from goodmem_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost:8080/v1/default
# See configuration.py for a list of all supported configuration parameters.
configuration = goodmem_client.Configuration(
    host = "http://localhost:8080/v1/default"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure API key authorization: ApiKeyAuth
configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer'

# Enter a context with an instance of the API client
with goodmem_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = goodmem_client.MemoriesApi(api_client)
    space_id = '550e8400-e29b-41d4-a716-446655440000' # str | The unique identifier of the space containing the memories
    include_content = false # bool | Whether to include the original content in the response (defaults to false) (optional)
    status_filter = 'COMPLETED' # str | Filter memories by processing status (PENDING, PROCESSING, COMPLETED, FAILED) (optional)
    max_results = 100 # int | IGNORED: The current server implementation does not support pagination for this endpoint. This parameter is documented for future compatibility but will be ignored. (optional)
    next_token = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...' # str | IGNORED: The current server implementation does not support pagination for this endpoint. This parameter is documented for future compatibility but will be ignored. (optional)
    sort_by = 'created_at' # str | Field to sort by (e.g., 'created_at') (optional)
    sort_order = 'DESCENDING' # str | Sort direction (ASCENDING or DESCENDING) (optional)

    try:
        # List memories in a space
        api_response = api_instance.list_memories(space_id, include_content=include_content, status_filter=status_filter, max_results=max_results, next_token=next_token, sort_by=sort_by, sort_order=sort_order)
        print("The response of MemoriesApi->list_memories:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling MemoriesApi->list_memories: %s\n" % e)

Parameters

NameTypeDescriptionNotes
space_idstrThe unique identifier of the space containing the memories
include_contentboolWhether to include the original content in the response (defaults to false)[optional]
status_filterstrFilter memories by processing status (PENDING, PROCESSING, COMPLETED, FAILED)[optional]
max_resultsintIGNORED: The current server implementation does not support pagination for this endpoint. This parameter is documented for future compatibility but will be ignored.[optional]
next_tokenstrIGNORED: The current server implementation does not support pagination for this endpoint. This parameter is documented for future compatibility but will be ignored.[optional]
sort_bystrField to sort by (e.g., 'created_at')[optional]
sort_orderstrSort direction (ASCENDING or DESCENDING)[optional]

Return type

MemoryListResponse

Authorization

ApiKeyAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

HTTP response details

Status codeDescriptionResponse headers
200Successfully retrieved memories-
400Invalid request - space ID in invalid format-
401Unauthorized - invalid or missing API key-
403Forbidden - insufficient permissions to list memories in this space-
404Not found - space with the specified ID does not exist-

↑ Back to Python SDK

retrieve_memory

📡 Stream Semantic Memory Retrieval

Use the MemoryStreamClient class from goodmem_client.streaming module for streaming memory retrieval:

Example Usage

from goodmem_client.streaming import MemoryStreamClient
from goodmem_client.models.space_key import SpaceKey
from goodmem_client.configuration import Configuration
from goodmem_client.api_client import ApiClient

# Configure client
configuration = Configuration()
configuration.host = "http://localhost:8080"
configuration.api_key = {"ApiKeyAuth": "your-api-key"}

api_client = ApiClient(configuration=configuration)

# Create streaming client
stream_client = MemoryStreamClient(api_client)

# Example 1: Basic retrieval with space_keys
space_keys = [
    SpaceKey(space_id="550e8400-e29b-41d4-a716-446655440000")
]

for event in stream_client.retrieve_memory_stream_chat(
    message="your search query",
    space_keys=space_keys,
    requested_size=10,
    fetch_memory=True,
    fetch_memory_content=False,
    pp_llm_id="550e8400-e29b-41d4-a716-446655440001",
    pp_reranker_id="550e8400-e29b-41d4-a716-446655440000",
    format="ndjson"
):
    if event.abstract_reply:
        print(f"Abstract: {event.abstract_reply.text}")
    elif event.retrieved_item and event.retrieved_item.memory:
        memory = event.retrieved_item.memory
        print(f"Memory: {memory.get('memoryId')}")
    elif event.memory_definition:
        print(f"Memory Definition: {event.memory_definition}")

# Example 2: With filter expressions
space_keys_filtered = [
    SpaceKey(
        space_id="550e8400-e29b-41d4-a716-446655440000",
        filter="CAST(val('$.category') AS TEXT) = 'technology'"
    )
]

for event in stream_client.retrieve_memory_stream_chat(
    message="artificial intelligence",
    space_keys=space_keys_filtered,
    requested_size=5
):
    if event.retrieved_item and event.retrieved_item.chunk:
        print(f"Chunk: {event.retrieved_item.chunk.chunk.get('chunkText', '')[:100]}...")

Parameters

  • message: Search query text
  • space_keys: List of SpaceKey objects (supports filter expressions, embedder weights)
  • requested_size: Number of results to return
  • Additional parameters: fetch_memory, fetch_memory_content, pp_llm_id, pp_reranker_id, format

For backwards compatibility, space_ids (list of strings) is still supported but space_keys is recommended for filter support.

Return type

Generator of RetrieveMemoryEvent objects (streaming)

Authorization

ApiKeyAuth

retrieve_memory_advanced

📡 Advanced Stream Semantic Memory Retrieval

Use the MemoryStreamClient class from goodmem_client.streaming module for advanced streaming memory retrieval with custom post-processor configuration:

Example Usage

from goodmem_client.streaming import MemoryStreamClient
from goodmem_client.models.space_key import SpaceKey
from goodmem_client.configuration import Configuration
from goodmem_client.api_client import ApiClient

# Configure client
configuration = Configuration()
configuration.host = "http://localhost:8080"
configuration.api_key = {"ApiKeyAuth": "your-api-key"}

api_client = ApiClient(configuration=configuration)

# Create streaming client
stream_client = MemoryStreamClient(api_client)

# Example 1: Advanced streaming with custom post-processor
space_keys = [
    SpaceKey(space_id="550e8400-e29b-41d4-a716-446655440000")
]

for event in stream_client.retrieve_memory_stream(
    message="your search query",
    space_keys=space_keys,
    requested_size=10,
    fetch_memory=True,
    fetch_memory_content=False,
    post_processor_name="com.goodmem.retrieval.postprocess.ChatPostProcessorFactory",
    post_processor_config={
        "llm_id": "550e8400-e29b-41d4-a716-446655440001",
        "reranker_id": "550e8400-e29b-41d4-a716-446655440000",
        "relevance_threshold": 0.5,
        "llm_temp": 0.3,
        "max_results": 10,
        "chronological_resort": True
    },
    format="ndjson"
):
    if event.abstract_reply:
        print(f"Abstract: {event.abstract_reply.text}")
    elif event.retrieved_item:
        print(f"Retrieved item: {event.retrieved_item}")

# Example 2: Multiple spaces with different filters
space_keys_filtered = [
    SpaceKey(
        space_id="550e8400-e29b-41d4-a716-446655440000",
        filter="CAST(val('$.category') AS TEXT) = 'technology'"
    ),
    SpaceKey(
        space_id="550e8400-e29b-41d4-a716-446655440001",
        filter="CAST(val('$.priority') AS TEXT) = 'high'"
    )
]

for event in stream_client.retrieve_memory_stream(
    message="important tech updates",
    space_keys=space_keys_filtered,
    requested_size=10
):
    if event.retrieved_item and event.retrieved_item.chunk:
        chunk = event.retrieved_item.chunk
        print(f"Relevance: {chunk.relevance_score:.4f}")
        print(f"Text: {chunk.chunk.get('chunkText', '')[:100]}...")

Parameters

  • message: Search query text
  • space_keys: List of SpaceKey objects with optional:
    • filter: Filter expression for metadata filtering
    • embedder_weights: Custom embedder weights for this space
  • requested_size: Number of results to return
  • post_processor_name: Custom post-processor factory class
  • post_processor_config: Configuration dict for the post-processor
  • Additional parameters: fetch_memory, fetch_memory_content, format

For backwards compatibility, space_ids (list of strings) is still supported but space_keys is recommended.

Return type

Generator of RetrieveMemoryEvent objects (streaming)

Authorization

ApiKeyAuth