Skip to content

Instantly share code, notes, and snippets.

@elijahbenizzy
Last active July 5, 2024 05:20
Show Gist options
  • Save elijahbenizzy/de7c403d31b7cc2581c464a014f79a30 to your computer and use it in GitHub Desktop.
Save elijahbenizzy/de7c403d31b7cc2581c464a014f79a30 to your computer and use it in GitHub Desktop.
graph_builder.py
graph = (
GraphBuilder()
.with_actions(
prompt=process_prompt,
check_safety=check_safety,
decide_mode=choose_mode,
generate_code=chat_response.bind(
prepend_prompt="Please respond with *only* code and no other text
"(at all) to the following",
),
... # more left out for brevity
)
.with_transitions(
("prompt", "check_safety", default),
("check_safety", "decide_mode", when(safe=True)),
("check_safety", "unsafe_response", default),
("decide_mode", "generate_code", when(mode="generate_code")),
... # more left out for brevity
)
.build()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment