HuggingGPT (Shen et al., 2023) uses a language model to plan a set of subtasks, each handled by a specialist model. The subtasks form a dependency graph, and they must run in an order where each task's inputs are ready.
Implement topo_order(tasks), returning an execution order consistent with the dependencies, or None if the plan has a cycle.
Repeatedly run a task whose dependencies are all finished. Track how many dependencies each task still waits on, and stop with None if some task never becomes ready.
No results yet
Run your code to check it against the examples, or submit to run every test.