MCPcopy Create free account
hub / github.com/AQ-MedAI/MedMemoryBench / example_basic_usage

Function example_basic_usage

methods/MIRIX/samples/new_client_example.py:17–69  ·  view source on GitHub ↗

Basic example of the new MirixClient API.

()

Source from the content-addressed store, hash-verified

15
16
17async def example_basic_usage():
18 """Basic example of the new MirixClient API."""
19 print("=" * 80)
20 print("Example: New MirixClient API")
21 print("=" * 80)
22
23 os.environ.setdefault("MIRIX_API_KEY", "your-api-key")
24
25 client = await MirixClient.create(
26 client_id="test",
27 org_id="demo-org",
28 )
29
30 print("\n1. Loading configuration...")
31 config = load_config("mirix/configs/mirix.yaml")
32
33 print("\n2. Initializing meta agent...")
34 meta_agent = await client.initialize_meta_agent(config=config)
35 print(f" Meta agent initialized: {meta_agent.id}")
36
37 print("\n3. Adding conversation to memory...")
38 result = await client.add(
39 user_id="user_123",
40 messages=[
41 {
42 "role": "user",
43 "content": [{"type": "text", "text": "I went to have dinner with my wife at Sichuan Chef"}],
44 },
45 {"role": "assistant", "content": [{"type": "text", "text": "That sounds great! How was the food?"}]},
46 ],
47 )
48 print(f" Memory added: {result['success']}")
49
50 print("\n4. Retrieving memories with conversation context...")
51 memories = await client.retrieve_with_conversation(
52 user_id="user_123",
53 messages=[
54 {
55 "role": "user",
56 "content": [{"type": "text", "text": "I want to go to the place I went with my wife again."}],
57 }
58 ],
59 )
60 print(f" Retrieved {len(memories.get('memories', {}).get('episodic', []))} episodic memories")
61
62 print("\n5. Retrieving memories by topic...")
63 topic_memories = await client.retrieve_with_topic(user_id="user_123", topic="dinner")
64 print(f" Topic search completed: {topic_memories['success']}")
65
66 print("\n6. Searching memories...")
67 search_results = await client.search(user_id="user_123", query="restaurants", limit=5)
68 print(f" Search completed: {search_results['success']}")
69 print(f" Found {search_results['count']} results")
70
71
72async def example_with_config_dict():

Callers 1

run_allFunction · 0.85

Calls 9

load_configFunction · 0.90
initialize_meta_agentMethod · 0.80
retrieve_with_topicMethod · 0.80
searchMethod · 0.65
setdefaultMethod · 0.45
createMethod · 0.45
addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected