Skip to main content

MemHQ adapter for LlamaIndex — chat memory and retriever backed by MemHQ.

Project description

memhq-llamaindex

MemHQ adapter for LlamaIndex (Python). Drop-in chat memory and retriever backed by the MemHQ hosted API. Sync and async both supported.

Install

pip install memhq-llamaindex

Quickstart — Chat memory

import os
from llama_index.llms.openai import OpenAI
from llama_index.core.agent import ReActAgent

from memhq_llamaindex import MemHQMemory

memory = MemHQMemory(
    api_key=os.environ["MEMHQ_API_KEY"],
    session_id="conv_42",
    user_id="user_42",
)

agent = ReActAgent.from_tools(
    tools=[],
    llm=OpenAI(model="gpt-4o-mini"),
    memory=memory,
)

reply = agent.chat("What's my favorite coffee order?")

Quickstart — Retriever

from llama_index.core.query_engine import RetrieverQueryEngine
from memhq_llamaindex import MemHQRetriever

retriever = MemHQRetriever(
    api_key=os.environ["MEMHQ_API_KEY"],
    user_id="user_42",
    limit=8,
)

engine = RetrieverQueryEngine.from_args(retriever)
answer = engine.query("Summarize pricing discussion")

Configuration

Argument Description
api_key MemHQ project API key. Falls back to MEMHQ_API_KEY.
user_id External user id. Required.
session_id Thread anchor for the memory adapter.
recall_limit Memories surfaced per memory read. Default 10.
limit Memories returned per retriever query. Default 10.
mode "hybrid" (default), "vector", or "lexical".
base_url Override the API base.

Reference

Full reference: https://docs.memhq.ai/sdks/llamaindex-py

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

memhq_llamaindex-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

memhq_llamaindex-0.1.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file memhq_llamaindex-0.1.0.tar.gz.

File metadata

  • Download URL: memhq_llamaindex-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for memhq_llamaindex-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8d45ea545219775ee785b7485daab38f48f24d9f31b88c18ae3b20b044768f56
MD5 1fbb094f6708f02c483393482eae761c
BLAKE2b-256 a4a1161b6253744304b9e0049da359328048b74bb1aafb9855b744746262876f

See more details on using hashes here.

File details

Details for the file memhq_llamaindex-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for memhq_llamaindex-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1cbdd1a9549c77419442cde1cf9e825f80d1820e9fd393e137f14de2775d4193
MD5 29f50da0784674d751ccb813d0e2accb
BLAKE2b-256 9166c33f1dac3b27bdcb8e2725a1075d53d1c46b9210a3a9a65f85e46e72168e

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