From c82d7a908e170b830455d22d97e472110a97f05d Mon Sep 17 00:00:00 2001 From: Benjoyo Date: Mon, 29 Apr 2024 17:13:49 +0200 Subject: [PATCH] fix caching in question_answering.py --- .../bpm_ai_core/question_answering/question_answering.py | 5 +++-- bpm-ai-core/pyproject.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bpm-ai-core/bpm_ai_core/question_answering/question_answering.py b/bpm-ai-core/bpm_ai_core/question_answering/question_answering.py index 9dfb1e4..ddff976 100644 --- a/bpm-ai-core/bpm_ai_core/question_answering/question_answering.py +++ b/bpm-ai-core/bpm_ai_core/question_answering/question_answering.py @@ -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, diff --git a/bpm-ai-core/pyproject.toml b/bpm-ai-core/pyproject.toml index 645386f..069f592 100644 --- a/bpm-ai-core/pyproject.toml +++ b/bpm-ai-core/pyproject.toml @@ -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 "] repository = "https://github.com/holunda-io/bpm-ai"