agents.memory_v2.standalone_memory_agent_freeยถ

Standalone memory agent using only free resources (no API keys required).

This implementation shows how to build a functional memory agent without relying on paid APIs like OpenAI or Anthropic.

Classesยถ

FreeMemoryAgent

Memory agent using free embeddings and local storage.

Functionsยถ

test_free_memory_agent()

Test the free memory agent.

Module Contentsยถ

class agents.memory_v2.standalone_memory_agent_free.FreeMemoryAgent(user_id, storage_path=None, embedding_model='sentence-transformers/all-MiniLM-L6-v2', k_memories=5)ยถ

Memory agent using free embeddings and local storage.

This agent provides: - Memory storage with embeddings (using HuggingFace) - Similarity-based retrieval - Persistent storage to disk - No API keys required

Initialize the free memory agent.

Parameters:
  • user_id (str) โ€“ User identifier

  • storage_path (str | None) โ€“ Path to store memories (uses temp if None)

  • embedding_model (str) โ€“ HuggingFace model name for embeddings

  • k_memories (int) โ€“ Number of memories to retrieve

add_memory(content, memory_type=MemoryType.CONVERSATIONAL, importance=ImportanceLevel.MEDIUM, metadata=None)ยถ

Add a new memory.

Parameters:
  • content (str) โ€“ Memory content

  • memory_type (haive.agents.memory_v2.memory_state_original.MemoryType) โ€“ Type of memory

  • importance (haive.agents.memory_v2.memory_state_original.ImportanceLevel) โ€“ Importance level

  • metadata (dict[str, Any] | None) โ€“ Optional metadata

Returns:

Memory ID

Return type:

str

get_relevant_context(query, k=None)ยถ

Get relevant context for a query.

Parameters:
  • query (str) โ€“ Query to find context for

  • k (int | None) โ€“ Number of memories to include

Returns:

Formatted context string

Return type:

str

get_stats()ยถ

Get memory statistics.

Return type:

dict[str, Any]

async process_input(user_input)ยถ

Process user input - store if itโ€™s information, retrieve if itโ€™s a question.

Parameters:

user_input (str) โ€“ Userโ€™s input text

Returns:

Response string

Return type:

str

save()ยถ

Save the vector store to disk.

search_memories(query, k=None, memory_type=None, importance=None)ยถ

Search memories using similarity search.

Parameters:
  • query (str) โ€“ Search query

  • k (int | None) โ€“ Number of results (uses k_memories if None)

  • memory_type (haive.agents.memory_v2.memory_state_original.MemoryType | None) โ€“ Filter by memory type

  • importance (haive.agents.memory_v2.memory_state_original.ImportanceLevel | None) โ€“ Filter by importance

Returns:

List of memory results with scores

Return type:

list[dict[str, Any]]

async agents.memory_v2.standalone_memory_agent_free.test_free_memory_agent()ยถ

Test the free memory agent.