Commit 1432229

benny-dou <60535774+benny-dou@users.noreply.github.com>
2026-05-19 06:15:01
chore(ai): early return if cache_day is 0
1 parent 2b1f5f0
Changed files (1)
src
ai
src/ai/texts/contexts.py
@@ -136,9 +136,11 @@ async def get_openai_response_contexts(client: Client, message: Message, openai_
         Returns:
             previous_response_id: str
         """
+        cache_day = openai_params["cache_day"]
+        if cache_day == 0:
+            return ""
         api_key = openai_params["api_key"]
         model_id = openai_params["model_id"]
-        cache_day = openai_params["cache_day"]
         key_hash = hashlib.sha256(api_key.encode()).hexdigest()
         tid = get_thread_id(msg)
         resp = await head_cf_r2(f"TTL/{cache_day}d/OpenAI/{msg.chat.id}/{msg.id}{'/' + str(tid) if tid else ''}/{model_id}/{key_hash}")