Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,15 +109,21 @@ Start each section with its number and title."""
|
|
| 109 |
response_start += len(code_to_analyze)
|
| 110 |
ai_response = full_response[response_start:].strip()
|
| 111 |
|
| 112 |
-
#
|
| 113 |
-
|
| 114 |
-
if
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
return ai_response
|
| 118 |
else:
|
| 119 |
return "Error: Unable to extract the AI's response. Here's the full output:\n\n" + full_response
|
| 120 |
|
|
|
|
| 121 |
# Create Gradio interface
|
| 122 |
iface = gr.Interface(
|
| 123 |
fn=code_review,
|
|
|
|
| 109 |
response_start += len(code_to_analyze)
|
| 110 |
ai_response = full_response[response_start:].strip()
|
| 111 |
|
| 112 |
+
# Find the second occurrence of "1. Understanding of the code"
|
| 113 |
+
first_occurrence = ai_response.find("1. Understanding of the code")
|
| 114 |
+
if first_occurrence != -1:
|
| 115 |
+
second_occurrence = ai_response.find("1. Understanding of the code", first_occurrence + 1)
|
| 116 |
+
if second_occurrence != -1:
|
| 117 |
+
ai_response = ai_response[second_occurrence:]
|
| 118 |
+
else:
|
| 119 |
+
# If we can't find a second occurrence, start from the first one
|
| 120 |
+
ai_response = ai_response[first_occurrence:]
|
| 121 |
|
| 122 |
return ai_response
|
| 123 |
else:
|
| 124 |
return "Error: Unable to extract the AI's response. Here's the full output:\n\n" + full_response
|
| 125 |
|
| 126 |
+
|
| 127 |
# Create Gradio interface
|
| 128 |
iface = gr.Interface(
|
| 129 |
fn=code_review,
|