Last active
August 14, 2024 22:21
-
-
Save elijahbenizzy/8c542d1aa291fc19669ae01c7ba82ffe to your computer and use it in GitHub Desktop.
This file contains 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 characters
app = ( | |
ApplicationBuilder() | |
.with_entrypoint("prompt") | |
.with_state(chat_history=[]) | |
.with_actions( | |
prompt=process_prompt, | |
check_safety=check_safety, | |
decide_mode=choose_mode, | |
generate_image=image_response, | |
generate_code=chat_response.bind( | |
prepend_prompt="Please respond with *only* code and no other text (at all) to the following:", | |
), | |
answer_question=chat_response.bind( | |
prepend_prompt="Please answer the following question:", | |
), | |
prompt_for_more=prompt_for_more, | |
response=response, | |
) | |
.with_transitions( | |
("prompt", "check_safety", default), | |
("check_safety", "decide_mode", when(safe=True)), | |
("check_safety", "response", default), | |
("decide_mode", "generate_image", when(mode="generate_image")), | |
("decide_mode", "generate_code", when(mode="generate_code")), | |
("decide_mode", "answer_question", when(mode="answer_question")), | |
("decide_mode", "prompt_for_more", default), | |
( | |
["generate_image", "answer_question", "generate_code", "prompt_for_more"], | |
"response", | |
), | |
("response", "prompt", default), | |
) | |
.with_tracker(project="demo_opentel") | |
.build() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment