diff options
Diffstat (limited to 'cogs/assistant.py')
| -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 9926361..a91d027 100644 --- a/cogs/assistant.py +++ b/cogs/assistant.py | |||
| @@ -144,10 +144,13 @@ class Jarvis(commands.Cog): | |||
| 144 | def _parse_response(response_data): | 144 | def _parse_response(response_data): |
| 145 | content = response_data['choices'][0]['message']['content'] | 145 | content = response_data['choices'][0]['message']['content'] |
| 146 | inner_json_str = content.strip('```json\n').strip('```').strip() | 146 | inner_json_str = content.strip('```json\n').strip('```').strip() |
| 147 | inner_data = json.loads(inner_json_str) | 147 | try: |
| 148 | 148 | inner_data = json.loads(inner_json_str) | |
| 149 | response_message = inner_data['message'] | 149 | response_message = inner_data['message'] |
| 150 | action = inner_data['action'] | 150 | action = inner_data['action'] |
| 151 | except (json.JSONDecodeError, KeyError): | ||
| 152 | response_message = content | ||
| 153 | action = "none" | ||
| 151 | 154 | ||
| 152 | logger.info(response_message) | 155 | logger.info(response_message) |
| 153 | logger.info(action) | 156 | logger.info(action) |
