Skip to content

Commit

Permalink
fix caching in question_answering.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjoyo committed Apr 29, 2024
1 parent 78ffd94 commit c82d7a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ async def _do_answer(
) -> QAResult:
pass

async def _cache_key(self, context_str_or_blob: str | Blob, *args, **kwargs) -> str:
@staticmethod
async def _cache_key(context_str_or_blob: str | Blob, *args, **kwargs) -> str:
if isinstance(context_str_or_blob, str):
return f"context={context_str_or_blob}"
else: # Blob
return f"blob_bytes={await context_str_or_blob.as_bytes()}"

@cached(exclude=["context_str_or_blob"])
@cached(exclude=["context_str_or_blob"], key_func=_cache_key)
@span(name="qa")
async def answer(
self,
Expand Down
2 changes: 1 addition & 1 deletion bpm-ai-core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "bpm-ai-core"
version = "2.6.1"
version = "2.6.2"
description = "Core AI abstractions and helpers."
authors = ["Bennet Krause <[email protected]>"]
repository = "https://github.com/holunda-io/bpm-ai"
Expand Down

0 comments on commit c82d7a9

Please sign in to comment.