From 873e5f201e9f2f774386ce653d050f3a88da3909 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 22 Aug 2024 18:20:12 +0530 Subject: [PATCH] feat: also serialize before saving --- lib/integrations/openai_base_service.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/integrations/openai_base_service.rb b/lib/integrations/openai_base_service.rb index 908ebf27e..5a1bae2d0 100644 --- a/lib/integrations/openai_base_service.rb +++ b/lib/integrations/openai_base_service.rb @@ -56,10 +56,9 @@ class Integrations::OpenaiBaseService def save_to_cache(response) return nil unless event_is_cacheable? - # if the response is a hash, save it as a json - # This allows the parsing to be simplified when getting from cache - response = response.to_json if response.is_a?(Hash) - Redis::Alfred.setex(cache_key, response) + # Serialize to JSON + # This makes parsing easy when response is a hash + Redis::Alfred.setex(cache_key, response.to_json) end def conversation