Skip to content

Commit

Permalink
cast client timestamp to datetime for ingestion
Browse files Browse the repository at this point in the history
  • Loading branch information
mdr223 committed Nov 7, 2023
1 parent 388e0f3 commit f8107a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions A2rchi/interfaces/chat_app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def insert_timing(self, message_id, timestamps):
self.cursor, self.conn = None, None


def __call__(self, message: List[str], conversation_id: int, is_refresh: bool, server_received_msg_ts: datetime, client_msg_ts: float, client_timeout: float):
def __call__(self, message: List[str], conversation_id: int, is_refresh: bool, server_received_msg_ts: datetime, client_sent_msg_ts: float, client_timeout: float):
"""
Execute the chat functionality.
"""
Expand Down Expand Up @@ -301,7 +301,7 @@ def __call__(self, message: List[str], conversation_id: int, is_refresh: bool, s

# guard call to LLM; if timestamp from message is more than timeout secs in the past;
# return error=True and do not generate response as the client will have timed out
if server_received_msg_ts.timestamp() - client_msg_ts > client_timeout:
if server_received_msg_ts.timestamp() - client_sent_msg_ts > client_timeout:
return None, None, None, True

# run chain to get result; limit users to 1000 queries per conversation; refreshing browser starts new conversation
Expand Down Expand Up @@ -437,7 +437,7 @@ def get_chat_response(self):

# store timing info for this message
timestamps['server_received_msg_ts'] = server_received_msg_ts
timestamps['client_sent_msg_ts'] = client_sent_msg_ts
timestamps['client_sent_msg_ts'] = datetime.fromtimestamp(client_sent_msg_ts)
self.chat.insert_timing(message_ids[-1], timestamps)

# otherwise return A2rchi's response to client
Expand Down

0 comments on commit f8107a7

Please sign in to comment.