Created
February 7, 2024 03:14
-
-
Save hwchase17/4e74dcda13e4545e93d26e2047567e0f to your computer and use it in GitHub Desktop.
Revisions
-
hwchase17 created this gist
Feb 7, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ class AgentState(TypedDict): code: str tests: str errors: Optional[str] def initial_writer(state): ... return {"code": ..., "tests": ...} def run_tests(state): ... # error = None if no errors return {"errors": error} def reprogram(state): ... return {"code": ...} workflow = StateGraph(AgentState) workflow.add_node("initial_writer", initial_writer) workflow.add_node("execute_tests", run_tests) workflow.add_node("reprogram", reprogram) workflow.set_entry_point("initial_writer") workflow.add_conditional_edges( "execute_tests", should_continue, { "continue": "reprogram", "end": END } ) workflow.add_edge('initial_writer', 'execute_tests') workflow.add_edge('reprogram', 'execute_tests') graph = workflow.compile()