MCPcopy Create free account
hub / github.com/MemTensor/MemOS / run_user_session

Function run_user_session

examples/basic_modules/neo4j_example.py:385–533  ·  view source on GitHub ↗
(
    user_name: str,
    db_name: str,
    topic_text: str,
    concept_texts: list[str],
    fact_texts: list[str],
    community: bool = False,
)

Source from the content-addressed store, hash-verified

383
384
385def run_user_session(
386 user_name: str,
387 db_name: str,
388 topic_text: str,
389 concept_texts: list[str],
390 fact_texts: list[str],
391 community: bool = False,
392):
393 print(f"\n=== {user_name} starts building their memory graph ===")
394
395 # Manually initialize correct GraphDB class
396 if community:
397 config = GraphDBConfigFactory(
398 backend="neo4j-community",
399 config={
400 "uri": NEO4J_URI,
401 "user": NEO4J_USER,
402 "password": NEO4J_PASSWORD,
403 "db_name": db_name,
404 "user_name": user_name,
405 "use_multi_db": False,
406 "auto_create": False,
407 "embedding_dimension": EMBEDDING_DIMENSION,
408 "vec_config": {
409 "backend": "qdrant",
410 "config": {
411 "collection_name": "neo4j_vec_db",
412 "vector_dimension": EMBEDDING_DIMENSION,
413 "distance_metric": "cosine",
414 "host": QDRANT_HOST,
415 "port": QDRANT_PORT,
416 },
417 },
418 },
419 )
420 else:
421 config = GraphDBConfigFactory(
422 backend="neo4j",
423 config={
424 "uri": NEO4J_URI,
425 "user": NEO4J_USER,
426 "password": NEO4J_PASSWORD,
427 "db_name": db_name,
428 "user_name": user_name,
429 "use_multi_db": False,
430 "auto_create": True,
431 "embedding_dimension": EMBEDDING_DIMENSION,
432 },
433 )
434 graph = GraphStoreFactory.from_config(config)
435
436 # Start with a clean slate for this user
437 graph.clear()
438
439 now = datetime.utcnow().isoformat()
440
441 # === Step 1: Create a root topic node (e.g., user's research focus) ===
442 topic = TextualMemoryItem(

Callers 1

Calls 15

TextualMemoryItemClass · 0.90
embed_memory_itemFunction · 0.85
model_dumpMethod · 0.80
clearMethod · 0.65
from_configMethod · 0.45
add_nodeMethod · 0.45
add_edgeMethod · 0.45
search_by_embeddingMethod · 0.45
get_nodeMethod · 0.45
get_neighbors_by_tagMethod · 0.45

Tested by

no test coverage detected