Skip to content

Latest commit

 

History

History
659 lines (435 loc) · 80.4 KB

File metadata and controls

659 lines (435 loc) · 80.4 KB

MemoryStores

Overview

Available Operations

list

Retrieves a paginated list of memory stores in the workspace. Use cursor-based pagination parameters to navigate through the results.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.list(limit=10)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
limit Optional[int] ➖ A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
starting_after Optional[str] ➖ A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list.
ending_before Optional[str] ➖ A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list.
search Optional[str] ➖ Filter memory stores by key (case-insensitive match)
updated_by Optional[str] ➖ Filter by the users who last updated the memory store. Accepts a comma-separated list of user IDs
project_id Optional[str] ➖ Filter memory stores by project ID
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListMemoryStoresResponse

Errors

Error Type Status Code Content Type
models.HonoAPIError 401 application/json
models.APIDefaultError 4XX, 5XX */*

create

Create memory store

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.create(key="<key>", embedding_config={
        "model": "cohere/embed-multilingual-light-v3.0",
    }, description="unlike excluding soulful quirkily hmph baseboard whereas gee deserted", path="Default")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
key str ✔️ The unique key of the memory store. The key is unique and inmmutable and cannot be repeated within the same workspace.
embedding_config models.MemoryStoreEmbeddingConfig ✔️ N/A
description str ✔️ N/A Long-term memory store for customer preferences and interaction history.
path str ✔️ Entity storage path. With workspace-level API keys, the first element identifies the project. With project-level API keys, the path is relative to that project.
ttl OptionalNullable[float] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.MemoryStore

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

retrieve

Retrieves detailed information about a specific memory store, including its configuration and metadata.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.retrieve(memory_store_key="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.MemoryStore

Errors

Error Type Status Code Content Type
models.HonoAPIError 401, 403, 404 application/json
models.APIDefaultError 4XX, 5XX */*

delete

Permanently delete a memory store, including memories and documents.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.memory_stores.delete(memory_store_key="<value>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

update

Update the memory store configuration

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.update(memory_store_key="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
description Optional[str] ➖ N/A
ttl OptionalNullable[float] ➖ N/A
path Optional[str] ➖ N/A
project_id Optional[str] ➖ New containing project. Omit to keep the current project; path resolves inside it.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.MemoryStore

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

list_memories

Retrieves a paginated list of memories for the memory store

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.list_memories(memory_store_key="<value>", limit=10)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ The unique key identifier of the memory store
limit Optional[int] ➖ A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
starting_after Optional[str] ➖ A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list.
ending_before Optional[str] ➖ A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list.
q Optional[str] ➖ Search query to filter memories by entity_id
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListMemoriesResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

create_memory

Creates a new memory in the specified memory store.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.create_memory(memory_store_key="<value>", entity_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
entity_id str ✔️ Unique identifier for the entity this memory is associated with (e.g., user ID, session ID, conversation ID).
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Memory

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

retrieve_memory

Retrieves details of a specific memory by its ID

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.retrieve_memory(memory_store_key="<value>", memory_entity_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
memory_entity_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Memory

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

delete_memory

Permanently deletes a specific memory.

Use this endpoint to:

  • Remove a memory from the store
  • Clean up unused memories
  • Manage memory storage space

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.memory_stores.delete_memory(memory_store_key="<value>", memory_entity_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
memory_entity_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

update_memory

Updates the details of a specific memory.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.update_memory(memory_store_key="<value>", memory_entity_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
memory_entity_id str ✔️ N/A
metadata Dict[str, str] ➖ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.Memory

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

list_documents

Retrieves a paginated list of documents associated with a specific memory.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.list_documents(memory_store_key="<value>", memory_entity_id="<id>", limit=10)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ The unique key identifier of the memory store
memory_entity_id str ✔️ The unique identifier of the memory
limit Optional[int] ➖ A limit on the number of objects to be returned. Limit can range between 1 and 50, and the default is 10
starting_after Optional[str] ➖ A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, ending with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include after=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the next page of the list.
ending_before Optional[str] ➖ A cursor for use in pagination. ending_before is an object ID that defines your place in the list. For instance, if you make a list request and receive 20 objects, starting with 01JJ1HDHN79XAS7A01WB3HYSDB, your subsequent call can include before=01JJ1HDHN79XAS7A01WB3HYSDB in order to fetch the previous page of the list.
updated_after date ➖ Filter documents updated after this ISO datetime
updated_before date ➖ Filter documents updated before this ISO datetime
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.ListMemoryDocumentsResponse

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

create_document

Creates a new document in the specified memory.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.create_document(memory_store_key="<value>", memory_entity_id="<id>", text="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
memory_entity_id str ✔️ N/A
text str ✔️ The content of the memory document (whitespace trimmed).
metadata Dict[str, str] ➖ Flexible key-value pairs for custom filtering and categorization. Clients can add arbitrary string metadata to enable future filtering of memory documents based on their specific needs.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.MemoryDocument

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

retrieve_document

Retrieves details of a specific memory document by its ID.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.retrieve_document(memory_store_key="<value>", memory_entity_id="<id>", document_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
memory_entity_id str ✔️ N/A
document_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.MemoryDocument

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

delete_document

Permanently deletes a specific memory document.

Use this endpoint to:

  • Remove a document from a memory
  • Clean up unused documents
  • Manage document storage space

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.memory_stores.delete_document(memory_store_key="<value>", memory_entity_id="<id>", document_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
memory_entity_id str ✔️ N/A
document_id str ✔️ N/A
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*

update_document

Updates the details of a specific memory document.

Example Usage

from orq_ai_sdk import Orq
import os


with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.memory_stores.update_document(memory_store_key="<value>", memory_entity_id="<id>", document_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
memory_store_key str ✔️ N/A
memory_entity_id str ✔️ N/A
document_id str ✔️ N/A
text Optional[str] ➖ The content of the memory document (whitespace trimmed).
metadata Dict[str, str] ➖ Flexible key-value pairs for custom filtering and categorization. Clients can add arbitrary string metadata to enable future filtering of memory documents based on their specific needs.
retries Optional[utils.RetryConfig] ➖ Configuration to override the default retry behavior of the client.

Response

models.MemoryDocument

Errors

Error Type Status Code Content Type
models.APIDefaultError 4XX, 5XX */*