Skip to content

Commit

Permalink
bugfix: decode.py
Browse files Browse the repository at this point in the history
  • Loading branch information
V-know committed May 17, 2023
1 parent 29039bc commit 058783a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
with open("main.log") as f:
i = 1
for line in f.readlines():
l = json.loads(line)
result = l['choices'][0].get('text') if l['choices'][0].get('text') else l['choices'][0]['message']['content']
print(f"{l['user']['name']} --- {l['user']['id']} --- {l['prompt']} --- {result}")
print()
print(i, "---------------------------------------------------------------------------------------------------")
print()
i+=1
try:
l = json.loads(line)
result = l['choices'][0].get('text') if l['choices'][0].get('text') else l['choices'][0]['message']['content']
print(f"{l['user']['name']} --- {l['user']['id']} --- {l['prompt']} --- {result}")
print()
print(i, "---------------------------------------------------------------------------------------------------")
print()
i+=1
except (json.decoder.JSONDecodeError, KeyError):
continue

0 comments on commit 058783a

Please sign in to comment.