File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
llm-service/app/services/chat_history Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ class RagStudioChatMessage(BaseModel):
6464
6565
6666class ChatHistoryManager (metaclass = ABCMeta ):
67+ def __init__ (self ):
68+ pass
69+
6770 @abstractmethod
6871 def retrieve_chat_history (self , session_id : int ) -> list [RagStudioChatMessage ]:
6972 pass
Original file line number Diff line number Diff line change 3535# BUSINESS ADVANTAGE OR UNAVAILABILITY, OR LOSS OR CORRUPTION OF
3636# DATA.
3737#
38-
38+ import functools
3939import json
4040import logging
4141from typing import List
5757class S3ChatHistoryManager (ChatHistoryManager ):
5858 """Chat history manager that uses S3 for storage."""
5959
60- def __init__ (self , bucket_name : str = settings .document_bucket ):
61- self .bucket_name = bucket_name
60+ def __init__ (self ):
61+ super ().__init__ ()
62+ self .bucket_name = settings .document_bucket
6263 self .bucket_prefix = settings .document_bucket_prefix
63- self ._s3_client : S3Client | None = None
6464
65- @property
65+ @functools . cached_property
6666 def s3_client (self ) -> S3Client :
6767 """Lazy initialization of S3 client."""
68- if self ._s3_client is None :
69- session : Session = boto3 .session .Session ()
70- self ._s3_client = session .client ("s3" )
71- return self ._s3_client
68+ session : Session = boto3 .session .Session ()
69+ return session .client ("s3" )
7270
7371 def _get_s3_key (self , session_id : int ) -> str :
7472 """Build the S3 key for a session's chat history."""
You can’t perform that action at this time.
0 commit comments