-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallel_utils.py
More file actions
22 lines (18 loc) · 867 Bytes
/
parallel_utils.py
File metadata and controls
22 lines (18 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import json
from concurrent.futures import ThreadPoolExecutor, as_completed
def assess_wrapper(mod_prompt, function_info, client):
# Local import to avoid circular dependency
from ast_utils import assess_function_relevance
is_relevant = assess_function_relevance(mod_prompt, function_info, client)
return function_info["name"], function_info.get("calls", []), is_relevant
def parallel_assess_functions(mod_prompt, functions, client):
results = []
with ThreadPoolExecutor() as executor:
futures = [executor.submit(assess_wrapper, mod_prompt, func, client) for func in functions]
for future in as_completed(futures):
try:
results.append(future.result())
except Exception as e:
print("[DEBUG] Exception in parallel assess:", e)
exit()
return results