MCPcopy Create free account
hub / github.com/RUC-NLPIR/WebThinker / parse_query_plan

Function parse_query_plan

scripts/run_naive_rag.py:129–143  ·  view source on GitHub ↗

Parse the query plan response to extract sub-queries

(response: str)

Source from the content-addressed store, hash-verified

127 return responses
128
129async 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
145async def main_async():
146 args = parse_args()

Callers 1

main_asyncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected