Skip to content

Commit d1488fb

Browse files
authored
Merge pull request #2495 from makermelissa/main
Fix Magic Storybook issue when ChatGPT uses fancy quotes
2 parents 41c8cfe + 8fe1d49 commit d1488fb

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Magic_AI_Storybook/story.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import threading
66
import sys
77
import os
8+
import re
89
import time
910
import argparse
1011
import math
@@ -102,6 +103,10 @@
102103
print("Please make sure PROMPT_FILE points to a valid file.")
103104
sys.exit(1)
104105

106+
def strip_fancy_quotes(text):
107+
text = re.sub(r"[\u2018\u2019]", "'", text)
108+
text = re.sub(r"[\u201C\u201D]", '"', text)
109+
return text
105110

106111
class Position(Enum):
107112
TOP = 0
@@ -668,7 +673,7 @@ def _sendchat(self, prompt):
668673
return None
669674

670675
# Send the heard text to ChatGPT and return the result
671-
return response # completion.choices[0].message.content
676+
return strip_fancy_quotes(response)
672677

673678

674679
def parse_args():

0 commit comments

Comments
 (0)