Skip to content

armgit / burr

Public Imported from GitHub
0

Build applications that make decisions (chatbots, agents, simulations, etc...). Monitor, trace, persist, and execute on your own infrastructure.

Fix parallel docs & notebook example (#450)

Stefan Krawczyk7c5c131ae537
diff --git a/burr/core/parallelism.py b/burr/core/parallelism.py
index dd431c38..e0a6beb7 100644
--- a/burr/core/parallelism.py
+++ b/burr/core/parallelism.py
@@ -199,14 +199,14 @@ class TaskBasedParallelAction(SingleStepAction):
# a few other parameters we might add -- see advanced usage -- failure conditions, etc...
)
- def reduce(self, states: Generator[State, None, None]) -> State:
+ def reduce(self, state: State, states: Generator[State, None, None]) -> State:
all_llm_outputs = []
- for state in states:
+ for sub_state in states:
all_llm_outputs.append(
{
- "output" : state["llm_output"],
- "model" : state["model"],
- "prompt" : state["prompt"],
+ "output" : sub_state["llm_output"],
+ "model" : sub_state["model"],
+ "prompt" : sub_state["prompt"],
}
)
return state.update(all_llm_outputs=all_llm_outputs)
@@ -380,7 +380,7 @@ class MapActionsAndStates(TaskBasedParallelAction):
class TestModelsOverPrompts(MapActionsAndStates):
- def actions(self, state: State) -> Generator[Action | Callable | RunnableGraph, None, None]:
+ def actions(self, state: State, context: ApplicationContext, inputs: Dict[str, Any]) -> Generator[Action | Callable | RunnableGraph, None, None]:
# make sure to add a name to the action
# This is not necessary for subgraphs, as actions will already have names
for action in [
@@ -390,7 +390,7 @@ class MapActionsAndStates(TaskBasedParallelAction):
]:
yield action
- def states(self, state: State) -> Generator[State, None, None]:
+ def states(self, state: State, context: ApplicationContext, inputs: Dict[str, Any]) -> Generator[State, None, None]:
for prompt in [
"What is the meaning of life?",
"What is the airspeed velocity of an unladen swallow?",
@@ -398,14 +398,14 @@ class MapActionsAndStates(TaskBasedParallelAction):
]:
yield state.update(prompt=prompt)
- def reduce(self, states: Generator[State, None, None]) -> State:
+ def reduce(self, state: State, states: Generator[State, None, None]) -> State:
all_llm_outputs = []
- for state in states:
+ for sub_state in states:
all_llm_outputs.append(
{
- "output" : state["llm_output"],
- "model" : state["model"],
- "prompt" : state["prompt"],
+ "output" : sub_state["llm_output"],
+ "model" : sub_state["model"],
+ "prompt" : sub_state["prompt"],
}
)
return state.update(all_llm_outputs=all_llm_outputs)
@@ -585,7 +585,7 @@ class MapActions(MapActionsAndStates, abc.ABC):
class TestMultipleModels(MapActions):
- def actions(self, state: State) -> Generator[Action | Callable | RunnableGraph, None, None]:
+ def actions(self, state: State, inputs: Dict[str, Any], context: ApplicationContext) -> Generator[Action | Callable | RunnableGraph, None, None]:
# Make sure to add a name to the action if you use bind() with a function,
# note that these can be different actions, functions, etc...
# in this case we're using `.bind()` to create multiple actions, but we can use some mix of
@@ -597,7 +597,7 @@ class MapActions(MapActionsAndStates, abc.ABC):
]:
yield action
- def state(self, state: State) -> State:
+ def state(self, state: State, inputs: Dict[str, Any]) -> State:
return state.update(prompt="What is the meaning of life?")
def reduce(self, states: Generator[State, None, None]) -> State:
@@ -682,12 +682,12 @@ class MapStates(MapActionsAndStates, abc.ABC):
class TestMultiplePrompts(MapStates):
- def action(self) -> Action | Callable | RunnableGraph:
+ def action(self, state: State, inputs: Dict[str, Any]) -> Action | Callable | RunnableGraph:
# make sure to add a name to the action
# This is not necessary for subgraphs, as actions will already have names
return query_llm.with_name("query_llm")
- def states(self, state: State) -> Generator[State, None, None]:
+ def states(self, state: State, inputs: Dict[str, Any], context: ApplicationContext) -> Generator[State, None, None]:
# You could easily have a list_prompts upstream action that writes to "prompts" in state
# And loop through those
# This hardcodes for simplicity
@@ -698,11 +698,10 @@ class MapStates(MapActionsAndStates, abc.ABC):
]:
yield state.update(prompt=prompt)
-
- def reduce(self, states: Generator[State, None, None]) -> State:
+ def reduce(self, state: State, states: Generator[State, None, None]) -> State:
all_llm_outputs = []
- for state in states:
- all_llm_outputs.append(state["llm_output"])
+ for sub_state in states:
+ all_llm_outputs.append(sub_state["llm_output"])
return state.update(all_llm_outputs=all_llm_outputs)
@property
diff --git a/docs/concepts/parallelism.rst b/docs/concepts/parallelism.rst
index 81e8013c..0b3a4913 100644
--- a/docs/concepts/parallelism.rst
+++ b/docs/concepts/parallelism.rst
@@ -98,16 +98,18 @@ This looks as follows -- in this case we're running the same LLM over different
yield state.update(prompt=prompt)
- def reduce(self, states: Generator[State, None, None]) -> State:
+ def reduce(self, state: State, states: Generator[State, None, None]) -> State:
all_llm_outputs = []
- for state in states:
- all_llm_outputs.append(state["llm_output"])
+ for sub_state in states:
+ all_llm_outputs.append(sub_state["llm_output"])
return state.update(all_llm_outputs=all_llm_outputs)
- def reads() -> List[str]:
+ @property
+ def reads(self) -> List[str]:
return ["prompts"]
- def writes() -> List[str]:
+ @property
+ def writes(self) -> List[str]:
return ["all_llm_outputs"]
Then, to run the application:
@@ -168,16 +170,18 @@ For case (2) (mapping actions over the same state) you implement the ``MapAction
def state(self, state: State) -> State:
return state.update(prompt="What is the meaning of life?")
- def reduce(self, states: Generator[State, None, None]) -> State:
+ def reduce(self, state: State, states: Generator[State, None, None]) -> State:
all_llm_outputs = []
- for state in states:
- all_llm_outputs.append(state["llm_output"])
+ for sub_state in states:
+ all_llm_outputs.append(sub_state["llm_output"])
return state.update(all_llm_outputs=all_llm_outputs)
- def reads() -> List[str]:
+ @property
+ def reads(self) -> List[str]:
return ["prompt"] # we're just running this on a single prompt, for multiple actions
- def writes() -> List[str]:
+ @property
+ def writes(self) -> List[str]:
return ["all_llm_outputs"]
@@ -219,7 +223,7 @@ For tracking which states/actions belong to which actions, we recommend you use
class TestModelsOverPrompts(MapActionsAndStates):
- def actions(self, state: State) -> Generator[Action | Callable | RunnableGraph, None, None]:
+ def actions(self, state: State, context: ApplicationContext, inputs: Dict[str, Any]) -> Generator[Action | Callable | RunnableGraph, None, None]:
# make sure to add a name to the action
# This is not necessary for subgraphs, as actions will already have names
for action in [
@@ -229,7 +233,7 @@ For tracking which states/actions belong to which actions, we recommend you use
]
yield action
- def states(self, state: State) -> Generator[State, None, None]:
+ def states(self, state: State, context: ApplicationContext, inputs: Dict[str, Any]) -> Generator[State, None, None]:
for prompt in [
"What is the meaning of life?",
"What is the airspeed velocity of an unladen swallow?",
@@ -237,22 +241,24 @@ For tracking which states/actions belong to which actions, we recommend you use
]:
yield state.update(prompt=prompt)
- def reduce(self, states: Generator[State, None, None]) -> State:
+ def reduce(self, state: State, states: Generator[State, None, None]) -> State:
all_llm_outputs = []
- for state in states:
+ for sub_state in states:
all_llm_outputs.append(
{
- "output" : state["llm_output"],
- "model" : state["model"],
- "prompt" : state["prompt"],
+ "output" : sub_state["llm_output"],
+ "model" : sub_state["model"],
+ "prompt" : sub_state["prompt"],
}
)
return state.update(all_llm_outputs=all_llm_outputs)
- def reads() -> List[str]:
+ @property
+ def reads(self) -> List[str]:
return ["prompts"]
- def writes() -> List[str]:
+ @property
+ def writes(self) -> List[str]:
return ["all_llm_outputs"]
@@ -272,6 +278,7 @@ This might look as follows -- say we have a simple subflow that takes in a raw p
.. code-block:: python
+ from typing import Dict, Any
from burr.core import action, state
from burr.core.graph import Graph
@@ -304,7 +311,7 @@ This might look as follows -- say we have a simple subflow that takes in a raw p
class TestMultiplePromptsWithSubgraph(MapStates):
- def action(self) -> Action | Callable | RunnableGraph:
+ def action(self, state: State, inputs: Dict[str, Any]) -> Action | Callable | RunnableGraph:
return runnable_graph
def states(self, state: State) -> Generator[State, None, None]:
@@ -425,14 +432,14 @@ This looks as follows:
# a few other parameters we might add -- see advanced usage -- failure conditions, etc...
)
- def reduce(self, states: Generator[State, None, None]) -> State:
+ def reduce(self, state: State, states: Generator[State, None, None]) -> State:
all_llm_outputs = []
- for state in states:
+ for sub_state in states:
all_llm_outputs.append(
{
- "output" : state["llm_output"],
- "model" : state["model"],
- "prompt" : state["prompt"],
+ "output" : sub_state["llm_output"],
+ "model" : sub_state["model"],
+ "prompt" : sub_state["prompt"],
}
)
return state.update(all_llm_outputs=all_llm_outputs)
diff --git a/examples/parallelism/notebook.ipynb b/examples/parallelism/notebook.ipynb
index 56b7873d..ac2f3391 100644
--- a/examples/parallelism/notebook.ipynb
+++ b/examples/parallelism/notebook.ipynb
@@ -69,18 +69,10 @@
},
{
"cell_type": "code",
- "execution_count": 31,
+ "execution_count": 1,
"id": "e95aa6fe-1eaa-490d-b7fd-ff956306bcc5",
"metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Attempting to instrument while already instrumented\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"from concurrent.futures import ThreadPoolExecutor\n",
"from typing import Callable, Generator, List, Dict, Any\n",
@@ -101,7 +93,7 @@
},
{
"cell_type": "code",
- "execution_count": 75,
+ "execution_count": 3,
"id": "e59f1418-68f8-47c2-8034-4b928211acbe",
"metadata": {},
"outputs": [
@@ -110,15 +102,36 @@
"output_type": "stream",
"text": [
"The burr.integrations.notebook extension is already loaded. To reload it, use:\n",
- " %reload_ext burr.integrations.notebook\n",
- "Burr UI: http://127.0.0.1:7241\n"
+ " %reload_ext burr.integrations.notebook\n"
]
+ },
+ {
+ "data": {
+ "text/html": [
+ "\n",
+ " <iframe\n",
+ " width=\"100%\"\n",
+ " height=\"400\"\n",
+ " src=\"http://127.0.0.1:7241\"\n",
+ " frameborder=\"0\"\n",
+ " allowfullscreen\n",
+ " \n",
+ " ></iframe>\n",
+ " "
+ ],
+ "text/plain": [
+ "<IPython.lib.display.IFrame at 0x10f518310>"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
}
],
"source": [
"# let's load up some jupyter UI magics\n",
"%load_ext burr.integrations.notebook\n",
- "%burr_ui # this starts the UI in a background process"
+ "%burr_ui \n",
+ "# this starts the UI in a background process"
]
},
{
@@ -146,7 +159,7 @@
},
{
"cell_type": "code",
- "execution_count": 79,
+ "execution_count": 4,
"id": "4778dbb2-75a0-4490-86b8-7be206832d92",
"metadata": {},
"outputs": [],
@@ -175,7 +188,7 @@
},
{
"cell_type": "code",
- "execution_count": 77,
+ "execution_count": 5,
"id": "0998576a-c8cb-45a2-94ce-d8ce326e3be7",
"metadata": {},
"outputs": [],
@@ -227,7 +240,7 @@
},
{
"cell_type": "code",
- "execution_count": 78,
+ "execution_count": 6,
"id": "27ee761e-f7e8-4da7-82f2-349653cc6a7e",
"metadata": {},
"outputs": [
@@ -247,65 +260,65 @@
"<!-- process_input -->\n",
"<g id=\"node1\" class=\"node\">\n",
"<title>process_input</title>\n",
- "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M151.35,-167.8C151.35,-167.8 69.75,-167.8 69.75,-167.8 63.75,-167.8 57.75,-161.8 57.75,-155.8 57.75,-155.8 57.75,-143.2 57.75,-143.2 57.75,-137.2 63.75,-131.2 69.75,-131.2 69.75,-131.2 151.35,-131.2 151.35,-131.2 157.35,-131.2 163.35,-137.2 163.35,-143.2 163.35,-143.2 163.35,-155.8 163.35,-155.8 163.35,-161.8 157.35,-167.8 151.35,-167.8\"/>\n",
- "<text text-anchor=\"middle\" x=\"110.55\" y=\"-143.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">process_input</text>\n",
+ "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M152.1,-167.8C152.1,-167.8 70.5,-167.8 70.5,-167.8 64.5,-167.8 58.5,-161.8 58.5,-155.8 58.5,-155.8 58.5,-143.2 58.5,-143.2 58.5,-137.2 64.5,-131.2 70.5,-131.2 70.5,-131.2 152.1,-131.2 152.1,-131.2 158.1,-131.2 164.1,-137.2 164.1,-143.2 164.1,-143.2 164.1,-155.8 164.1,-155.8 164.1,-161.8 158.1,-167.8 152.1,-167.8\"/>\n",
+ "<text text-anchor=\"middle\" x=\"111.3\" y=\"-143.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">process_input</text>\n",
"</g>\n",
"<!-- query_multiple_models -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>query_multiple_models</title>\n",
- "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M179.47,-102.2C179.47,-102.2 41.62,-102.2 41.62,-102.2 35.62,-102.2 29.62,-96.2 29.62,-90.2 29.62,-90.2 29.62,-77.6 29.62,-77.6 29.62,-71.6 35.62,-65.6 41.62,-65.6 41.62,-65.6 179.47,-65.6 179.47,-65.6 185.47,-65.6 191.47,-71.6 191.47,-77.6 191.47,-77.6 191.47,-90.2 191.47,-90.2 191.47,-96.2 185.47,-102.2 179.47,-102.2\"/>\n",
- "<text text-anchor=\"middle\" x=\"110.55\" y=\"-78.1\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">query_multiple_models</text>\n",
+ "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M180.22,-102.2C180.22,-102.2 42.38,-102.2 42.38,-102.2 36.38,-102.2 30.38,-96.2 30.38,-90.2 30.38,-90.2 30.38,-77.6 30.38,-77.6 30.38,-71.6 36.38,-65.6 42.38,-65.6 42.38,-65.6 180.22,-65.6 180.22,-65.6 186.22,-65.6 192.22,-71.6 192.22,-77.6 192.22,-77.6 192.22,-90.2 192.22,-90.2 192.22,-96.2 186.22,-102.2 180.22,-102.2\"/>\n",
+ "<text text-anchor=\"middle\" x=\"111.3\" y=\"-78.1\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">query_multiple_models</text>\n",
"</g>\n",
"<!-- process_input&#45;&gt;query_multiple_models -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>process_input&#45;&gt;query_multiple_models</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M110.55,-130.78C110.55,-125.55 110.55,-119.67 110.55,-113.92\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"114.05,-114.03 110.55,-104.03 107.05,-114.03 114.05,-114.03\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M111.3,-130.78C111.3,-125.55 111.3,-119.67 111.3,-113.92\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"114.8,-114.03 111.3,-104.03 107.8,-114.03 114.8,-114.03\"/>\n",
"</g>\n",
- "<!-- input__prompt -->\n",
+ "<!-- input__models -->\n",
"<g id=\"node2\" class=\"node\">\n",
- "<title>input__prompt</title>\n",
- "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"101.1,-233.4 0,-233.4 0,-196.8 101.1,-196.8 101.1,-233.4\"/>\n",
- "<text text-anchor=\"middle\" x=\"50.55\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: prompt</text>\n",
+ "<title>input__models</title>\n",
+ "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"102.6,-233.4 0,-233.4 0,-196.8 102.6,-196.8 102.6,-233.4\"/>\n",
+ "<text text-anchor=\"middle\" x=\"51.3\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: models</text>\n",
"</g>\n",
- "<!-- input__prompt&#45;&gt;process_input -->\n",
+ "<!-- input__models&#45;&gt;process_input -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
- "<title>input__prompt&#45;&gt;process_input</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M67.26,-196.38C73.11,-190.18 79.81,-183.08 86.16,-176.35\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"88.57,-178.9 92.89,-169.22 83.48,-174.09 88.57,-178.9\"/>\n",
+ "<title>input__models&#45;&gt;process_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M68.01,-196.38C73.86,-190.18 80.56,-183.08 86.91,-176.35\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"89.32,-178.9 93.64,-169.22 84.23,-174.09 89.32,-178.9\"/>\n",
"</g>\n",
- "<!-- input__models -->\n",
+ "<!-- input__prompt -->\n",
"<g id=\"node3\" class=\"node\">\n",
- "<title>input__models</title>\n",
- "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"221.85,-233.4 119.25,-233.4 119.25,-196.8 221.85,-196.8 221.85,-233.4\"/>\n",
- "<text text-anchor=\"middle\" x=\"170.55\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: models</text>\n",
+ "<title>input__prompt</title>\n",
+ "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"221.85,-233.4 120.75,-233.4 120.75,-196.8 221.85,-196.8 221.85,-233.4\"/>\n",
+ "<text text-anchor=\"middle\" x=\"171.3\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: prompt</text>\n",
"</g>\n",
- "<!-- input__models&#45;&gt;process_input -->\n",
+ "<!-- input__prompt&#45;&gt;process_input -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
- "<title>input__models&#45;&gt;process_input</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M153.84,-196.38C147.99,-190.18 141.29,-183.08 134.94,-176.35\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"137.62,-174.09 128.21,-169.22 132.53,-178.9 137.62,-174.09\"/>\n",
+ "<title>input__prompt&#45;&gt;process_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M154.59,-196.38C148.74,-190.18 142.04,-183.08 135.69,-176.35\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"138.37,-174.09 128.96,-169.22 133.28,-178.9 138.37,-174.09\"/>\n",
"</g>\n",
"<!-- join_outputs -->\n",
"<g id=\"node5\" class=\"node\">\n",
"<title>join_outputs</title>\n",
- "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M145.72,-36.6C145.72,-36.6 75.38,-36.6 75.38,-36.6 69.38,-36.6 63.38,-30.6 63.38,-24.6 63.38,-24.6 63.38,-12 63.38,-12 63.38,-6 69.38,0 75.38,0 75.38,0 145.72,0 145.72,0 151.72,0 157.72,-6 157.72,-12 157.72,-12 157.72,-24.6 157.72,-24.6 157.72,-30.6 151.72,-36.6 145.72,-36.6\"/>\n",
- "<text text-anchor=\"middle\" x=\"110.55\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">join_outputs</text>\n",
+ "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M146.47,-36.6C146.47,-36.6 76.12,-36.6 76.12,-36.6 70.12,-36.6 64.12,-30.6 64.12,-24.6 64.12,-24.6 64.12,-12 64.12,-12 64.12,-6 70.12,0 76.12,0 76.12,0 146.47,0 146.47,0 152.47,0 158.47,-6 158.47,-12 158.47,-12 158.47,-24.6 158.47,-24.6 158.47,-30.6 152.47,-36.6 146.47,-36.6\"/>\n",
+ "<text text-anchor=\"middle\" x=\"111.3\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">join_outputs</text>\n",
"</g>\n",
"<!-- query_multiple_models&#45;&gt;join_outputs -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>query_multiple_models&#45;&gt;join_outputs</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M110.55,-65.18C110.55,-59.95 110.55,-54.07 110.55,-48.32\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"114.05,-48.43 110.55,-38.43 107.05,-48.43 114.05,-48.43\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M111.3,-65.18C111.3,-59.95 111.3,-54.07 111.3,-48.32\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"114.8,-48.43 111.3,-38.43 107.8,-48.43 114.8,-48.43\"/>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
- "<burr.core.application.Application at 0x1306644c0>"
+ "<burr.core.application.Application at 0x10f43b490>"
]
},
- "execution_count": 78,
+ "execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -348,7 +361,7 @@
},
{
"cell_type": "code",
- "execution_count": 80,
+ "execution_count": 7,
"id": "c99f7a75-1410-4aa6-b60d-16a592c3ae5f",
"metadata": {},
"outputs": [
@@ -359,7 +372,7 @@
" <iframe\n",
" width=\"100%\"\n",
" height=\"700px\"\n",
- " src=\"http://localhost:7241/project/parallelism_example/null/e58b9895-46e9-4e0d-b125-9748e5387465\"\n",
+ " src=\"http://localhost:7241/project/parallelism_example/null/77783ee1-dcf5-4991-9b27-c92313fea7a6\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
@@ -367,10 +380,10 @@
" "
],
"text/plain": [
- "<IPython.lib.display.IFrame at 0x1306674f0>"
+ "<IPython.lib.display.IFrame at 0x129ffca30>"
]
},
- "execution_count": 80,
+ "execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@@ -382,7 +395,7 @@
},
{
"cell_type": "code",
- "execution_count": 20,
+ "execution_count": 8,
"id": "ab7e1041-fd7e-438e-8a78-aa468830e2f6",
"metadata": {
"scrolled": true
@@ -410,7 +423,7 @@
},
{
"cell_type": "code",
- "execution_count": 24,
+ "execution_count": 9,
"id": "14a89b97-ae8f-4ae7-b1fc-a91182d5658d",
"metadata": {},
"outputs": [
@@ -430,65 +443,65 @@
"<!-- process_input -->\n",
"<g id=\"node1\" class=\"node\">\n",
"<title>process_input</title>\n",
- "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M151.35,-167.8C151.35,-167.8 69.75,-167.8 69.75,-167.8 63.75,-167.8 57.75,-161.8 57.75,-155.8 57.75,-155.8 57.75,-143.2 57.75,-143.2 57.75,-137.2 63.75,-131.2 69.75,-131.2 69.75,-131.2 151.35,-131.2 151.35,-131.2 157.35,-131.2 163.35,-137.2 163.35,-143.2 163.35,-143.2 163.35,-155.8 163.35,-155.8 163.35,-161.8 157.35,-167.8 151.35,-167.8\"/>\n",
- "<text text-anchor=\"middle\" x=\"110.55\" y=\"-143.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">process_input</text>\n",
+ "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M152.1,-167.8C152.1,-167.8 70.5,-167.8 70.5,-167.8 64.5,-167.8 58.5,-161.8 58.5,-155.8 58.5,-155.8 58.5,-143.2 58.5,-143.2 58.5,-137.2 64.5,-131.2 70.5,-131.2 70.5,-131.2 152.1,-131.2 152.1,-131.2 158.1,-131.2 164.1,-137.2 164.1,-143.2 164.1,-143.2 164.1,-155.8 164.1,-155.8 164.1,-161.8 158.1,-167.8 152.1,-167.8\"/>\n",
+ "<text text-anchor=\"middle\" x=\"111.3\" y=\"-143.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">process_input</text>\n",
"</g>\n",
"<!-- query_multiple_models -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>query_multiple_models</title>\n",
- "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M179.47,-102.2C179.47,-102.2 41.62,-102.2 41.62,-102.2 35.62,-102.2 29.62,-96.2 29.62,-90.2 29.62,-90.2 29.62,-77.6 29.62,-77.6 29.62,-71.6 35.62,-65.6 41.62,-65.6 41.62,-65.6 179.47,-65.6 179.47,-65.6 185.47,-65.6 191.47,-71.6 191.47,-77.6 191.47,-77.6 191.47,-90.2 191.47,-90.2 191.47,-96.2 185.47,-102.2 179.47,-102.2\"/>\n",
- "<text text-anchor=\"middle\" x=\"110.55\" y=\"-78.1\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">query_multiple_models</text>\n",
+ "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M180.22,-102.2C180.22,-102.2 42.38,-102.2 42.38,-102.2 36.38,-102.2 30.38,-96.2 30.38,-90.2 30.38,-90.2 30.38,-77.6 30.38,-77.6 30.38,-71.6 36.38,-65.6 42.38,-65.6 42.38,-65.6 180.22,-65.6 180.22,-65.6 186.22,-65.6 192.22,-71.6 192.22,-77.6 192.22,-77.6 192.22,-90.2 192.22,-90.2 192.22,-96.2 186.22,-102.2 180.22,-102.2\"/>\n",
+ "<text text-anchor=\"middle\" x=\"111.3\" y=\"-78.1\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">query_multiple_models</text>\n",
"</g>\n",
"<!-- process_input&#45;&gt;query_multiple_models -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>process_input&#45;&gt;query_multiple_models</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M110.55,-130.78C110.55,-125.55 110.55,-119.67 110.55,-113.92\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"114.05,-114.03 110.55,-104.03 107.05,-114.03 114.05,-114.03\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M111.3,-130.78C111.3,-125.55 111.3,-119.67 111.3,-113.92\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"114.8,-114.03 111.3,-104.03 107.8,-114.03 114.8,-114.03\"/>\n",
"</g>\n",
- "<!-- input__prompt -->\n",
+ "<!-- input__models -->\n",
"<g id=\"node2\" class=\"node\">\n",
- "<title>input__prompt</title>\n",
- "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"101.1,-233.4 0,-233.4 0,-196.8 101.1,-196.8 101.1,-233.4\"/>\n",
- "<text text-anchor=\"middle\" x=\"50.55\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: prompt</text>\n",
+ "<title>input__models</title>\n",
+ "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"102.6,-233.4 0,-233.4 0,-196.8 102.6,-196.8 102.6,-233.4\"/>\n",
+ "<text text-anchor=\"middle\" x=\"51.3\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: models</text>\n",
"</g>\n",
- "<!-- input__prompt&#45;&gt;process_input -->\n",
+ "<!-- input__models&#45;&gt;process_input -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
- "<title>input__prompt&#45;&gt;process_input</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M67.26,-196.38C73.11,-190.18 79.81,-183.08 86.16,-176.35\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"88.57,-178.9 92.89,-169.22 83.48,-174.09 88.57,-178.9\"/>\n",
+ "<title>input__models&#45;&gt;process_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M68.01,-196.38C73.86,-190.18 80.56,-183.08 86.91,-176.35\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"89.32,-178.9 93.64,-169.22 84.23,-174.09 89.32,-178.9\"/>\n",
"</g>\n",
- "<!-- input__models -->\n",
+ "<!-- input__prompt -->\n",
"<g id=\"node3\" class=\"node\">\n",
- "<title>input__models</title>\n",
- "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"221.85,-233.4 119.25,-233.4 119.25,-196.8 221.85,-196.8 221.85,-233.4\"/>\n",
- "<text text-anchor=\"middle\" x=\"170.55\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: models</text>\n",
+ "<title>input__prompt</title>\n",
+ "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"221.85,-233.4 120.75,-233.4 120.75,-196.8 221.85,-196.8 221.85,-233.4\"/>\n",
+ "<text text-anchor=\"middle\" x=\"171.3\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: prompt</text>\n",
"</g>\n",
- "<!-- input__models&#45;&gt;process_input -->\n",
+ "<!-- input__prompt&#45;&gt;process_input -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
- "<title>input__models&#45;&gt;process_input</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M153.84,-196.38C147.99,-190.18 141.29,-183.08 134.94,-176.35\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"137.62,-174.09 128.21,-169.22 132.53,-178.9 137.62,-174.09\"/>\n",
+ "<title>input__prompt&#45;&gt;process_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M154.59,-196.38C148.74,-190.18 142.04,-183.08 135.69,-176.35\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"138.37,-174.09 128.96,-169.22 133.28,-178.9 138.37,-174.09\"/>\n",
"</g>\n",
"<!-- join_outputs -->\n",
"<g id=\"node5\" class=\"node\">\n",
"<title>join_outputs</title>\n",
- "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M145.72,-36.6C145.72,-36.6 75.38,-36.6 75.38,-36.6 69.38,-36.6 63.38,-30.6 63.38,-24.6 63.38,-24.6 63.38,-12 63.38,-12 63.38,-6 69.38,0 75.38,0 75.38,0 145.72,0 145.72,0 151.72,0 157.72,-6 157.72,-12 157.72,-12 157.72,-24.6 157.72,-24.6 157.72,-30.6 151.72,-36.6 145.72,-36.6\"/>\n",
- "<text text-anchor=\"middle\" x=\"110.55\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">join_outputs</text>\n",
+ "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M146.47,-36.6C146.47,-36.6 76.12,-36.6 76.12,-36.6 70.12,-36.6 64.12,-30.6 64.12,-24.6 64.12,-24.6 64.12,-12 64.12,-12 64.12,-6 70.12,0 76.12,0 76.12,0 146.47,0 146.47,0 152.47,0 158.47,-6 158.47,-12 158.47,-12 158.47,-24.6 158.47,-24.6 158.47,-30.6 152.47,-36.6 146.47,-36.6\"/>\n",
+ "<text text-anchor=\"middle\" x=\"111.3\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">join_outputs</text>\n",
"</g>\n",
"<!-- query_multiple_models&#45;&gt;join_outputs -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>query_multiple_models&#45;&gt;join_outputs</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M110.55,-65.18C110.55,-59.95 110.55,-54.07 110.55,-48.32\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"114.05,-48.43 110.55,-38.43 107.05,-48.43 114.05,-48.43\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M111.3,-65.18C111.3,-59.95 111.3,-54.07 111.3,-48.32\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"114.8,-48.43 111.3,-38.43 107.8,-48.43 114.8,-48.43\"/>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
- "<burr.core.application.Application at 0x12cda75b0>"
+ "<burr.core.application.Application at 0x129ffef80>"
]
},
- "execution_count": 24,
+ "execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
@@ -545,7 +558,7 @@
},
{
"cell_type": "code",
- "execution_count": 25,
+ "execution_count": 10,
"id": "adb02469-9dd6-404e-8a9f-0e50fe21123f",
"metadata": {},
"outputs": [
@@ -556,7 +569,7 @@
" <iframe\n",
" width=\"100%\"\n",
" height=\"700px\"\n",
- " src=\"http://localhost:7241/project/parallelism_example/null/eeefba2c-db19-45c2-8844-ba90369ce9ee\"\n",
+ " src=\"http://localhost:7241/project/parallelism_example/null/3cfc4776-5081-4428-aa9a-0e8fa3d3f005\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
@@ -564,10 +577,10 @@
" "
],
"text/plain": [
- "<IPython.lib.display.IFrame at 0x12cdd5e10>"
+ "<IPython.lib.display.IFrame at 0x12a2416c0>"
]
},
- "execution_count": 25,
+ "execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
@@ -579,7 +592,7 @@
},
{
"cell_type": "code",
- "execution_count": 26,
+ "execution_count": 11,
"id": "ff28d579-084f-463f-9761-b9e85a6d1460",
"metadata": {},
"outputs": [],
@@ -605,7 +618,7 @@
},
{
"cell_type": "code",
- "execution_count": 39,
+ "execution_count": 12,
"id": "ce90216e-5470-4bdb-9d32-c9b7c3e64eb3",
"metadata": {},
"outputs": [
@@ -625,65 +638,65 @@
"<!-- process_input -->\n",
"<g id=\"node1\" class=\"node\">\n",
"<title>process_input</title>\n",
- "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M151.35,-167.8C151.35,-167.8 69.75,-167.8 69.75,-167.8 63.75,-167.8 57.75,-161.8 57.75,-155.8 57.75,-155.8 57.75,-143.2 57.75,-143.2 57.75,-137.2 63.75,-131.2 69.75,-131.2 69.75,-131.2 151.35,-131.2 151.35,-131.2 157.35,-131.2 163.35,-137.2 163.35,-143.2 163.35,-143.2 163.35,-155.8 163.35,-155.8 163.35,-161.8 157.35,-167.8 151.35,-167.8\"/>\n",
- "<text text-anchor=\"middle\" x=\"110.55\" y=\"-143.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">process_input</text>\n",
+ "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M152.1,-167.8C152.1,-167.8 70.5,-167.8 70.5,-167.8 64.5,-167.8 58.5,-161.8 58.5,-155.8 58.5,-155.8 58.5,-143.2 58.5,-143.2 58.5,-137.2 64.5,-131.2 70.5,-131.2 70.5,-131.2 152.1,-131.2 152.1,-131.2 158.1,-131.2 164.1,-137.2 164.1,-143.2 164.1,-143.2 164.1,-155.8 164.1,-155.8 164.1,-161.8 158.1,-167.8 152.1,-167.8\"/>\n",
+ "<text text-anchor=\"middle\" x=\"111.3\" y=\"-143.7\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">process_input</text>\n",
"</g>\n",
"<!-- query_multiple_models -->\n",
"<g id=\"node5\" class=\"node\">\n",
"<title>query_multiple_models</title>\n",
- "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M179.47,-102.2C179.47,-102.2 41.62,-102.2 41.62,-102.2 35.62,-102.2 29.62,-96.2 29.62,-90.2 29.62,-90.2 29.62,-77.6 29.62,-77.6 29.62,-71.6 35.62,-65.6 41.62,-65.6 41.62,-65.6 179.47,-65.6 179.47,-65.6 185.47,-65.6 191.47,-71.6 191.47,-77.6 191.47,-77.6 191.47,-90.2 191.47,-90.2 191.47,-96.2 185.47,-102.2 179.47,-102.2\"/>\n",
- "<text text-anchor=\"middle\" x=\"110.55\" y=\"-78.1\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">query_multiple_models</text>\n",
+ "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M180.22,-102.2C180.22,-102.2 42.38,-102.2 42.38,-102.2 36.38,-102.2 30.38,-96.2 30.38,-90.2 30.38,-90.2 30.38,-77.6 30.38,-77.6 30.38,-71.6 36.38,-65.6 42.38,-65.6 42.38,-65.6 180.22,-65.6 180.22,-65.6 186.22,-65.6 192.22,-71.6 192.22,-77.6 192.22,-77.6 192.22,-90.2 192.22,-90.2 192.22,-96.2 186.22,-102.2 180.22,-102.2\"/>\n",
+ "<text text-anchor=\"middle\" x=\"111.3\" y=\"-78.1\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">query_multiple_models</text>\n",
"</g>\n",
"<!-- process_input&#45;&gt;query_multiple_models -->\n",
"<g id=\"edge3\" class=\"edge\">\n",
"<title>process_input&#45;&gt;query_multiple_models</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M110.55,-130.78C110.55,-125.55 110.55,-119.67 110.55,-113.92\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"114.05,-114.03 110.55,-104.03 107.05,-114.03 114.05,-114.03\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M111.3,-130.78C111.3,-125.55 111.3,-119.67 111.3,-113.92\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"114.8,-114.03 111.3,-104.03 107.8,-114.03 114.8,-114.03\"/>\n",
"</g>\n",
- "<!-- input__prompt -->\n",
+ "<!-- input__models -->\n",
"<g id=\"node2\" class=\"node\">\n",
- "<title>input__prompt</title>\n",
- "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"101.1,-233.4 0,-233.4 0,-196.8 101.1,-196.8 101.1,-233.4\"/>\n",
- "<text text-anchor=\"middle\" x=\"50.55\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: prompt</text>\n",
+ "<title>input__models</title>\n",
+ "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"102.6,-233.4 0,-233.4 0,-196.8 102.6,-196.8 102.6,-233.4\"/>\n",
+ "<text text-anchor=\"middle\" x=\"51.3\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: models</text>\n",
"</g>\n",
- "<!-- input__prompt&#45;&gt;process_input -->\n",
+ "<!-- input__models&#45;&gt;process_input -->\n",
"<g id=\"edge1\" class=\"edge\">\n",
- "<title>input__prompt&#45;&gt;process_input</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M67.26,-196.38C73.11,-190.18 79.81,-183.08 86.16,-176.35\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"88.57,-178.9 92.89,-169.22 83.48,-174.09 88.57,-178.9\"/>\n",
+ "<title>input__models&#45;&gt;process_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M68.01,-196.38C73.86,-190.18 80.56,-183.08 86.91,-176.35\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"89.32,-178.9 93.64,-169.22 84.23,-174.09 89.32,-178.9\"/>\n",
"</g>\n",
- "<!-- input__models -->\n",
+ "<!-- input__prompt -->\n",
"<g id=\"node3\" class=\"node\">\n",
- "<title>input__models</title>\n",
- "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"221.85,-233.4 119.25,-233.4 119.25,-196.8 221.85,-196.8 221.85,-233.4\"/>\n",
- "<text text-anchor=\"middle\" x=\"170.55\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: models</text>\n",
+ "<title>input__prompt</title>\n",
+ "<polygon fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" points=\"221.85,-233.4 120.75,-233.4 120.75,-196.8 221.85,-196.8 221.85,-233.4\"/>\n",
+ "<text text-anchor=\"middle\" x=\"171.3\" y=\"-209.3\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">input: prompt</text>\n",
"</g>\n",
- "<!-- input__models&#45;&gt;process_input -->\n",
+ "<!-- input__prompt&#45;&gt;process_input -->\n",
"<g id=\"edge2\" class=\"edge\">\n",
- "<title>input__models&#45;&gt;process_input</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M153.84,-196.38C147.99,-190.18 141.29,-183.08 134.94,-176.35\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"137.62,-174.09 128.21,-169.22 132.53,-178.9 137.62,-174.09\"/>\n",
+ "<title>input__prompt&#45;&gt;process_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M154.59,-196.38C148.74,-190.18 142.04,-183.08 135.69,-176.35\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"138.37,-174.09 128.96,-169.22 133.28,-178.9 138.37,-174.09\"/>\n",
"</g>\n",
"<!-- join_outputs -->\n",
"<g id=\"node4\" class=\"node\">\n",
"<title>join_outputs</title>\n",
- "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M145.72,-36.6C145.72,-36.6 75.38,-36.6 75.38,-36.6 69.38,-36.6 63.38,-30.6 63.38,-24.6 63.38,-24.6 63.38,-12 63.38,-12 63.38,-6 69.38,0 75.38,0 75.38,0 145.72,0 145.72,0 151.72,0 157.72,-6 157.72,-12 157.72,-12 157.72,-24.6 157.72,-24.6 157.72,-30.6 151.72,-36.6 145.72,-36.6\"/>\n",
- "<text text-anchor=\"middle\" x=\"110.55\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">join_outputs</text>\n",
+ "<path fill=\"#b4d8e4\" stroke=\"black\" d=\"M146.47,-36.6C146.47,-36.6 76.12,-36.6 76.12,-36.6 70.12,-36.6 64.12,-30.6 64.12,-24.6 64.12,-24.6 64.12,-12 64.12,-12 64.12,-6 70.12,0 76.12,0 76.12,0 146.47,0 146.47,0 152.47,0 158.47,-6 158.47,-12 158.47,-12 158.47,-24.6 158.47,-24.6 158.47,-30.6 152.47,-36.6 146.47,-36.6\"/>\n",
+ "<text text-anchor=\"middle\" x=\"111.3\" y=\"-12.5\" font-family=\"Helvetica,sans-Serif\" font-size=\"14.00\">join_outputs</text>\n",
"</g>\n",
"<!-- query_multiple_models&#45;&gt;join_outputs -->\n",
"<g id=\"edge4\" class=\"edge\">\n",
"<title>query_multiple_models&#45;&gt;join_outputs</title>\n",
- "<path fill=\"none\" stroke=\"black\" d=\"M110.55,-65.18C110.55,-59.95 110.55,-54.07 110.55,-48.32\"/>\n",
- "<polygon fill=\"black\" stroke=\"black\" points=\"114.05,-48.43 110.55,-38.43 107.05,-48.43 114.05,-48.43\"/>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M111.3,-65.18C111.3,-59.95 111.3,-54.07 111.3,-48.32\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"114.8,-48.43 111.3,-38.43 107.8,-48.43 114.8,-48.43\"/>\n",
"</g>\n",
"</g>\n",
"</svg>\n"
],
"text/plain": [
- "<burr.core.application.Application at 0x12cd68670>"
+ "<burr.core.application.Application at 0x12a2950f0>"
]
},
- "execution_count": 39,
+ "execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
@@ -696,7 +709,7 @@
"class RunOverMultiplePromptsAction(MapStates):\n",
" \"\"\"Our parallel action - defined as a class.\"\"\"\n",
" def states(\n",
- " self, state: State, context: ApplicationContext, inputs: Dict[str, Any]\n",
+ " self, state: State, inputs: Dict[str, Any], context: ApplicationContext\n",
" ) -> Generator[State, None, None]:\n",
" \"\"\"Generator to map over values in state\"\"\"\n",
" for model in state[\"models\"]:\n",
@@ -708,8 +721,10 @@
"\n",
" def reduce(self, state: State, results: Generator[State, None, None]) -> State:\n",
" \"\"\"The reduction step - allows us to customize how state is updated\"\"\"\n",
- " state = state.update(results=[])\n",
- " responses = {model: output_state[\"response\"] for model, output_state in zip(state[\"models\"], results)}\n",
+ " responses = {\n",
+ " model: output_state[\"response\"]\n",
+ " for model, output_state in zip(state[\"models\"], results)\n",
+ " }\n",
" return state.update(responses=responses)\n",
" \n",
" @property\n",
@@ -741,7 +756,7 @@
},
{
"cell_type": "code",
- "execution_count": 40,
+ "execution_count": 13,
"id": "7ece3113-cf60-47b1-b375-735070c70b67",
"metadata": {},
"outputs": [
@@ -752,7 +767,7 @@
" <iframe\n",
" width=\"100%\"\n",
" height=\"700px\"\n",
- " src=\"http://localhost:7241/project/parallelism_example/null/59460ace-2cba-41fe-ae6d-9352ccdad0dc\"\n",
+ " src=\"http://localhost:7241/project/parallelism_example/null/8f87303a-1cd2-4345-9143-69c7409a23e0\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
@@ -760,10 +775,10 @@
" "
],
"text/plain": [
- "<IPython.lib.display.IFrame at 0x13016a0b0>"
+ "<IPython.lib.display.IFrame at 0x12a297dc0>"
]
},
- "execution_count": 40,
+ "execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
@@ -775,7 +790,7 @@
},
{
"cell_type": "code",
- "execution_count": 41,
+ "execution_count": 14,
"id": "816cf0d7-1f89-4145-a5e3-c2878cec12e1",
"metadata": {},
"outputs": [],
@@ -814,7 +829,7 @@
},
{
"cell_type": "code",
- "execution_count": 67,
+ "execution_count": 15,
"id": "1969fe52-ba92-42f6-ae39-2252aff30d51",
"metadata": {},
"outputs": [
@@ -865,10 +880,10 @@
"</svg>\n"
],
"text/plain": [
- "<burr.core.application.Application at 0x13096ad40>"
+ "<burr.core.application.Application at 0x12a264700>"
]
},
- "execution_count": 67,
+ "execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
@@ -945,7 +960,8 @@
"class RunMultipleGraphsAction(MapActions):\n",
" \"\"\"Our parallel action that will map over graphs\"\"\"\n",
"\n",
- " def actions(self, state: State) -> Generator[Action | Callable | RunnableGraph, None, None]:\n",
+ " def actions(self, state: State, inputs: Dict[str, Any], context: ApplicationContext\n",
+ " ) -> Generator[Action | Callable | RunnableGraph, None, None]:\n",
" \"\"\"We hard code the actions here, but they could be dynamic\"\"\"\n",
" for graph_action in [\n",
" hypothesis_graph_1.with_name(\"hypothesis_1\"),\n",
@@ -953,14 +969,14 @@
" ]:\n",
" yield graph_action\n",
"\n",
- " def state(self, state: State) -> State:\n",
+ " def state(self, state: State, inputs: Dict[str, Any]) -> State:\n",
" return state.update(transcript=\"this could be passed in or could be set here\")\n",
"\n",
- " def reduce(self, states: Generator[State, None, None]) -> State:\n",
+ " def reduce(self, state: State, states: Generator[State, None, None]) -> State:\n",
" # we aggregate here\n",
" all_diagnoses = []\n",
- " for state in states:\n",
- " all_diagnoses.append((state[\"llm_response\"], state[\"hypothesis\"]))\n",
+ " for sub_state in states:\n",
+ " all_diagnoses.append((sub_state[\"llm_response\"], sub_state[\"hypothesis\"]))\n",
" return state.update(all_diagnoses=all_diagnoses)\n",
" \n",
" @property\n",
@@ -1015,7 +1031,7 @@
},
{
"cell_type": "code",
- "execution_count": 68,
+ "execution_count": 16,
"id": "c881b815-b9bf-472d-9104-84ffa2fda63f",
"metadata": {},
"outputs": [
@@ -1066,10 +1082,10 @@
"</svg>\n"
],
"text/plain": [
- "<burr.core.application.Application at 0x130664c40>"
+ "<burr.core.application.Application at 0x12a22aa40>"
]
},
- "execution_count": 68,
+ "execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
@@ -1123,7 +1139,7 @@
"class MapOverURLsAction(MapStates):\n",
" \"\"\"Our parallel action that will map over state values\"\"\"\n",
"\n",
- " def action(self, state: State) -> Generator[Action | Callable | RunnableGraph, None, None]:\n",
+ " def action(self, state: State, inputs: Dict[str, Any]) -> Generator[Action | Callable | RunnableGraph, None, None]:\n",
" \"\"\"Return the one action.\"\"\"\n",
" return url_processor\n",
"\n",
@@ -1134,11 +1150,11 @@
" for url in state[\"urls\"]:\n",
" yield state.update(url=url)\n",
"\n",
- " def reduce(self, states: Generator[State, None, None]) -> State:\n",
+ " def reduce(self, state: State, states: Generator[State, None, None]) -> State:\n",
" # we aggregate here\n",
" all_results = []\n",
- " for state in states:\n",
- " all_results.append((state[\"classification\"], state[\"url\"]))\n",
+ " for sub_state in states:\n",
+ " all_results.append((sub_state[\"classification\"], sub_state[\"url\"]))\n",
" return state.update(all_results=all_results)\n",
" \n",
" @property\n",
@@ -1195,7 +1211,7 @@
},
{
"cell_type": "code",
- "execution_count": 59,
+ "execution_count": 17,
"id": "66f78c91-09db-49df-9c20-6f084783dc7a",
"metadata": {},
"outputs": [
@@ -1253,10 +1269,10 @@
"</svg>\n"
],
"text/plain": [
- "<burr.core.application.Application at 0x1308cc4f0>"
+ "<burr.core.application.Application at 0x12a422f20>"
]
},
- "execution_count": 59,
+ "execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
@@ -1303,7 +1319,7 @@
" E.g. states x actions burr subapplications will be run in parallel.\n",
" \"\"\"\n",
"\n",
- " def actions(self, state: State) -> Generator[Action | Callable | RunnableGraph, None, None]:\n",
+ " def actions(self, state: State, context: ApplicationContext, inputs: Dict[str, Any]) -> Generator[Action | Callable | RunnableGraph, None, None]:\n",
" # make sure to add a name to the action\n",
" # This is not necessary for subgraphs, as actions will already have names\n",
" for action in [\n",
@@ -1313,18 +1329,18 @@
" ]:\n",
" yield action\n",
"\n",
- " def states(self, state: State) -> Generator[State, None, None]:\n",
+ " def states(self, state: State, context: ApplicationContext, inputs: Dict[str, Any]) -> Generator[State, None, None]:\n",
" for prompt in state[\"prompts\"]:\n",
" yield state.update(prompt=prompt)\n",
"\n",
- " def reduce(self, states: Generator[State, None, None]) -> State:\n",
+ " def reduce(self, state: State, states: Generator[State, None, None]) -> State:\n",
" all_llm_outputs = []\n",
- " for state in states:\n",
+ " for sub_state in states:\n",
" all_llm_outputs.append(\n",
" {\n",
- " \"output\" : state[\"llm_output\"][0],\n",
- " \"provider\" : state[\"llm_output\"][1],\n",
- " \"prompt\" : state[\"prompt\"],\n",
+ " \"output\" : sub_state[\"llm_output\"][0],\n",
+ " \"provider\" : sub_state[\"llm_output\"][1],\n",
+ " \"prompt\" : sub_state[\"prompt\"],\n",
" }\n",
" )\n",
" return state.update(all_llm_outputs=all_llm_outputs)\n",