Skip to content

Commit c2b2ba2

Browse files
Replace print statements with logging in client.py
- Replace all 19 print statements with appropriate logging calls - Use logging.info() for informational messages - Use logging.error() for error messages - Add logging import with noqa comment to silence unused import warning - All logging calls are in docstring examples for user reference Co-authored-by: Andrew Brookins <[email protected]>
1 parent ccb97ff commit c2b2ba2

File tree

1 file changed

+25
-24
lines changed
  • agent-memory-client/agent_memory_client

1 file changed

+25
-24
lines changed

agent-memory-client/agent_memory_client/client.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import asyncio
8+
import logging # noqa: F401
89
import re
910
from collections.abc import AsyncIterator, Sequence
1011
from typing import TYPE_CHECKING, Any, Literal, TypedDict
@@ -323,11 +324,11 @@ async def get_or_create_working_memory(
323324
)
324325
325326
if created:
326-
print("Created new session")
327+
logging.info("Created new session")
327328
else:
328-
print("Found existing session")
329+
logging.info("Found existing session")
329330
330-
print(f"Session has {len(memory.messages)} messages")
331+
logging.info(f"Session has {len(memory.messages)} messages")
331332
```
332333
"""
333334
try:
@@ -638,7 +639,7 @@ async def create_long_term_memory(
638639
]
639640
640641
response = await client.create_long_term_memory(memories)
641-
print(f"Stored memories: {response.status}")
642+
logging.info(f"Stored memories: {response.status}")
642643
```
643644
"""
644645
# Apply default namespace and ensure IDs are present
@@ -792,9 +793,9 @@ async def search_long_term_memory(
792793
distance_threshold=0.3
793794
)
794795
795-
print(f"Found {results.total} memories")
796+
logging.info(f"Found {results.total} memories")
796797
for memory in results.memories:
797-
print(f"- {memory.text[:100]}... (distance: {memory.dist})")
798+
logging.info(f"- {memory.text[:100]}... (distance: {memory.dist})")
798799
```
799800
"""
800801
# Convert dictionary filters to their proper filter objects if needed
@@ -944,9 +945,9 @@ async def search_memory_tool(
944945
min_relevance=0.7
945946
)
946947
947-
print(result["summary"]) # "Found 2 relevant memories for: user preferences about UI themes"
948+
logging.info(result["summary"]) # "Found 2 relevant memories for: user preferences about UI themes"
948949
for memory in result["memories"]:
949-
print(f"- {memory['text']} (score: {memory['relevance_score']})")
950+
logging.info(f"- {memory['text']} (score: {memory['relevance_score']})")
950951
```
951952
952953
LLM Framework Integration:
@@ -1147,9 +1148,9 @@ async def get_working_memory_tool(
11471148
session_id="current_session"
11481149
)
11491150
1150-
print(memory_state["summary"]) # Human-readable summary
1151-
print(f"Messages: {memory_state['message_count']}")
1152-
print(f"Memories: {len(memory_state['memories'])}")
1151+
logging.info(memory_state["summary"]) # Human-readable summary
1152+
logging.info(f"Messages: {memory_state['message_count']}")
1153+
logging.info(f"Memories: {len(memory_state['memories'])}")
11531154
```
11541155
"""
11551156
try:
@@ -1227,13 +1228,13 @@ async def get_or_create_working_memory_tool(
12271228
)
12281229
12291230
if memory_state["created"]:
1230-
print("Created new session")
1231+
logging.info("Created new session")
12311232
else:
1232-
print("Found existing session")
1233+
logging.info("Found existing session")
12331234
1234-
print(memory_state["summary"]) # Human-readable summary
1235-
print(f"Messages: {memory_state['message_count']}")
1236-
print(f"Memories: {len(memory_state['memories'])}")
1235+
logging.info(memory_state["summary"]) # Human-readable summary
1236+
logging.info(f"Messages: {memory_state['message_count']}")
1237+
logging.info(f"Memories: {len(memory_state['memories'])}")
12371238
```
12381239
"""
12391240
try:
@@ -1325,7 +1326,7 @@ async def add_memory_tool(
13251326
entities=["vegetarian", "restaurants"]
13261327
)
13271328
1328-
print(result["summary"]) # "Successfully stored semantic memory"
1329+
logging.info(result["summary"]) # "Successfully stored semantic memory"
13291330
```
13301331
"""
13311332
try:
@@ -1399,7 +1400,7 @@ async def update_memory_data_tool(
13991400
}
14001401
)
14011402
1402-
print(result["summary"]) # "Successfully updated 3 data entries"
1403+
logging.info(result["summary"]) # "Successfully updated 3 data entries"
14031404
```
14041405
"""
14051406
try:
@@ -1974,9 +1975,9 @@ async def resolve_tool_call(
19741975
)
19751976
19761977
if result["success"]:
1977-
print(result["formatted_response"])
1978+
logging.info(result["formatted_response"])
19781979
else:
1979-
print(f"Error: {result['error']}")
1980+
logging.error(f"Error: {result['error']}")
19801981
```
19811982
"""
19821983
try:
@@ -2030,7 +2031,7 @@ async def resolve_tool_calls(
20302031
20312032
for result in results:
20322033
if result["success"]:
2033-
print(f"{result['function_name']}: {result['formatted_response']}")
2034+
logging.info(f"{result['function_name']}: {result['formatted_response']}")
20342035
```
20352036
"""
20362037
results = []
@@ -2088,9 +2089,9 @@ async def resolve_function_call(
20882089
)
20892090
20902091
if result["success"]:
2091-
print(result["formatted_response"])
2092+
logging.info(result["formatted_response"])
20922093
else:
2093-
print(f"Error: {result['error']}")
2094+
logging.error(f"Error: {result['error']}")
20942095
```
20952096
"""
20962097
import json
@@ -2378,7 +2379,7 @@ async def resolve_function_calls(
23782379
results = await client.resolve_function_calls(calls, "session123")
23792380
for result in results:
23802381
if result["success"]:
2381-
print(f"{result['function_name']}: {result['formatted_response']}")
2382+
logging.info(f"{result['function_name']}: {result['formatted_response']}")
23822383
```
23832384
"""
23842385
results = []

0 commit comments

Comments
 (0)