theminji commited on
Commit
c20e58c
·
verified ·
1 Parent(s): 734e5e6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -77,11 +77,11 @@ def index():
77
  ]
78
  )
79
 
80
- code_pattern = r"```python\s*(.*?)\s*```"
81
- code_match = re.search(code_pattern, ai_response.text, re.DOTALL)
82
- if not code_match:
83
  raise Exception("No python code block found in the AI response.")
84
- code = code_match.group(1)
85
 
86
 
87
  scene_match = re.search(r"class\s+(\w+)\(.*Scene.*\):", code)
 
77
  ]
78
  )
79
 
80
+ pattern = r"```python\s*(.*?)\s*```"
81
+ match = re.search(pattern, completion.choices[0].message.content, re.DOTALL)
82
+ if not match:
83
  raise Exception("No python code block found in the AI response.")
84
+ code = match.group(1)
85
 
86
 
87
  scene_match = re.search(r"class\s+(\w+)\(.*Scene.*\):", code)