diff options
Diffstat (limited to '')
| -rw-r--r-- | cogs/assistant.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/cogs/assistant.py b/cogs/assistant.py index 6cc1b03..a89c356 100644 --- a/cogs/assistant.py +++ b/cogs/assistant.py | |||
| @@ -146,10 +146,13 @@ class Jarvis(commands.Cog): | |||
| 146 | def _parse_response(response_data): | 146 | def _parse_response(response_data): |
| 147 | content = response_data['choices'][0]['message']['content'] | 147 | content = response_data['choices'][0]['message']['content'] |
| 148 | inner_json_str = content.strip('```json\n').strip('```').strip() | 148 | inner_json_str = content.strip('```json\n').strip('```').strip() |
| 149 | inner_data = json.loads(inner_json_str) | 149 | try: |
| 150 | 150 | inner_data = json.loads(inner_json_str) | |
| 151 | response_message = inner_data['message'] | 151 | response_message = inner_data['message'] |
| 152 | action = inner_data['action'] | 152 | action = inner_data['action'] |
| 153 | except (json.JSONDecodeError, KeyError): | ||
| 154 | response_message = content | ||
| 155 | action = "none" | ||
| 153 | 156 | ||
| 154 | logger.info(response_message) | 157 | logger.info(response_message) |
| 155 | logger.info(action) | 158 | logger.info(action) |
