|
6 | 6 | "outputs": [], |
7 | 7 | "execution_count": null, |
8 | 8 | "source": [ |
9 | | - "# Copyright 2025 Apache Software Foundation\n", |
| 9 | + "# Copyright 2026 Apache Software Foundation\n", |
10 | 10 | "#\n", |
11 | 11 | "# Licensed under the Apache License, Version 2.0 (the \"License\");\n", |
12 | 12 | "# you may not use this file except in compliance with the License.\n", |
|
123 | 123 | "import copy\n", |
124 | 124 | "\n", |
125 | 125 | "from IPython.display import Image, display\n", |
126 | | - "from IPython.core.display import HTML \n", |
| 126 | + "from IPython.core.display import HTML\n", |
127 | 127 | "import openai\n", |
128 | 128 | "\n", |
129 | 129 | "from burr.core import ApplicationBuilder, State, default, graph, when\n", |
|
190 | 190 | "def chat_response(\n", |
191 | 191 | " state: State, prepend_prompt: str, model: str = \"gpt-3.5-turbo\"\n", |
192 | 192 | ") -> State:\n", |
193 | | - " \n", |
| 193 | + "\n", |
194 | 194 | " chat_history = copy.deepcopy(state[\"chat_history\"])\n", |
195 | 195 | " chat_history[-1][\"content\"] = f\"{prepend_prompt}: {chat_history[-1]['content']}\"\n", |
196 | 196 | " chat_history_api_format = [\n", |
|
409 | 409 | "base_graph = (\n", |
410 | 410 | " graph.GraphBuilder()\n", |
411 | 411 | " .with_actions(\n", |
412 | | - " # these are the \"nodes\" \n", |
| 412 | + " # these are the \"nodes\"\n", |
413 | 413 | " prompt=process_prompt,\n", |
414 | 414 | " decide_mode=choose_mode,\n", |
415 | 415 | " generate_image=image_response,\n", |
|
635 | 635 | " ApplicationBuilder()\n", |
636 | 636 | " .with_graph(base_graph)\n", |
637 | 637 | " .initialize_from(\n", |
638 | | - " tracker, \n", |
639 | | - " resume_at_next_action=True, \n", |
| 638 | + " tracker,\n", |
| 639 | + " resume_at_next_action=True,\n", |
640 | 640 | " default_state={\"chat_history\": []},\n", |
641 | 641 | " default_entrypoint=\"prompt\",\n", |
642 | 642 | " )\n", |
|
744 | 744 | " if \"quit\" == user_input.lower():\n", |
745 | 745 | " break\n", |
746 | 746 | " last_action, action_result, app_state = app.run(\n", |
747 | | - " halt_after=[\"response\"], \n", |
| 747 | + " halt_after=[\"response\"],\n", |
748 | 748 | " inputs={\"prompt\": user_input}\n", |
749 | 749 | " )\n", |
750 | 750 | " last_message = app_state[\"chat_history\"][-1]\n", |
|
796 | 796 | " .with_graph(base_graph)\n", |
797 | 797 | " .initialize_from(\n", |
798 | 798 | " tracker,\n", |
799 | | - " resume_at_next_action=True, \n", |
| 799 | + " resume_at_next_action=True,\n", |
800 | 800 | " default_state={\"chat_history\": []},\n", |
801 | 801 | " default_entrypoint=\"prompt\",\n", |
802 | 802 | " )\n", |
|
868 | 868 | " if \"quit\" == user_input.lower():\n", |
869 | 869 | " break\n", |
870 | 870 | " last_action, action_result, app_state = resumed_app.run(\n", |
871 | | - " halt_after=[\"response\"], \n", |
| 871 | + " halt_after=[\"response\"],\n", |
872 | 872 | " inputs={\"prompt\": user_input}\n", |
873 | 873 | " )\n", |
874 | 874 | " last_message = app_state[\"chat_history\"][-1]\n", |
|
917 | 917 | " .with_graph(base_graph) # this could be different...\n", |
918 | 918 | " .initialize_from(\n", |
919 | 919 | " tracker,\n", |
920 | | - " resume_at_next_action=True, \n", |
| 920 | + " resume_at_next_action=True,\n", |
921 | 921 | " default_state={\"chat_history\": []},\n", |
922 | 922 | " default_entrypoint=\"prompt\",\n", |
923 | 923 | " fork_from_app_id=app_id,\n", |
|
997 | 997 | " if \"quit\" == user_input.lower():\n", |
998 | 998 | " break\n", |
999 | 999 | " last_action, action_result, app_state = forked_app.run(\n", |
1000 | | - " halt_after=[\"response\"], \n", |
| 1000 | + " halt_after=[\"response\"],\n", |
1001 | 1001 | " inputs={\"prompt\": user_input}\n", |
1002 | 1002 | " )\n", |
1003 | 1003 | " last_message = app_state[\"chat_history\"][-1]\n", |
|
1021 | 1021 | "\n", |
1022 | 1022 | "[Time Travel blog post & video:](https://blog.dagworks.io/p/travel-back-in-time-with-burr)\n", |
1023 | 1023 | "\n", |
1024 | | - "<a href=\"https://www.youtube.com/embed/98vxhIcE6NI?si=oV1BbSUCKa1UvX5P\"><img src=\"https://img.youtube.com/vi/98vxhIcE6NI/0.jpg\"> \n", |
| 1024 | + "<a href=\"https://www.youtube.com/embed/98vxhIcE6NI?si=oV1BbSUCKa1UvX5P\"><img src=\"https://img.youtube.com/vi/98vxhIcE6NI/0.jpg\">\n", |
1025 | 1025 | "</img>\n", |
1026 | 1026 | "<a href=\"https://www.youtube.com/embed/98vxhIcE6NI?si=oV1BbSUCKa1UvX5P\">\n", |
1027 | 1027 | "\n", |
|
0 commit comments