Parse the query plan response to extract sub-queries
(response: str)
| 127 | return responses |
| 128 | |
| 129 | async def parse_query_plan(response: str) -> List[str]: |
| 130 | """Parse the query plan response to extract sub-queries""" |
| 131 | try: |
| 132 | # Try to find and parse JSON content |
| 133 | match = re.search(r'\{.*\}', response, re.DOTALL) |
| 134 | if match: |
| 135 | json_content = json.loads(match.group()) |
| 136 | if 'query_plan' in json_content: |
| 137 | query_plan = json_content['query_plan'][:3] # Take first 3 queries |
| 138 | # print('query_plan', query_plan) |
| 139 | return query_plan |
| 140 | except: |
| 141 | pass |
| 142 | # Fallback: return empty list if parsing fails |
| 143 | return [] |
| 144 | |
| 145 | async def main_async(): |
| 146 | args = parse_args() |