Skip to content

Commit

Permalink
Add async methods to InMemoryCache (#17425)
Browse files Browse the repository at this point in the history
Add async methods to InMemoryCache
  • Loading branch information
cbornet authored Feb 13, 2024
1 parent 93472ee commit fb7552b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions libs/community/langchain_community/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,20 @@ def clear(self, **kwargs: Any) -> None:
"""Clear cache."""
self._cache = {}

async def alookup(self, prompt: str, llm_string: str) -> Optional[RETURN_VAL_TYPE]:
"""Look up based on prompt and llm_string."""
return self.lookup(prompt, llm_string)

async def aupdate(
self, prompt: str, llm_string: str, return_val: RETURN_VAL_TYPE
) -> None:
"""Update cache based on prompt and llm_string."""
self.update(prompt, llm_string, return_val)

async def aclear(self, **kwargs: Any) -> None:
"""Clear cache."""
self.clear()


Base = declarative_base()

Expand Down

0 comments on commit fb7552b

Please sign in to comment.