Skip to content

Commit

Permalink
remove print statement
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouyuf6741 committed Sep 7, 2024
1 parent eba767c commit e52aca9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,24 +252,22 @@ def get_tuple(self, config: RunnableConfig) -> Optional[CheckpointTuple]:
)

def get_writes_by_cache_key(self, cache_key: str) -> List[Any]:
"""Get checkpoint tuples from the database based on a cache key.
"""Get checkpoint writes from the database based on a cache key.
This method retrieves checkpoint tuples from the Postgres database based on the
This method retrieves checkpoint writes from the Postgres database based on the
provided cache key.
Args:
cache_key (str): The cache key to use for retrieving the checkpoints.
Returns:
List[CheckpointTuple]: A list of retrieved checkpoint tuples. Empty list if none found.
List[Any]: A list of retrieved checkpoint writes. Empty list if none found.
Examples:
>>> cache_key = "some_unique_cache_key"
>>> checkpoint_tuples = memory.get_writes_by_cache_key(cache_key)
>>> for tuple in checkpoint_tuples:
... print(tuple)
CheckpointTuple(...)
CheckpointTuple(...)
>>> checkpoint_writes = memory.get_writes_by_cache_key(cache_key)
>>> for write in checkpoint_writes:
... print(write)
"""
results = []
try:
Expand Down
10 changes: 5 additions & 5 deletions libs/checkpoint/langgraph/checkpoint/base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,25 +424,25 @@ def get_next_version(self, current: Optional[V], channel: ChannelProtocol) -> V:

def aget_writes_by_cache_key(
self, cache_key: str
) -> Optional[List[CheckpointTuple]]:
"""Get a checkpoint tuple from the database based on a cache key.
) -> Optional[List[Any]]:
"""Get a checkpoint writes from the database based on a cache key.
Args:
cache_key (str): The cache key to use for retrieving the checkpoint.
Returns:
List[CheckpointTuple]: A list of retrieved checkpoint tuples. Empty list if none found.
List[Any]: A list of retrieved checkpoint writes. Empty list if none found.
"""
raise NotImplementedError

def get_writes_by_cache_key(self, cache_key: str) -> Optional[List[Any]]:
"""Get a checkpoint tuple from the database based on a cache key.
"""Get a checkpoint writes from the database based on a cache key.
Args:
cache_key (str): The cache key to use for retrieving the checkpoint.
Returns:
List[CheckpointTuple]: A list of retrieved checkpoint tuples. Empty list if none found.
List[Any]: A list of retrieved checkpoint writes. Empty list if none found.
"""
pass

Expand Down
4 changes: 0 additions & 4 deletions libs/langgraph/tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ def custom_cache_key(input: Any, config: Optional[RunnableConfig] = None) -> str
"metadata": config.get("metadata", {}),
}
config_str = json.dumps(relevant_config, sort_keys=True)
print()
# Combine input and config strings
combined_str = f"{input_str}|{config_str}"
print("combined_str", combined_str)
# Generate a hash of the combined string
return hashlib.md5(combined_str.encode("utf-8")).hexdigest()

Expand Down Expand Up @@ -92,15 +90,13 @@ def analyzer_one(data: State) -> State:
def retriever_one(data: State) -> State:
nonlocal call_count
call_count += 1
print("increasing count", call_count)
return {"docs": ["doc1", "doc2"]}

def retriever_two(data: State) -> State:
time.sleep(0.1)
return {"docs": ["doc3", "doc4"]}

def qa(data: State) -> State:
print("qaaaa", data["docs"])
return {"answer": ",".join(data["docs"])}

def rewrite_query_then(data: State) -> Literal["retriever_two"]:
Expand Down

0 comments on commit e52aca9

Please sign in to comment.