59
59
from ....services .chat .suggested_questions import generate_suggested_questions
60
60
from ....services .chat_history .chat_history_manager import (
61
61
RagStudioChatMessage ,
62
- chat_history_manager ,
62
+ get_chat_history_manager ,
63
63
)
64
64
from ....services .chat_history .paginator import paginate
65
65
from ....services .metadata_apis import session_metadata_api
@@ -142,7 +142,7 @@ class RagStudioChatHistoryResponse(BaseModel):
142
142
def chat_history (
143
143
session_id : int , limit : Optional [int ] = None , offset : Optional [int ] = None
144
144
) -> RagStudioChatHistoryResponse :
145
- results = chat_history_manager .retrieve_chat_history (session_id = session_id )
145
+ results = get_chat_history_manager () .retrieve_chat_history (session_id = session_id )
146
146
147
147
paginated_results , previous_id , next_id = paginate (results , limit , offset )
148
148
return RagStudioChatHistoryResponse (
@@ -158,8 +158,8 @@ def chat_history(
158
158
)
159
159
@exceptions .propagates
160
160
def get_message_by_id (session_id : int , message_id : str ) -> RagStudioChatMessage :
161
- results : list [RagStudioChatMessage ] = chat_history_manager . retrieve_chat_history (
162
- session_id = session_id
161
+ results : list [RagStudioChatMessage ] = (
162
+ get_chat_history_manager (). retrieve_chat_history ( session_id = session_id )
163
163
)
164
164
for message in results :
165
165
if message .id == message_id :
@@ -175,14 +175,14 @@ def get_message_by_id(session_id: int, message_id: str) -> RagStudioChatMessage:
175
175
)
176
176
@exceptions .propagates
177
177
def clear_chat_history (session_id : int ) -> str :
178
- chat_history_manager .clear_chat_history (session_id = session_id )
178
+ get_chat_history_manager () .clear_chat_history (session_id = session_id )
179
179
return "Chat history cleared."
180
180
181
181
182
182
@router .delete ("" , summary = "Deletes the requested session." )
183
183
@exceptions .propagates
184
184
def delete_session (session_id : int ) -> str :
185
- chat_history_manager .delete_chat_history (session_id = session_id )
185
+ get_chat_history_manager () .delete_chat_history (session_id = session_id )
186
186
return "Chat history deleted."
187
187
188
188
0 commit comments