ndurner commited on
Commit
86a3809
1 Parent(s): 6647f9f

backwards compat

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -178,10 +178,15 @@ def import_history(history, file):
178
  # Deserialize the JSON content
179
  import_data = json.loads(content)
180
 
181
- new_history = import_data.get('history', history) # Use existing history if not provided
182
- new_system_prompt = import_data.get('system_prompt', '') # Default to empty if not provided
 
 
 
 
 
183
 
184
- return new_history, new_system_prompt
185
 
186
  with gr.Blocks() as demo:
187
  gr.Markdown("# Anthropic™️ Claude™️ Chat (Nils' Version™️)")
 
178
  # Deserialize the JSON content
179
  import_data = json.loads(content)
180
 
181
+ # Check if 'history' key exists for backward compatibility
182
+ if 'history' in import_data:
183
+ history = import_data['history']
184
+ system_prompt.value = import_data.get('system_prompt', '') # Set default if not present
185
+ else:
186
+ # Assume it's an old format with only history data
187
+ history = import_data
188
 
189
+ return history, system_prompt.value # Return system prompt value to be set in the UI
190
 
191
  with gr.Blocks() as demo:
192
  gr.Markdown("# Anthropic™️ Claude™️ Chat (Nils' Version™️)")