(select_response)
| 17 | return parsed_tools |
| 18 | |
| 19 | def extract_json(select_response): |
| 20 | select_response = select_response.replace('```json', '').replace('```', '') |
| 21 | start_index = select_response.find('{') |
| 22 | end_index = select_response.rfind('}') |
| 23 | if start_index != -1 and end_index != -1 and start_index < end_index: |
| 24 | json_str = select_response[start_index:end_index + 1] |
| 25 | return json.loads(json_str) |
| 26 | else: |
| 27 | return json.loads(select_response) |