Fix Flask template discovery#2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @staticmethod | ||
| def _parse_response(response: Any) -> Dict[str, Any]: | ||
| try: | ||
| return json.loads(response.output[0].content[0].text) | ||
| except (KeyError, AttributeError, IndexError, json.JSONDecodeError) as exc: | ||
| raise RuntimeError('Unable to parse response from ChatGPT.') from exc |
There was a problem hiding this comment.
Parse structured response from wrong field
When generate_business_insights requests a JSON schema response, the OpenAI SDK already places the parsed object under response.output[0].content[0].parsed (or an equivalent json attribute). The code instead indexes into .text and runs json.loads, which is None for JSON‑schema responses, so every successful call raises the RuntimeError('Unable to parse response from ChatGPT.') path and the predictor view never renders results. Use the SDK’s structured field instead of .text to avoid the unconditional failure.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task