Skip to content

Instantly share code, notes, and snippets.

@tubaman
Created April 2, 2023 02:16
Show Gist options
  • Save tubaman/794441bcd7d65da2e1d5d134c477bb32 to your computer and use it in GitHub Desktop.
Save tubaman/794441bcd7d65da2e1d5d134c477bb32 to your computer and use it in GitHub Desktop.
Print out all the chatgpt responses in a conversation Use the devtools in your browser to download the json file from: https://chat.openai.com/backend-api/conversation/nnnnnnnnnnnnnn
#!/usr/bin/env python3
"""Print out all the chatgpt responses in a conversation
Use the devtools in your browser to download the json file from:
https://chat.openai.com/backend-api/conversation/nnnnnnnnnnnnnn
"""
import sys
import json
conversation_json_file_path = sys.argv[1]
conversation = json.load(open(conversation_json_file_path))
for mapping_id, mapping_data in conversation['mapping'].items():
try:
message = mapping_data['message']
except KeyError:
continue
if message['author']['role'] != 'assistant':
continue
content = message['content']
assert content['content_type'] == 'text'
for part in content['parts']:
print(part)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment