Created
January 16, 2025 04:44
Revisions
-
elijahbenizzy created this gist
Jan 16, 2025 .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,24 @@ from burr.core import action, State, ApplicationBuilder @action(reads=[], writes=["prompt", "chat_history"]) def human_input(state: State, prompt: str) -> State: # your code -- write what you want here! return state.update(prompt=prompt).append(chat_history=chat_item) @action(reads=["chat_history"], writes=["response", "chat_history"]) def ai_response(state: State) -> State: response = _query_llm(state["chat_history"]) # Burr doesn't care how you use LLMs! return state.update(response=content).append(chat_history=chat_item) app = ( ApplicationBuilder() .with_actions(human_input, ai_response) .with_transitions( ("human_input", "ai_response"), ("ai_response", "human_input") ).with_state(chat_history=[]) .with_entrypoint("human_input") .build() ) *_, state = app.run(halt_after=["ai_response"], inputs={"prompt": "Who was Aaron Burr, sir?"}) print("answer:", app.state["response"])