Construct and build the MapCoder graph for one model + (k, t) config.
(model, k: int = 3, t: int = 3)
| 72 | |
| 73 | |
| 74 | def build_graph(model, k: int = 3, t: int = 3) -> RootGraph: |
| 75 | """Construct and build the MapCoder graph for one model + (k, t) config.""" |
| 76 | |
| 77 | # ===================================================================== |
| 78 | # Agent templates |
| 79 | # ===================================================================== |
| 80 | RetrievalT = make_retrieval_agent_template(model) |
| 81 | PlanGenT = make_plan_gen_template(model) |
| 82 | ConfidenceT = make_confidence_eval_template(model) |
| 83 | CodingT = make_coding_agent_template(model) |
| 84 | DebugT = make_debug_agent_template(model) |
| 85 | |
| 86 | # ===================================================================== |
| 87 | # CustomNode templates |
| 88 | # ===================================================================== |
| 89 | RetrievalParserT = NodeTemplate( |
| 90 | CustomNode, |
| 91 | forward=retrieval_parser_forward, |
| 92 | pull_keys={"problem": "", "sample_io": "", "language": ""}, |
| 93 | ) |
| 94 | |
| 95 | ExemplarPickerT = NodeTemplate( |
| 96 | CustomNode, |
| 97 | forward=exemplar_picker_forward, |
| 98 | pull_keys={ |
| 99 | "exemplars": "", |
| 100 | "algorithm": "", |
| 101 | "problem": "", |
| 102 | "sample_io": "", |
| 103 | "language": "", |
| 104 | "current_iteration": "", |
| 105 | }, |
| 106 | # Forward pickers stringify `sample_io` for Agent prompts. We MUST |
| 107 | # NOT push that stringified form back into the parent Loop's attrs, |
| 108 | # otherwise the Tester CustomNode (which pulls `sample_io` from |
| 109 | # attrs) would receive a string instead of the list[dict] it needs. |
| 110 | push_keys={}, |
| 111 | ) |
| 112 | |
| 113 | PlanSorterT = NodeTemplate( |
| 114 | CustomNode, |
| 115 | forward=plan_sorter_forward, |
| 116 | pull_keys={ |
| 117 | "problem": "", |
| 118 | "algorithm": "", |
| 119 | "sample_io": "", |
| 120 | "language": "", |
| 121 | }, |
| 122 | ) |
| 123 | |
| 124 | PlanPickerT = NodeTemplate( |
| 125 | CustomNode, |
| 126 | forward=plan_picker_forward, |
| 127 | pull_keys={ |
| 128 | "sorted_plans": "", |
| 129 | "problem": "", |
| 130 | "algorithm": "", |
| 131 | "sample_io": "", |