Skip to main content

MemoryX Python SDK - 让 AI Agents 轻松拥有持久记忆

Project description

MemoryX Python SDK

Give your AI agents long-term memory.

Installation

pip install t0ken-memoryx

Quick Start

from memoryx import connect_memory

# Connect (auto-registers on first use)
memory = connect_memory()

# Store a memory
memory.add("User prefers dark mode")

# Search memories
results = memory.search("user preferences")
for m in results["data"]:
    print(m["content"])

# List all memories
memories = memory.list(limit=10)

# Delete a memory
memory.delete("memory_id")

API Reference

connect_memory(base_url=None, verbose=True)

Quick connect to MemoryX. Auto-registers if first time.

from memoryx import connect_memory

memory = connect_memory()

For self-hosted:

memory = connect_memory(base_url="http://localhost:8000/api")

memory.add(content, project_id="default", metadata=None)

Store a memory. Returns {"success": True, "task_id": "..."}.

memory.add("User works at Google")
memory.add("User birthday is Jan 15", project_id="personal")

memory.search(query, project_id=None, limit=10)

Search memories by semantic similarity.

results = memory.search("user job")
for m in results["data"]:
    print(f"- {m['memory']} (score: {m['score']})")

memory.list(project_id=None, limit=50, offset=0)

List all memories with pagination. Uses GET /v1/memories/list.

memories = memory.list(limit=20, offset=0)
print(f"Total: {memories['total']}")
for m in memories["data"]:
    print(f"- {m['id']}: {m['content']}")

memory.delete(memory_id)

Delete a memory by ID.

memory.delete("abc123")

memory.get_task_status(task_id)

Check async task status (from add()).

status = memory.get_task_status("task_id_here")
print(status["status"])  # PENDING, SUCCESS, FAILURE

memory.get_quota()

Get quota information.

quota = memory.get_quota()
print(f"Tier: {quota['quota']['tier']}")
print(f"Memories used: {quota['quota']['memories']['used']}")

Self-Hosted

from memoryx import connect_memory

memory = connect_memory(base_url="http://your-server:8000/api")

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

t0ken_memoryx-1.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

t0ken_memoryx-1.1.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file t0ken_memoryx-1.1.0.tar.gz.

File metadata

  • Download URL: t0ken_memoryx-1.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for t0ken_memoryx-1.1.0.tar.gz
Algorithm Hash digest
SHA256 76042b60e72d3965d234e2e97e45e9c883853dc732b78edba7a350604bbfc357
MD5 2c7f64da823d53c04418739c59c3976e
BLAKE2b-256 60f0464303a623aa9409bb8d7a6498240953cd1b6bae08e42f8093e1052f2c77

See more details on using hashes here.

File details

Details for the file t0ken_memoryx-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: t0ken_memoryx-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for t0ken_memoryx-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17ee47477dc641d91597bcfb5f47a710fbac6454793a40e77329e73d21e3cbed
MD5 98eb3fb177392f9abc69f8b3a3cef1a3
BLAKE2b-256 2230448b0c65518963b5734b8f9ce94e119a3809b575ab93e2c43a2e3a1fb6b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page