Rulga commited on
Commit
5a536b8
·
1 Parent(s): 8f6d874

Update chat history schema to use 'history' key instead of 'messages'

Browse files
config/settings.py CHANGED
@@ -254,7 +254,7 @@ RATING_FIELDS = {
254
  CHAT_HISTORY_SCHEMA = {
255
  "conversation_id": str,
256
  "timestamp": str, # ISO format
257
- "messages": [
258
  {
259
  "role": str, # "user" or "assistant"
260
  "content": str,
 
254
  CHAT_HISTORY_SCHEMA = {
255
  "conversation_id": str,
256
  "timestamp": str, # ISO format
257
+ "history": [
258
  {
259
  "role": str, # "user" or "assistant"
260
  "content": str,
src/analytics/chat_evaluator.py CHANGED
@@ -96,7 +96,7 @@ class ChatEvaluator:
96
  )
97
  with open(content, 'r', encoding='utf-8') as f:
98
  chat_data = json.load(f)
99
- if isinstance(chat_data, dict) and 'messages' in chat_data:
100
  histories.append(chat_data)
101
  else:
102
  logger.warning(f"Invalid chat history format in {file}")
@@ -118,7 +118,7 @@ class ChatEvaluator:
118
  qa_pairs = []
119
 
120
  for history in histories:
121
- messages = history.get('messages', [])
122
  current_question = None
123
 
124
  for msg in messages:
@@ -154,7 +154,7 @@ class ChatEvaluator:
154
  for chat in chat_data:
155
  conversation_id = chat.get("conversation_id", "unknown")
156
  timestamp = chat.get("timestamp", "")
157
- messages = chat.get("messages", [])
158
 
159
  # Find user-assistant pairs in messages
160
  for i in range(len(messages) - 1):
 
96
  )
97
  with open(content, 'r', encoding='utf-8') as f:
98
  chat_data = json.load(f)
99
+ if isinstance(chat_data, dict) and 'history' in chat_data:
100
  histories.append(chat_data)
101
  else:
102
  logger.warning(f"Invalid chat history format in {file}")
 
118
  qa_pairs = []
119
 
120
  for history in histories:
121
+ messages = history.get('history', [])
122
  current_question = None
123
 
124
  for msg in messages:
 
154
  for chat in chat_data:
155
  conversation_id = chat.get("conversation_id", "unknown")
156
  timestamp = chat.get("timestamp", "")
157
+ messages = chat.get("history", [])
158
 
159
  # Find user-assistant pairs in messages
160
  for i in range(len(messages) - 1):