Spaces:
Sleeping
Sleeping
Update openai_client.py
Browse files- openai_client.py +14 -1
openai_client.py
CHANGED
@@ -27,7 +27,20 @@ def get_code_review_response(prompt, max_tokens=1000):
|
|
27 |
},
|
28 |
],
|
29 |
)
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
except Exception as e:
|
32 |
return "Sorry, an error occurred while generating your idea. Please try again later."
|
33 |
|
|
|
27 |
},
|
28 |
],
|
29 |
)
|
30 |
+
# Extract feedback text from the response
|
31 |
+
review = response.text if hasattr(response, "text") else str(response)
|
32 |
+
|
33 |
+
# Check if feedback is a Message object and extract text if necessary
|
34 |
+
if hasattr(response, "content") and isinstance(response.content, list):
|
35 |
+
review = "\n\n".join(
|
36 |
+
[
|
37 |
+
text_block.text
|
38 |
+
for text_block in response.content
|
39 |
+
if hasattr(text_block, "text")
|
40 |
+
]
|
41 |
+
)
|
42 |
+
|
43 |
+
return review
|
44 |
except Exception as e:
|
45 |
return "Sorry, an error occurred while generating your idea. Please try again later."
|
46 |
|