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.

Fixes up PR for review

elijahbenizzy557dc86f6612
diff --git a/burr/core/application.py b/burr/core/application.py
index 0f4f134d..dd5ef4f4 100644
--- a/burr/core/application.py
+++ b/burr/core/application.py
@@ -385,7 +385,7 @@ class Application:
sequence_id: Optional[int] = None,
adapter_set: Optional[LifecycleAdapterSet] = None,
builder: Optional["ApplicationBuilder"] = None,
- parent_pointer: Optional[burr_types.ParentPointer] = None,
+ fork_parent_pointer: Optional[burr_types.ParentPointer] = None,
spawning_parent_pointer: Optional[burr_types.ParentPointer] = None,
tracker: Optional["TrackingClient"] = None,
):
@@ -418,7 +418,7 @@ class Application:
if sequence_id is not None:
self._set_sequence_id(sequence_id)
self._builder = builder
- self._parent_pointer = parent_pointer
+ self._parent_pointer = fork_parent_pointer
self.dependency_factory = {
"__tracer": functools.partial(
visibility.tracing.TracerFactory, lifecycle_adapters=self._adapter_set
@@ -432,7 +432,7 @@ class Application:
application_graph=self._graph,
app_id=self._uid,
partition_key=self._partition_key,
- parent_pointer=parent_pointer,
+ parent_pointer=fork_parent_pointer,
spawning_parent_pointer=spawning_parent_pointer,
)
@@ -533,6 +533,7 @@ class Application:
return new_state
def _process_inputs(self, inputs: Dict[str, Any], action: Action) -> Dict[str, Any]:
+ """Processes inputs, injecting the common inputs and ensuring that all required inputs are present."""
starting_with_double_underscore = {key for key in inputs.keys() if key.startswith("__")}
if len(starting_with_double_underscore) > 0:
raise ValueError(
@@ -1977,7 +1978,7 @@ class ApplicationBuilder:
sequence_id=self.sequence_id,
adapter_set=LifecycleAdapterSet(*self.lifecycle_adapters),
builder=self,
- parent_pointer=burr_types.ParentPointer(
+ fork_parent_pointer=burr_types.ParentPointer(
app_id=self.fork_from_app_id,
partition_key=self.fork_from_partition_key,
sequence_id=self.fork_from_sequence_id,
diff --git a/burr/tracking/client.py b/burr/tracking/client.py
index 1770cd45..77e52f3e 100644
--- a/burr/tracking/client.py
+++ b/burr/tracking/client.py
@@ -201,6 +201,10 @@ class LocalTrackingClient(
parent_children_list_path = os.path.join(
parent_path, LocalTrackingClient.CHILDREN_FILENAME
)
+ # Order should not matter here
+ # currently we write start events, so it really won't matter
+ # but in the future we'll write end events, but we'll parse it in a
+ # way that allows them to be interwoven
with open(parent_children_list_path, "a") as f:
fileno = f.fileno()
try:
diff --git a/examples/recursive/__init__.py b/examples/recursive/__init__.py
new file mode 100644
index 00000000..e69de29b
diff --git a/examples/recursive/notebook.ipynb b/examples/recursive/notebook.ipynb
new file mode 100644
index 00000000..c1d33d58
--- /dev/null
+++ b/examples/recursive/notebook.ipynb
@@ -0,0 +1,585 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "4bb251de-463e-4156-bcfc-9078721f6a8b",
+ "metadata": {},
+ "source": [
+ "# Imports"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "id": "0ae4a1f2-c40c-4c97-9c98-e8e1152a3f95",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from typing import List, Tuple, Optional\n",
+ "\n",
+ "import joblib\n",
+ "import openai\n",
+ "from joblib import parallel_config\n",
+ "\n",
+ "from burr.core import Application, ApplicationBuilder, Condition, State, action\n",
+ "from burr.core.application import ApplicationContext\n",
+ "from burr.tracking import LocalTrackingClient"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "d3e64255-0154-496b-b1cd-7821789e05b0",
+ "metadata": {},
+ "source": [
+ "# Helper functions"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "id": "5d45a62a-3432-4159-a1a2-703ef8d91d3b",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def _query_llm(prompt: str) -> str:\n",
+ " \"\"\"Simple wrapper around the OpenAI API.\"\"\"\n",
+ " client = openai.Client()\n",
+ " return (\n",
+ " client.chat.completions.create(\n",
+ " model=\"gpt-4o\",\n",
+ " messages=[\n",
+ " {\"role\": \"system\", \"content\": \"You are a helpful assistant\"},\n",
+ " {\"role\": \"user\", \"content\": prompt},\n",
+ " ],\n",
+ " )\n",
+ " .choices[0]\n",
+ " .message.content\n",
+ " )"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "91a4a439-9d5e-4e6d-b287-0532abd3c19e",
+ "metadata": {},
+ "source": [
+ "# Sub Application\n",
+ "\n",
+ "First let's write a sub-application. We're going to have it do two things:\n",
+ "\n",
+ "1. Write a poem (`write`)\n",
+ "2. Provide suggestions (`edit`)\n",
+ "\n",
+ "We're going to wrap its creation in a function so we can create it within an application. Note that we pass in `__context` -- this allows us to wire the context through for tracking."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "ce9afd4c-986a-4d19-b72a-67c1b2b7fa34",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "@action(\n",
+ " reads=[\"feedback\", \"current_draft\", \"poem_type\", \"prompt\"],\n",
+ " writes=[\"current_draft\", \"draft_history\", \"num_drafts\"],\n",
+ ")\n",
+ "def write(state: State) -> Tuple[dict, State]:\n",
+ " \"\"\"Writes a draft of a poem.\"\"\"\n",
+ " poem_subject = state[\"prompt\"]\n",
+ " poem_type = state[\"poem_type\"]\n",
+ " current_draft = state.get(\"current_draft\")\n",
+ " feedback = state.get(\"feedback\")\n",
+ "\n",
+ " parts = [\n",
+ " f'You are an AI poet. Create a {poem_type} poem on the following subject: \"{poem_subject}\".'\n",
+ " ]\n",
+ "\n",
+ " if current_draft:\n",
+ " parts.append(f'Here is the current draft of the poem: \"{current_draft}\".')\n",
+ "\n",
+ " if feedback:\n",
+ " parts.append(f'Please incorporate the following feedback: \"{feedback}\".')\n",
+ "\n",
+ " parts.append(\n",
+ " f\"Ensure the poem is creative, adheres to the style of a {poem_type}, and improves upon the previous draft.\"\n",
+ " )\n",
+ "\n",
+ " prompt = \"\\n\".join(parts)\n",
+ "\n",
+ " draft = _query_llm(prompt)\n",
+ "\n",
+ " return {\"draft\": draft}, state.update(\n",
+ " current_draft=draft,\n",
+ " draft_history=state.get(\"draft_history\", []) + [draft],\n",
+ " ).increment(num_drafts=1)\n",
+ "\n",
+ "\n",
+ "@action(reads=[\"current_draft\", \"poem_type\", \"prompt\"], writes=[\"feedback\"])\n",
+ "def edit(state: State) -> Tuple[dict, State]:\n",
+ " \"\"\"Edits a draft of a poem, providing feedback\"\"\"\n",
+ " poem_subject = state[\"prompt\"]\n",
+ " poem_type = state[\"poem_type\"]\n",
+ " current_draft = state[\"current_draft\"]\n",
+ "\n",
+ " prompt = f\"\"\"\n",
+ " You are an AI poetry critic. Review the following {poem_type} poem based on the subject: \"{poem_subject}\".\n",
+ " Here is the current draft of the poem: \"{current_draft}\".\n",
+ " Provide detailed feedback to improve the poem. If the poem is already excellent and needs no changes, simply respond with an empty string.\n",
+ " \"\"\"\n",
+ "\n",
+ " feedback = _query_llm(prompt)\n",
+ "\n",
+ " return {\"feedback\": feedback}, state.update(feedback=feedback)\n",
+ "\n",
+ "\n",
+ "@action(reads=[\"current_draft\"], writes=[\"final_draft\"])\n",
+ "def final_draft(state: State) -> Tuple[dict, State]:\n",
+ " return {\"final_draft\": state[\"current_draft\"]}, state.update(final_draft=state[\"current_draft\"])\n",
+ "\n",
+ "\n",
+ "def _create_sub_application(\n",
+ " max_num_drafts: int,\n",
+ " spawning_application_context: Optional[ApplicationContext],\n",
+ " poem_type: str,\n",
+ " prompt: str,\n",
+ ") -> Application:\n",
+ " \"\"\"Utility to create sub-application -- note\"\"\"\n",
+ " builder = (\n",
+ " ApplicationBuilder()\n",
+ " .with_actions(\n",
+ " edit,\n",
+ " write,\n",
+ " final_draft,\n",
+ " )\n",
+ " .with_transitions(\n",
+ " (\"write\", \"edit\", Condition.expr(f\"num_drafts < {max_num_drafts}\")),\n",
+ " (\"write\", \"final_draft\"),\n",
+ " (\"edit\", \"final_draft\", Condition.expr(\"len(feedback) == 0\")),\n",
+ " (\"edit\", \"write\"),\n",
+ " )\n",
+ " .with_entrypoint(\"write\")\n",
+ " .with_state(\n",
+ " current_draft=None,\n",
+ " poem_type=poem_type,\n",
+ " prompt=prompt,\n",
+ " feedback=None,\n",
+ " )\n",
+ " )\n",
+ " # so we can run without it\n",
+ " if spawning_application_context:\n",
+ " builder=(\n",
+ " builder\n",
+ " .with_tracker(spawning_application_context.tracker.copy()) # remember to do `copy()` here!\n",
+ " .with_spawning_parent(\n",
+ " spawning_application_context.app_id,\n",
+ " spawning_application_context.sequence_id,\n",
+ " spawning_application_context.partition_key,\n",
+ " )\n",
+ " )\n",
+ " \n",
+ " return builder.build()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "id": "52ef53b9-c3a1-4ee4-a8e0-99906c6bd8d8",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
+ "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
+ " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
+ "<!-- Generated by graphviz version 8.1.0 (20230707.0739)\n",
+ " -->\n",
+ "<!-- Pages: 1 -->\n",
+ "<svg width=\"99pt\" height=\"174pt\"\n",
+ " viewBox=\"0.00 0.00 98.50 174.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
+ "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 170)\">\n",
+ "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-170 94.5,-170 94.5,4 -4,4\"/>\n",
+ "<!-- edit -->\n",
+ "<g id=\"node1\" class=\"node\">\n",
+ "<title>edit</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M42,-166C42,-166 12,-166 12,-166 6,-166 0,-160 0,-154 0,-154 0,-142 0,-142 0,-136 6,-130 12,-130 12,-130 42,-130 42,-130 48,-130 54,-136 54,-142 54,-142 54,-154 54,-154 54,-160 48,-166 42,-166\"/>\n",
+ "<text text-anchor=\"middle\" x=\"27\" y=\"-142.95\" font-family=\"Times,serif\" font-size=\"14.00\">edit</text>\n",
+ "</g>\n",
+ "<!-- write -->\n",
+ "<g id=\"node2\" class=\"node\">\n",
+ "<title>write</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M42,-101C42,-101 12,-101 12,-101 6,-101 0,-95 0,-89 0,-89 0,-77 0,-77 0,-71 6,-65 12,-65 12,-65 42,-65 42,-65 48,-65 54,-71 54,-77 54,-77 54,-89 54,-89 54,-95 48,-101 42,-101\"/>\n",
+ "<text text-anchor=\"middle\" x=\"27\" y=\"-77.95\" font-family=\"Times,serif\" font-size=\"14.00\">write</text>\n",
+ "</g>\n",
+ "<!-- edit&#45;&gt;write -->\n",
+ "<g id=\"edge4\" class=\"edge\">\n",
+ "<title>edit&#45;&gt;write</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M20.91,-129.78C20.36,-124.23 20.15,-117.92 20.29,-111.8\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"23.82,-112.38 20.91,-102.19 16.83,-111.97 23.82,-112.38\"/>\n",
+ "</g>\n",
+ "<!-- final_draft -->\n",
+ "<g id=\"node3\" class=\"node\">\n",
+ "<title>final_draft</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M78.5,-36C78.5,-36 29.5,-36 29.5,-36 23.5,-36 17.5,-30 17.5,-24 17.5,-24 17.5,-12 17.5,-12 17.5,-6 23.5,0 29.5,0 29.5,0 78.5,0 78.5,0 84.5,0 90.5,-6 90.5,-12 90.5,-12 90.5,-24 90.5,-24 90.5,-30 84.5,-36 78.5,-36\"/>\n",
+ "<text text-anchor=\"middle\" x=\"54\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">final_draft</text>\n",
+ "</g>\n",
+ "<!-- edit&#45;&gt;final_draft -->\n",
+ "<g id=\"edge3\" class=\"edge\">\n",
+ "<title>edit&#45;&gt;final_draft</title>\n",
+ "<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M44.84,-129.9C51.94,-121.88 59.3,-111.74 63,-101 68.99,-83.62 66.71,-63.05 62.95,-46.86\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"66.13,-46.22 60.19,-37.45 59.37,-48.01 66.13,-46.22\"/>\n",
+ "</g>\n",
+ "<!-- write&#45;&gt;edit -->\n",
+ "<g id=\"edge1\" class=\"edge\">\n",
+ "<title>write&#45;&gt;edit</title>\n",
+ "<path fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" d=\"M33.09,-101.19C33.64,-106.75 33.85,-113.06 33.71,-119.18\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"30.18,-118.6 33.09,-128.78 37.17,-119.01 30.18,-118.6\"/>\n",
+ "</g>\n",
+ "<!-- write&#45;&gt;final_draft -->\n",
+ "<g id=\"edge2\" class=\"edge\">\n",
+ "<title>write&#45;&gt;final_draft</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M34.38,-64.78C36.88,-58.95 39.73,-52.29 42.48,-45.89\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"45.91,-47.76 46.63,-37.19 39.47,-45.01 45.91,-47.76\"/>\n",
+ "</g>\n",
+ "</g>\n",
+ "</svg>\n"
+ ],
+ "text/plain": [
+ "<graphviz.graphs.Digraph at 0x16a053210>"
+ ]
+ },
+ "execution_count": 4,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "_create_sub_application(2, None, \"sonnet\", \"state machines\").visualize()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "0f14b1f4-06d2-492c-be5c-088862445ff7",
+ "metadata": {},
+ "source": [
+ "# Full Application\n",
+ "\n",
+ "Next let's create the actual application. We'll call the sub-application inside the `generate_all_poems` step:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "id": "0b786047-8944-45d4-a383-b32ee013a773",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# full agent\n",
+ "@action(\n",
+ " reads=[],\n",
+ " writes=[\n",
+ " \"max_drafts\",\n",
+ " \"poem_types\",\n",
+ " \"poem_subject\",\n",
+ " ],\n",
+ ")\n",
+ "def user_input(\n",
+ " state: State, max_drafts: int, poem_types: List[str], poem_subject: str\n",
+ ") -> Tuple[dict, State]:\n",
+ " \"\"\"Collects user input for the poem generation process.\"\"\"\n",
+ " return {\n",
+ " \"max_drafts\": max_drafts,\n",
+ " \"poem_types\": poem_types,\n",
+ " \"poem_subject\": poem_subject,\n",
+ " }, state.update(max_drafts=max_drafts, poem_types=poem_types, poem_subject=poem_subject)\n",
+ "\n",
+ "\n",
+ "@action(reads=[\"max_drafts\", \"poem_types\", \"poem_subject\"], writes=[\"proposals\"])\n",
+ "def generate_all_poems(state: State, __context: ApplicationContext) -> Tuple[dict, State]:\n",
+ " # create one each\n",
+ " apps = [\n",
+ " _create_sub_application(state[\"max_drafts\"], __context, poem_type, state[\"poem_subject\"])\n",
+ " for poem_type in state[\"poem_types\"]\n",
+ " ]\n",
+ " # run them all in parallel\n",
+ " with parallel_config(backend=\"threading\", n_jobs=3):\n",
+ " all_results = joblib.Parallel()(\n",
+ " joblib.delayed(app.run)(halt_after=[\"final_draft\"])\n",
+ " for app, poem_type in zip(apps, state[\"poem_types\"])\n",
+ " )\n",
+ " proposals = []\n",
+ " for *_, substate in all_results:\n",
+ " proposals.append(substate[\"final_draft\"])\n",
+ "\n",
+ " return {\"proposals\": proposals}, state.update(proposals=proposals)\n",
+ "\n",
+ "\n",
+ "@action(reads=[\"proposals\", \"prompts\"], writes=[\"final_results\"])\n",
+ "def final_results(state: State) -> Tuple[dict, State]:\n",
+ " # joins them into a string\n",
+ " proposals = state[\"proposals\"]\n",
+ " final_results = \"\\n\\n\".join(\n",
+ " [f\"{poem_type}:\\n{proposal}\" for poem_type, proposal in zip(state[\"poem_types\"], proposals)]\n",
+ " )\n",
+ " return {\"final_results\": final_results}, state.update(final_results=final_results)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "id": "195a5ab3-1208-4200-9e9d-473ec0575e10",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
+ "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
+ " \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
+ "<!-- Generated by graphviz version 8.1.0 (20230707.0739)\n",
+ " -->\n",
+ "<!-- Pages: 1 -->\n",
+ "<svg width=\"532pt\" height=\"239pt\"\n",
+ " viewBox=\"0.00 0.00 531.68 239.00\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
+ "<g id=\"graph0\" class=\"graph\" transform=\"scale(1 1) rotate(0) translate(4 235)\">\n",
+ "<polygon fill=\"white\" stroke=\"none\" points=\"-4,4 -4,-235 527.68,-235 527.68,4 -4,4\"/>\n",
+ "<!-- user_input -->\n",
+ "<g id=\"node1\" class=\"node\">\n",
+ "<title>user_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M279.51,-166C279.51,-166 230.51,-166 230.51,-166 224.51,-166 218.51,-160 218.51,-154 218.51,-154 218.51,-142 218.51,-142 218.51,-136 224.51,-130 230.51,-130 230.51,-130 279.51,-130 279.51,-130 285.51,-130 291.51,-136 291.51,-142 291.51,-142 291.51,-154 291.51,-154 291.51,-160 285.51,-166 279.51,-166\"/>\n",
+ "<text text-anchor=\"middle\" x=\"255.01\" y=\"-142.95\" font-family=\"Times,serif\" font-size=\"14.00\">user_input</text>\n",
+ "</g>\n",
+ "<!-- generate_all_poems -->\n",
+ "<g id=\"node5\" class=\"node\">\n",
+ "<title>generate_all_poems</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M305.39,-101C305.39,-101 204.64,-101 204.64,-101 198.64,-101 192.64,-95 192.64,-89 192.64,-89 192.64,-77 192.64,-77 192.64,-71 198.64,-65 204.64,-65 204.64,-65 305.39,-65 305.39,-65 311.39,-65 317.39,-71 317.39,-77 317.39,-77 317.39,-89 317.39,-89 317.39,-95 311.39,-101 305.39,-101\"/>\n",
+ "<text text-anchor=\"middle\" x=\"255.01\" y=\"-77.95\" font-family=\"Times,serif\" font-size=\"14.00\">generate_all_poems</text>\n",
+ "</g>\n",
+ "<!-- user_input&#45;&gt;generate_all_poems -->\n",
+ "<g id=\"edge4\" class=\"edge\">\n",
+ "<title>user_input&#45;&gt;generate_all_poems</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M255.01,-129.78C255.01,-124.23 255.01,-117.92 255.01,-111.8\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"258.51,-112.19 255.01,-102.19 251.51,-112.19 258.51,-112.19\"/>\n",
+ "</g>\n",
+ "<!-- input__poem_types -->\n",
+ "<g id=\"node2\" class=\"node\">\n",
+ "<title>input__poem_types</title>\n",
+ "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"80.01\" cy=\"-213\" rx=\"80.01\" ry=\"18\"/>\n",
+ "<text text-anchor=\"middle\" x=\"80.01\" y=\"-207.95\" font-family=\"Times,serif\" font-size=\"14.00\">input: poem_types</text>\n",
+ "</g>\n",
+ "<!-- input__poem_types&#45;&gt;user_input -->\n",
+ "<g id=\"edge1\" class=\"edge\">\n",
+ "<title>input__poem_types&#45;&gt;user_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M121.04,-197.23C147.11,-187.84 180.93,-175.67 208.07,-165.9\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"208.89,-168.96 217.11,-162.28 206.52,-162.38 208.89,-168.96\"/>\n",
+ "</g>\n",
+ "<!-- input__max_drafts -->\n",
+ "<g id=\"node3\" class=\"node\">\n",
+ "<title>input__max_drafts</title>\n",
+ "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"255.01\" cy=\"-213\" rx=\"76.94\" ry=\"18\"/>\n",
+ "<text text-anchor=\"middle\" x=\"255.01\" y=\"-207.95\" font-family=\"Times,serif\" font-size=\"14.00\">input: max_drafts</text>\n",
+ "</g>\n",
+ "<!-- input__max_drafts&#45;&gt;user_input -->\n",
+ "<g id=\"edge2\" class=\"edge\">\n",
+ "<title>input__max_drafts&#45;&gt;user_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M255.01,-194.78C255.01,-189.23 255.01,-182.92 255.01,-176.8\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"258.51,-177.19 255.01,-167.19 251.51,-177.19 258.51,-177.19\"/>\n",
+ "</g>\n",
+ "<!-- input__poem_subject -->\n",
+ "<g id=\"node4\" class=\"node\">\n",
+ "<title>input__poem_subject</title>\n",
+ "<ellipse fill=\"none\" stroke=\"black\" stroke-dasharray=\"5,2\" cx=\"437.01\" cy=\"-213\" rx=\"86.67\" ry=\"18\"/>\n",
+ "<text text-anchor=\"middle\" x=\"437.01\" y=\"-207.95\" font-family=\"Times,serif\" font-size=\"14.00\">input: poem_subject</text>\n",
+ "</g>\n",
+ "<!-- input__poem_subject&#45;&gt;user_input -->\n",
+ "<g id=\"edge3\" class=\"edge\">\n",
+ "<title>input__poem_subject&#45;&gt;user_input</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M393.88,-197.07C366.26,-187.51 330.42,-175.1 302.07,-165.29\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"303.59,-161.76 292.99,-161.8 301.3,-168.38 303.59,-161.76\"/>\n",
+ "</g>\n",
+ "<!-- final_results -->\n",
+ "<g id=\"node6\" class=\"node\">\n",
+ "<title>final_results</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M284.39,-36C284.39,-36 225.64,-36 225.64,-36 219.64,-36 213.64,-30 213.64,-24 213.64,-24 213.64,-12 213.64,-12 213.64,-6 219.64,0 225.64,0 225.64,0 284.39,0 284.39,0 290.39,0 296.39,-6 296.39,-12 296.39,-12 296.39,-24 296.39,-24 296.39,-30 290.39,-36 284.39,-36\"/>\n",
+ "<text text-anchor=\"middle\" x=\"255.01\" y=\"-12.95\" font-family=\"Times,serif\" font-size=\"14.00\">final_results</text>\n",
+ "</g>\n",
+ "<!-- generate_all_poems&#45;&gt;final_results -->\n",
+ "<g id=\"edge5\" class=\"edge\">\n",
+ "<title>generate_all_poems&#45;&gt;final_results</title>\n",
+ "<path fill=\"none\" stroke=\"black\" d=\"M255.01,-64.78C255.01,-59.23 255.01,-52.92 255.01,-46.8\"/>\n",
+ "<polygon fill=\"black\" stroke=\"black\" points=\"258.51,-47.19 255.01,-37.19 251.51,-47.19 258.51,-47.19\"/>\n",
+ "</g>\n",
+ "</g>\n",
+ "</svg>\n"
+ ],
+ "text/plain": [
+ "<graphviz.graphs.Digraph at 0x16a0d8dd0>"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "app = (\n",
+ " ApplicationBuilder()\n",
+ " .with_actions(\n",
+ " user_input,\n",
+ " generate_all_poems,\n",
+ " final_results,\n",
+ " )\n",
+ " .with_transitions(\n",
+ " (\"user_input\", \"generate_all_poems\"),\n",
+ " (\"generate_all_poems\", \"final_results\"),\n",
+ " )\n",
+ " .with_tracker(project=\"demo:parallelism_poem_generation\")\n",
+ " .with_entrypoint(\"user_input\")\n",
+ " .build()\n",
+ ")\n",
+ "app.visualize()"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "id": "8db52375-6031-4b2e-8667-f7bc81f76580",
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/markdown": [
+ "[View in UI!](http://localhost:7241/project/demo:parallelism_poem_generation/7e4abaa5-5d9f-4a35-863b-9627727eb4d4) (make sure Burr is running first)"
+ ],
+ "text/plain": [
+ "<IPython.core.display.Markdown object>"
+ ]
+ },
+ "execution_count": 19,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "from IPython.display import Markdown\n",
+ "Markdown(f\"[View in UI!](http://localhost:7241/project/demo:parallelism_poem_generation/{app.uid}) (make sure Burr is running first)\")"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "9700a6a5-b6c8-475c-afaa-96ca2bf2a65b",
+ "metadata": {},
+ "source": [
+ "# Running it"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "992c0e25-e504-4eda-8d13-f3ec07aa73ad",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "action, state, results = app.run(\n",
+ " halt_after=[\"final_results\"],\n",
+ " inputs={\n",
+ " \"max_drafts\": 2,\n",
+ " \"poem_types\": [\n",
+ " \"sonnet\",\n",
+ " \"limerick\",\n",
+ " \"haiku\",\n",
+ " \"acrostic\",\n",
+ " ],\n",
+ " \"poem_subject\": \"state machines\",\n",
+ " },\n",
+ ")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "id": "cb52e66c-b391-4495-aa48-b86fb96fc780",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "sonnet:\n",
+ "In realms of logic, where machines reside,\n",
+ "With gears of reason, wheels of choice aligned,\n",
+ "A state machine, our guiding technologic guide,\n",
+ "A dance of code within a frame confined.\n",
+ "\n",
+ "It starts with states, finite list well-traced,\n",
+ "Transitions chart its routes from here to there.\n",
+ "Encoded paths, in logic's arms embraced,\n",
+ "A web of rules, spun tight with utmost care.\n",
+ "\n",
+ "From idle calm to busy hum it shifts,\n",
+ "With each condition met, it alters course.\n",
+ "It thrives on change; its power deftly lifts,\n",
+ "Transforms through states, a tireless, coded force.\n",
+ "\n",
+ "Though hardware cold may cloak its silent might,\n",
+ "In structured change, it brings our world to light.\n",
+ "\n",
+ "limerick:\n",
+ "In realms where the data aligns,\n",
+ "Live machines with sleek, stateful designs.\n",
+ "Their transitions, so neat,\n",
+ "Make logic a treat,\n",
+ "As grand as the royals in lines.\n",
+ "\n",
+ "haiku:\n",
+ "Whispers of logic,\n",
+ "Circuits pulse in silent paths —\n",
+ "States craft vivid tales.\n",
+ "\n",
+ "acrostic:\n",
+ "**State Machines**\n",
+ "\n",
+ "**S**hadows of logic in code’s tight embrace,\n",
+ "**T**houghts intertwined in a digital space.\n",
+ "**A**lchemy of zeros ignites the race,\n",
+ "**T**ransitions intricate, guarded with grace.\n",
+ "**E**choed whispers in circuits’ high chase.\n",
+ "\n",
+ "**M**emory’s echo in silicon lanes,\n",
+ "**A**cross pathways, breaking old chains.\n",
+ "**C**elestial guides in algorithm’s reign,\n",
+ "**H**eavy with purpose, binaries plain.\n",
+ "**I**nfinite states, each proud and contained,\n",
+ "**N**avigating logic, calculations sustained,\n",
+ "**E**thos of order where chaos restrains,\n",
+ "**S**ymbiotic rhythms, precision regained.\n"
+ ]
+ }
+ ],
+ "source": [
+ "print(results['final_results'])"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3 (ipykernel)",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.11.6"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/notebook.ipynb b/notebook.ipynb
deleted file mode 100644
index 64df0e75..00000000
--- a/notebook.ipynb
+++ /dev/null
@@ -1,666 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 8,
- "id": "d3e3fc61-0b15-488f-916c-a68851a54c55",
- "metadata": {
- "scrolled": true
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Requirement already satisfied: pypdf2 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (3.0.1)\n",
- "\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.2.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython3.11 -m pip install --upgrade pip\u001b[0m\n",
- "Note: you may need to restart the kernel to use updated packages.\n",
- "Requirement already satisfied: sentence-transformers in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (2.7.0)\n",
- "Requirement already satisfied: transformers<5.0.0,>=4.34.0 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from sentence-transformers) (4.40.2)\n",
- "Requirement already satisfied: tqdm in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from sentence-transformers) (4.66.1)\n",
- "Requirement already satisfied: torch>=1.11.0 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from sentence-transformers) (2.3.0)\n",
- "Requirement already satisfied: numpy in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from sentence-transformers) (1.26.3)\n",
- "Requirement already satisfied: scikit-learn in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from sentence-transformers) (1.4.2)\n",
- "Requirement already satisfied: scipy in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from sentence-transformers) (1.13.0)\n",
- "Requirement already satisfied: huggingface-hub>=0.15.1 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from sentence-transformers) (0.23.0)\n",
- "Requirement already satisfied: Pillow in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from sentence-transformers) (10.2.0)\n",
- "Requirement already satisfied: filelock in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from huggingface-hub>=0.15.1->sentence-transformers) (3.13.1)\n",
- "Requirement already satisfied: fsspec>=2023.5.0 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from huggingface-hub>=0.15.1->sentence-transformers) (2024.5.0)\n",
- "Requirement already satisfied: packaging>=20.9 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from huggingface-hub>=0.15.1->sentence-transformers) (23.2)\n",
- "Requirement already satisfied: pyyaml>=5.1 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from huggingface-hub>=0.15.1->sentence-transformers) (6.0.1)\n",
- "Requirement already satisfied: requests in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from huggingface-hub>=0.15.1->sentence-transformers) (2.31.0)\n",
- "Requirement already satisfied: typing-extensions>=3.7.4.3 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from huggingface-hub>=0.15.1->sentence-transformers) (4.9.0)\n",
- "Requirement already satisfied: sympy in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from torch>=1.11.0->sentence-transformers) (1.12)\n",
- "Requirement already satisfied: networkx in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from torch>=1.11.0->sentence-transformers) (3.2.1)\n",
- "Requirement already satisfied: jinja2 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from torch>=1.11.0->sentence-transformers) (3.1.3)\n",
- "Requirement already satisfied: regex!=2019.12.17 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from transformers<5.0.0,>=4.34.0->sentence-transformers) (2023.12.25)\n",
- "Requirement already satisfied: tokenizers<0.20,>=0.19 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from transformers<5.0.0,>=4.34.0->sentence-transformers) (0.19.1)\n",
- "Requirement already satisfied: safetensors>=0.4.1 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from transformers<5.0.0,>=4.34.0->sentence-transformers) (0.4.3)\n",
- "Requirement already satisfied: joblib>=1.2.0 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from scikit-learn->sentence-transformers) (1.4.0)\n",
- "Requirement already satisfied: threadpoolctl>=2.0.0 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from scikit-learn->sentence-transformers) (3.4.0)\n",
- "Requirement already satisfied: MarkupSafe>=2.0 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from jinja2->torch>=1.11.0->sentence-transformers) (2.1.4)\n",
- "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from requests->huggingface-hub>=0.15.1->sentence-transformers) (3.3.2)\n",
- "Requirement already satisfied: idna<4,>=2.5 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from requests->huggingface-hub>=0.15.1->sentence-transformers) (3.6)\n",
- "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from requests->huggingface-hub>=0.15.1->sentence-transformers) (2.0.7)\n",
- "Requirement already satisfied: certifi>=2017.4.17 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from requests->huggingface-hub>=0.15.1->sentence-transformers) (2023.11.17)\n",
- "Requirement already satisfied: mpmath>=0.19 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from sympy->torch>=1.11.0->sentence-transformers) (1.3.0)\n",
- "\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.2.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython3.11 -m pip install --upgrade pip\u001b[0m\n",
- "Note: you may need to restart the kernel to use updated packages.\n",
- "Collecting qdrant-client\n",
- " Obtaining dependency information for qdrant-client from https://files.pythonhosted.org/packages/5c/1c/551dac58a8be76820b3eb72b190191337686f75fbee5d738657bca4bd812/qdrant_client-1.9.1-py3-none-any.whl.metadata\n",
- " Downloading qdrant_client-1.9.1-py3-none-any.whl.metadata (9.5 kB)\n",
- "Collecting grpcio>=1.41.0 (from qdrant-client)\n",
- " Obtaining dependency information for grpcio>=1.41.0 from https://files.pythonhosted.org/packages/a4/83/c3a8480f170894c132ef00450ab11ed5c86ae047c54fd7b7faf6a53475c7/grpcio-1.63.0-cp311-cp311-macosx_10_9_universal2.whl.metadata\n",
- " Downloading grpcio-1.63.0-cp311-cp311-macosx_10_9_universal2.whl.metadata (3.2 kB)\n",
- "Collecting grpcio-tools>=1.41.0 (from qdrant-client)\n",
- " Obtaining dependency information for grpcio-tools>=1.41.0 from https://files.pythonhosted.org/packages/1a/a1/42970349bb7cbf1a222cb996e6cff1a5ec6ba68e871bb38b8a5c98378428/grpcio_tools-1.63.0-cp311-cp311-macosx_10_9_universal2.whl.metadata\n",
- " Downloading grpcio_tools-1.63.0-cp311-cp311-macosx_10_9_universal2.whl.metadata (5.3 kB)\n",
- "Requirement already satisfied: httpx[http2]>=0.20.0 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from qdrant-client) (0.26.0)\n",
- "Requirement already satisfied: numpy>=1.21 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from qdrant-client) (1.26.3)\n",
- "Collecting portalocker<3.0.0,>=2.7.0 (from qdrant-client)\n",
- " Obtaining dependency information for portalocker<3.0.0,>=2.7.0 from https://files.pythonhosted.org/packages/17/9e/87671efcca80ba6203811540ed1f9c0462c1609d2281d7b7f53cef05da3d/portalocker-2.8.2-py3-none-any.whl.metadata\n",
- " Downloading portalocker-2.8.2-py3-none-any.whl.metadata (8.5 kB)\n",
- "Requirement already satisfied: pydantic>=1.10.8 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from qdrant-client) (2.6.0)\n",
- "Requirement already satisfied: urllib3<3,>=1.26.14 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from qdrant-client) (2.0.7)\n",
- "Collecting protobuf<6.0dev,>=5.26.1 (from grpcio-tools>=1.41.0->qdrant-client)\n",
- " Obtaining dependency information for protobuf<6.0dev,>=5.26.1 from https://files.pythonhosted.org/packages/1e/40/2eb2bf643d4b060b1602a25748b48d75431f4951be2470f8ae136952b3d3/protobuf-5.26.1-cp37-abi3-macosx_10_9_universal2.whl.metadata\n",
- " Downloading protobuf-5.26.1-cp37-abi3-macosx_10_9_universal2.whl.metadata (592 bytes)\n",
- "Requirement already satisfied: setuptools in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from grpcio-tools>=1.41.0->qdrant-client) (68.2.2)\n",
- "Requirement already satisfied: anyio in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from httpx[http2]>=0.20.0->qdrant-client) (4.2.0)\n",
- "Requirement already satisfied: certifi in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from httpx[http2]>=0.20.0->qdrant-client) (2023.11.17)\n",
- "Requirement already satisfied: httpcore==1.* in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from httpx[http2]>=0.20.0->qdrant-client) (1.0.2)\n",
- "Requirement already satisfied: idna in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from httpx[http2]>=0.20.0->qdrant-client) (3.6)\n",
- "Requirement already satisfied: sniffio in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from httpx[http2]>=0.20.0->qdrant-client) (1.3.0)\n",
- "Collecting h2<5,>=3 (from httpx[http2]>=0.20.0->qdrant-client)\n",
- " Obtaining dependency information for h2<5,>=3 from https://files.pythonhosted.org/packages/2a/e5/db6d438da759efbb488c4f3fbdab7764492ff3c3f953132efa6b9f0e9e53/h2-4.1.0-py3-none-any.whl.metadata\n",
- " Downloading h2-4.1.0-py3-none-any.whl.metadata (3.6 kB)\n",
- "Requirement already satisfied: h11<0.15,>=0.13 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from httpcore==1.*->httpx[http2]>=0.20.0->qdrant-client) (0.14.0)\n",
- "Requirement already satisfied: annotated-types>=0.4.0 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from pydantic>=1.10.8->qdrant-client) (0.6.0)\n",
- "Requirement already satisfied: pydantic-core==2.16.1 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from pydantic>=1.10.8->qdrant-client) (2.16.1)\n",
- "Requirement already satisfied: typing-extensions>=4.6.1 in /Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages (from pydantic>=1.10.8->qdrant-client) (4.9.0)\n",
- "Collecting hyperframe<7,>=6.0 (from h2<5,>=3->httpx[http2]>=0.20.0->qdrant-client)\n",
- " Obtaining dependency information for hyperframe<7,>=6.0 from https://files.pythonhosted.org/packages/d7/de/85a784bcc4a3779d1753a7ec2dee5de90e18c7bcf402e71b51fcf150b129/hyperframe-6.0.1-py3-none-any.whl.metadata\n",
- " Downloading hyperframe-6.0.1-py3-none-any.whl.metadata (2.7 kB)\n",
- "Collecting hpack<5,>=4.0 (from h2<5,>=3->httpx[http2]>=0.20.0->qdrant-client)\n",
- " Obtaining dependency information for hpack<5,>=4.0 from https://files.pythonhosted.org/packages/d5/34/e8b383f35b77c402d28563d2b8f83159319b509bc5f760b15d60b0abf165/hpack-4.0.0-py3-none-any.whl.metadata\n",
- " Downloading hpack-4.0.0-py3-none-any.whl.metadata (2.5 kB)\n",
- "Downloading qdrant_client-1.9.1-py3-none-any.whl (229 kB)\n",
- "\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m229.3/229.3 kB\u001b[0m \u001b[31m1.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m[36m0:00:01\u001b[0m[36m0:00:01\u001b[0m01\u001b[0m\n",
- "\u001b[?25hDownloading grpcio-1.63.0-cp311-cp311-macosx_10_9_universal2.whl (10.1 MB)\n",
- "\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.1/10.1 MB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mm eta \u001b[36m0:00:01\u001b[0m36m0:00:01\u001b[0m\n",
- "\u001b[?25hDownloading grpcio_tools-1.63.0-cp311-cp311-macosx_10_9_universal2.whl (5.3 MB)\n",
- "\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.3/5.3 MB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mm eta \u001b[36m0:00:01\u001b[0m0:01\u001b[0m:01\u001b[0m\n",
- "\u001b[?25hDownloading portalocker-2.8.2-py3-none-any.whl (17 kB)\n",
- "Using cached h2-4.1.0-py3-none-any.whl (57 kB)\n",
- "Downloading protobuf-5.26.1-cp37-abi3-macosx_10_9_universal2.whl (404 kB)\n",
- "\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m404.0/404.0 kB\u001b[0m \u001b[31m2.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mm eta \u001b[36m0:00:01\u001b[0m0:01\u001b[0m\n",
- "\u001b[?25hUsing cached hpack-4.0.0-py3-none-any.whl (32 kB)\n",
- "Using cached hyperframe-6.0.1-py3-none-any.whl (12 kB)\n",
- "Installing collected packages: protobuf, portalocker, hyperframe, hpack, grpcio, h2, grpcio-tools, qdrant-client\n",
- " Attempting uninstall: protobuf\n",
- " Found existing installation: protobuf 4.25.2\n",
- " Uninstalling protobuf-4.25.2:\n",
- " Successfully uninstalled protobuf-4.25.2\n",
- "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
- "streamlit 1.31.0 requires protobuf<5,>=3.20, but you have protobuf 5.26.1 which is incompatible.\u001b[0m\u001b[31m\n",
- "\u001b[0mSuccessfully installed grpcio-1.63.0 grpcio-tools-1.63.0 h2-4.1.0 hpack-4.0.0 hyperframe-6.0.1 portalocker-2.8.2 protobuf-5.26.1 qdrant-client-1.9.1\n",
- "\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.2.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n",
- "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython3.11 -m pip install --upgrade pip\u001b[0m\n",
- "Note: you may need to restart the kernel to use updated packages.\n"
- ]
- }
- ],
- "source": [
- "%pip install pypdf2\n",
- "%pip install sentence-transformers\n",
- "%pip install qdrant-client"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "70ae1209-71d2-4cb2-8e35-ab4c20d00daf",
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "id": "51221206-72ec-44e8-b17d-c46870a9debf",
- "metadata": {},
- "outputs": [
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "dc142927780e4ac58dc33e93aa692818",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "model.safetensors: 58%|#####7 | 52.4M/90.9M [00:00<?, ?B/s]"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "ce13ef23bf904e71b4e0ea0887c25b6d",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "tokenizer_config.json: 0%| | 0.00/350 [00:00<?, ?B/s]"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "5269d335ef2747648a16d80f756faee5",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "vocab.txt: 0%| | 0.00/232k [00:00<?, ?B/s]"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "c4491fffad3449f19e6ea74536452188",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "tokenizer.json: 0%| | 0.00/466k [00:00<?, ?B/s]"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "06e4b57568584bc898d3af97ee398246",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "special_tokens_map.json: 0%| | 0.00/112 [00:00<?, ?B/s]"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- },
- {
- "data": {
- "application/vnd.jupyter.widget-view+json": {
- "model_id": "1fe0c96378fd456f9ef95e60da5553ab",
- "version_major": 2,
- "version_minor": 0
- },
- "text/plain": [
- "1_Pooling/config.json: 0%| | 0.00/190 [00:00<?, ?B/s]"
- ]
- },
- "metadata": {},
- "output_type": "display_data"
- }
- ],
- "source": [
- "# %%\n",
- "import copy\n",
- "import os\n",
- "import base64\n",
- "\n",
- "import openai\n",
- "import PyPDF2\n",
- "import textwrap\n",
- "from io import BytesIO\n",
- "\n",
- "from burr.core import Application, ApplicationBuilder, State, Result\n",
- "from burr.core.action import action, default, expr, when\n",
- "from burr.lifecycle import LifecycleAdapter\n",
- "from burr.tracking import LocalTrackingClient\n",
- "\n",
- "# %%\n",
- "from pydantic import BaseModel, Field\n",
- "\n",
- "\n",
- "class InputType(BaseModel):\n",
- " prompt: str | None = None\n",
- " document: bytes| str | None = Field(default=None, description=\"Binary PDF content\")\n",
- "\n",
- "# %%\n",
- "@action(reads=[], writes=[\"prompt\", \"document_ingest\"])\n",
- "def process_input(state: State, input: InputType) -> tuple[dict, State]:\n",
- " # TODO: raise and exception if input is invalid\n",
- "\n",
- " return (\n",
- " {\"prompt\": input.prompt, \"document_ingest\": input.document},\n",
- " state.update(prompt=input.prompt, document_ingest=input.document),\n",
- " )\n",
- "\n",
- "# %%\n",
- "@action(reads=[\"prompt\"], writes=[\"vector_results\"])\n",
- "def query_vector(state: State) -> tuple[dict, State]:\n",
- " vector_results = []\n",
- " return {\"vector_results\": vector_results}, state.update(\n",
- " vector_results=vector_results\n",
- " )\n",
- "\n",
- "\n",
- "@action(reads=[\"prompt\", \"vector_results\"], writes=[\"full_prompt\"])\n",
- "def generate_prompt(state: State) -> tuple[dict, State]:\n",
- " prompt = state[\"prompt\"]\n",
- " vector_results = state[\"vector_results\"]\n",
- "\n",
- " full_prompt = prompt + str(vector_results)\n",
- " return {\"full_prompt\": full_prompt}, state.update(full_prompt=full_prompt)\n",
- "\n",
- "\n",
- "def _get_openai_client():\n",
- " return openai.Client()\n",
- "\n",
- "\n",
- "@action(reads=[\"full_prompt\"], writes=[\"response\"])\n",
- "def prompt_response(\n",
- " state: State,\n",
- " model: str = \"gpt-4o\",\n",
- ") -> tuple[dict, State]:\n",
- " client = _get_openai_client()\n",
- " prompt = state[\"full_prompt\"]\n",
- " result = client.chat.completions.create(\n",
- " model=model,\n",
- " messages=[\n",
- " {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n",
- " {\"role\": \"user\", \"content\": prompt},\n",
- " ],\n",
- " )\n",
- " response = result.choices[0].message.content\n",
- " return {\"response\": response}, state.update(response=response)\n",
- "\n",
- "# %%\n",
- "import uuid\n",
- "from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
- "from sentence_transformers import SentenceTransformer\n",
- "\n",
- "from qdrant_client import QdrantClient\n",
- "from qdrant_client.http import models\n",
- "\n",
- "embeddings_model = SentenceTransformer(\n",
- " os.environ.get(\"embeddings_model\") or \"all-MiniLM-L6-v2\"\n",
- ")\n",
- "embeddings_dimension = 384\n",
- "\n",
- "\n",
- "@action(reads=[\"document_ingest\"], writes=[\"chunk_document\"])\n",
- "def chunk_document(state: State) -> tuple[dict, State]:\n",
- " document_base64 = state[\"document_ingest\"]\n",
- " document_bytes = base64.b64decode(document_base64)\n",
- " # Read PDF content\n",
- " pdf_reader = PyPDF2.PdfReader(BytesIO(document_bytes))\n",
- " pdf_text = \"\"\n",
- " for page in pdf_reader.pages:\n",
- " pdf_text += page.extract_text()\n",
- " \n",
- " # Initialize the text splitter\n",
- " text_splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)\n",
- " \n",
- " # Split the text into chunks\n",
- " chunks = text_splitter.split_text(pdf_text)\n",
- " \n",
- " # Update state with chunks\n",
- " return {\"chunk_document\" : chunks}, state.update(chunk_document=chunks)\n",
- "\n",
- "@action(reads=[\"chunk_document\"], writes=[\"doc_embeddings\"])\n",
- "def get_embeddings(state: State) -> tuple[dict, State]:\n",
- " chunks = state[\"chunk_document\"]\n",
- "\n",
- " embeddings_model = SentenceTransformer(os.environ.get(\"embeddings_model\") or \"all-MiniLM-L6-v2\")\n",
- " \n",
- " points = []\n",
- " for doc_id, chunk in enumerate(chunks):\n",
- " chunk_id = uuid.uuid5(uuid.NAMESPACE_DNS, f\"{doc_id}_1\")\n",
- "\n",
- " # TODO: Fix this so that the vector output is of the format PointStruct expects\n",
- " vector = embeddings_model.encode([chunk])[0]\n",
- " vector = vector.tolist()\n",
- "\n",
- " points.append(\n",
- " models.PointStruct(\n",
- " id=str(chunk_id),\n",
- " payload={\n",
- " \"metadata\": {\n",
- " # \"tenant_id\": app_config.app_id,\n",
- " # \"title\": chunk.metadata[\"title\"],\n",
- " # \"source\": chunk.metadata[\"source\"],\n",
- " \"chunk_id\": chunk_id,\n",
- " \"doc_id\": doc_id,\n",
- " },\n",
- " \"content\": chunk,\n",
- " },\n",
- " vector=vector,\n",
- " )\n",
- " )\n",
- " # Update state with embeddings\n",
- " return {\"doc_embeddings\" : points}, state.update(doc_embeddings=points)\n",
- "\n",
- "\n",
- "@action(reads=[\"doc_embeddings\"], writes=[\"db_success\"])\n",
- "def embeddings_to_db(state: State) -> tuple[dict, State]:\n",
- " embeddings = state[\"doc_embeddings\"]\n",
- " \n",
- " # Initialize Qdrant client\n",
- " qdrant_host = os.environ.get(\"QDRANT_HOST\", \"localhost\") # 49.13.162.67\n",
- " qdrant_port = int(os.environ.get(\"QDRANT_PORT\", \"6333\"))\n",
- " client = QdrantClient(host=qdrant_host, port=qdrant_port)\n",
- " \n",
- " # Define the collection name\n",
- " collection_name = os.environ.get(\"QDRANT_COLLECTION\", \"embeddings_collection\")\n",
- " if not client.collection_exists(\"{collection_name}\"):\n",
- " client.create_collection(\n",
- " collection_name=\"{collection_name}\",\n",
- " vectors_config=models.VectorParams(size=embeddings_dimension, distance=models.Distance.COSINE),\n",
- " )\n",
- "\n",
- " # Insert points into the collection\n",
- " response = client.upsert(\n",
- " collection_name=\"{collection_name}\",\n",
- " points=embeddings,\n",
- " )\n",
- " \n",
- " # Update state with success status\n",
- " return {\"db_success\" : response}, state.update(db_success=response)\n",
- "\n",
- "\n",
- "@action(reads=[\"db_success\"], writes=[\"db_response\"])\n",
- "def ingest_response(state: State) -> tuple[dict, State]:\n",
- " db_success = state[\"db_success\"]\n",
- " \n",
- " if db_success.status == \"completed\":\n",
- " message = \"Embeddings successfully ingested into Qdrant.\"\n",
- " else:\n",
- " message = \"Failed to ingest embeddings into Qdrant.\"\n",
- " \n",
- " return {\"db_response\" : message}, state.update(db_response=message)\n",
- "\n",
- "# %%\n",
- "app = (ApplicationBuilder()\n",
- " .with_actions(process_input, query_vector, generate_prompt, prompt_response, chunk_document, get_embeddings, embeddings_to_db, ingest_response)\n",
- " .with_transitions(\n",
- " # Furst chain\n",
- " (\"process_input\", \"query_vector\", expr(\"prompt is not None\")),\n",
- " (\"query_vector\", \"generate_prompt\"),\n",
- " (\"generate_prompt\", \"prompt_response\"),\n",
- " # Second chain\n",
- " (\"process_input\", \"chunk_document\", expr(\"document_ingest is not None\")),\n",
- " (\"chunk_document\", \"get_embeddings\"),\n",
- " (\"get_embeddings\", \"embeddings_to_db\"),\n",
- " (\"embeddings_to_db\", \"ingest_response\"),\n",
- " )\n",
- " .with_entrypoint(\"process_input\")\n",
- " .with_tracker(project=\"pfd_rag\")\n",
- " .build()\n",
- ")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 13,
- "id": "f57eff00-486e-450d-bc7c-e4551c5b0e76",
- "metadata": {},
- "outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "\n",
- "********************************************************************************\n",
- "-------------------------------------------------------------------\n",
- "Oh no an error! Need help with Burr?\n",
- "Join our discord and ask for help! https://discord.gg/4FxBMyzW5n\n",
- "-------------------------------------------------------------------\n",
- "> Action: `embeddings_to_db` encountered an error!<\n",
- "> State (at time of action):\n",
- "{'__PRIOR_STEP': 'get_embeddings',\n",
- " '__SEQUENCE_ID': 3,\n",
- " 'chunk_document': \"['AOA Form No. 1 10 (Rev. 10/13 ) - Copyright 2010...\",\n",
- " 'doc_embeddings': \"[PointStruct(id='29d77b6e-893a-51b8-916e-fa0c963b4...\",\n",
- " 'document_ingest': \"'JVBERi0xLjMKJcTl8uXrp/Og0MTGCjQgMCBvYmoKPDwgL0Zpb...\",\n",
- " 'prompt': None}\n",
- "> Inputs (at time of action):\n",
- "{'input': \"InputType(prompt=None, document='JVBERi0xLjMKJcTl8...\"}\n",
- "********************************************************************************\n",
- "Traceback (most recent call last):\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_exceptions.py\", line 10, in map_exceptions\n",
- " yield\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_backends/sync.py\", line 206, in connect_tcp\n",
- " sock = socket.create_connection(\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py\", line 851, in create_connection\n",
- " raise exceptions[0]\n",
- " File \"/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py\", line 836, in create_connection\n",
- " sock.connect(sa)\n",
- "ConnectionRefusedError: [Errno 61] Connection refused\n",
- "\n",
- "The above exception was the direct cause of the following exception:\n",
- "\n",
- "Traceback (most recent call last):\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_transports/default.py\", line 67, in map_httpcore_exceptions\n",
- " yield\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_transports/default.py\", line 231, in handle_request\n",
- " resp = self._pool.handle_request(req)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py\", line 268, in handle_request\n",
- " raise exc\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py\", line 251, in handle_request\n",
- " response = connection.handle_request(request)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection.py\", line 99, in handle_request\n",
- " raise exc\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection.py\", line 76, in handle_request\n",
- " stream = self._connect(request)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection.py\", line 124, in _connect\n",
- " stream = self._network_backend.connect_tcp(**kwargs)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_backends/sync.py\", line 205, in connect_tcp\n",
- " with map_exceptions(exc_map):\n",
- " File \"/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py\", line 155, in __exit__\n",
- " self.gen.throw(typ, value, traceback)\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_exceptions.py\", line 14, in map_exceptions\n",
- " raise to_exc(exc) from exc\n",
- "httpcore.ConnectError: [Errno 61] Connection refused\n",
- "\n",
- "The above exception was the direct cause of the following exception:\n",
- "\n",
- "Traceback (most recent call last):\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py\", line 103, in send_inner\n",
- " response = self._client.send(request)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_client.py\", line 915, in send\n",
- " response = self._send_handling_auth(\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_client.py\", line 943, in _send_handling_auth\n",
- " response = self._send_handling_redirects(\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_client.py\", line 980, in _send_handling_redirects\n",
- " response = self._send_single_request(request)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_client.py\", line 1016, in _send_single_request\n",
- " response = transport.handle_request(request)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_transports/default.py\", line 230, in handle_request\n",
- " with map_httpcore_exceptions():\n",
- " File \"/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py\", line 155, in __exit__\n",
- " self.gen.throw(typ, value, traceback)\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_transports/default.py\", line 84, in map_httpcore_exceptions\n",
- " raise mapped_exc(message) from exc\n",
- "httpx.ConnectError: [Errno 61] Connection refused\n",
- "\n",
- "During handling of the above exception, another exception occurred:\n",
- "\n",
- "Traceback (most recent call last):\n",
- " File \"/Users/elijahbenizzy/dev/dagworks/os/burr/burr/core/application.py\", line 375, in _step\n",
- " result, new_state = _run_single_step_action(next_action, self._state, action_inputs)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/dev/dagworks/os/burr/burr/core/application.py\", line 219, in _run_single_step_action\n",
- " result, new_state = action.run_and_update(state, **inputs)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/dev/dagworks/os/burr/burr/core/action.py\", line 472, in run_and_update\n",
- " return self._fn(state, **self._bound_params, **run_kwargs)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/var/folders/dq/sgyvfntx2h16h_7l7csqp_sr0000gn/T/ipykernel_34961/2756764752.py\", line 151, in embeddings_to_db\n",
- " if not client.collection_exists(\"{collection_name}\"):\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/qdrant_client.py\", line 1591, in collection_exists\n",
- " return self._client.collection_exists(collection_name=collection_name, **kwargs)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/qdrant_remote.py\", line 2063, in collection_exists\n",
- " result: Optional[models.CollectionExistence] = self.http.collections_api.collection_exists(\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api/collections_api.py\", line 1157, in collection_exists\n",
- " return self._build_for_collection_exists(\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api/collections_api.py\", line 87, in _build_for_collection_exists\n",
- " return self.api_client.request(\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py\", line 76, in request\n",
- " return self.send(request, type_)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py\", line 93, in send\n",
- " response = self.middleware(request, self.send_inner)\n",
- " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py\", line 202, in __call__\n",
- " return call_next(request)\n",
- " ^^^^^^^^^^^^^^^^^^\n",
- " File \"/Users/elijahbenizzy/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py\", line 105, in send_inner\n",
- " raise ResponseHandlingException(e)\n",
- "qdrant_client.http.exceptions.ResponseHandlingException: [Errno 61] Connection refused\n"
- ]
- },
- {
- "ename": "ResponseHandlingException",
- "evalue": "[Errno 61] Connection refused",
- "output_type": "error",
- "traceback": [
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
- "\u001b[0;31mConnectionRefusedError\u001b[0m Traceback (most recent call last)",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_exceptions.py:10\u001b[0m, in \u001b[0;36mmap_exceptions\u001b[0;34m(map)\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 10\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc: \u001b[38;5;66;03m# noqa: PIE786\u001b[39;00m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_backends/sync.py:206\u001b[0m, in \u001b[0;36mSyncBackend.connect_tcp\u001b[0;34m(self, host, port, timeout, local_address, socket_options)\u001b[0m\n\u001b[1;32m 205\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m map_exceptions(exc_map):\n\u001b[0;32m--> 206\u001b[0m sock \u001b[38;5;241m=\u001b[39m \u001b[43msocket\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcreate_connection\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 207\u001b[0m \u001b[43m \u001b[49m\u001b[43maddress\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 208\u001b[0m \u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 209\u001b[0m \u001b[43m \u001b[49m\u001b[43msource_address\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msource_address\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 210\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 211\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m option \u001b[38;5;129;01min\u001b[39;00m socket_options:\n",
- "File \u001b[0;32m/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py:851\u001b[0m, in \u001b[0;36mcreate_connection\u001b[0;34m(address, timeout, source_address, all_errors)\u001b[0m\n\u001b[1;32m 850\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m all_errors:\n\u001b[0;32m--> 851\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exceptions[\u001b[38;5;241m0\u001b[39m]\n\u001b[1;32m 852\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ExceptionGroup(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcreate_connection failed\u001b[39m\u001b[38;5;124m\"\u001b[39m, exceptions)\n",
- "File \u001b[0;32m/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py:836\u001b[0m, in \u001b[0;36mcreate_connection\u001b[0;34m(address, timeout, source_address, all_errors)\u001b[0m\n\u001b[1;32m 835\u001b[0m sock\u001b[38;5;241m.\u001b[39mbind(source_address)\n\u001b[0;32m--> 836\u001b[0m \u001b[43msock\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconnect\u001b[49m\u001b[43m(\u001b[49m\u001b[43msa\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 837\u001b[0m \u001b[38;5;66;03m# Break explicitly a reference cycle\u001b[39;00m\n",
- "\u001b[0;31mConnectionRefusedError\u001b[0m: [Errno 61] Connection refused",
- "\nThe above exception was the direct cause of the following exception:\n",
- "\u001b[0;31mConnectError\u001b[0m Traceback (most recent call last)",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_transports/default.py:67\u001b[0m, in \u001b[0;36mmap_httpcore_exceptions\u001b[0;34m()\u001b[0m\n\u001b[1;32m 66\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 67\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m\n\u001b[1;32m 68\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_transports/default.py:231\u001b[0m, in \u001b[0;36mHTTPTransport.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 230\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m map_httpcore_exceptions():\n\u001b[0;32m--> 231\u001b[0m resp \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_pool\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mreq\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 233\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(resp\u001b[38;5;241m.\u001b[39mstream, typing\u001b[38;5;241m.\u001b[39mIterable)\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py:268\u001b[0m, in \u001b[0;36mConnectionPool.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 267\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mresponse_closed(status)\n\u001b[0;32m--> 268\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exc\n\u001b[1;32m 269\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection_pool.py:251\u001b[0m, in \u001b[0;36mConnectionPool.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 250\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 251\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[43mconnection\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 252\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m ConnectionNotAvailable:\n\u001b[1;32m 253\u001b[0m \u001b[38;5;66;03m# The ConnectionNotAvailable exception is a special case, that\u001b[39;00m\n\u001b[1;32m 254\u001b[0m \u001b[38;5;66;03m# indicates we need to retry the request on a new connection.\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 258\u001b[0m \u001b[38;5;66;03m# might end up as an HTTP/2 connection, but which actually ends\u001b[39;00m\n\u001b[1;32m 259\u001b[0m \u001b[38;5;66;03m# up as HTTP/1.1.\u001b[39;00m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection.py:99\u001b[0m, in \u001b[0;36mHTTPConnection.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 98\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_connect_failed \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m---> 99\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m exc\n\u001b[1;32m 100\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_connection\u001b[38;5;241m.\u001b[39mis_available():\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection.py:76\u001b[0m, in \u001b[0;36mHTTPConnection.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 75\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 76\u001b[0m stream \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_connect\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 78\u001b[0m ssl_object \u001b[38;5;241m=\u001b[39m stream\u001b[38;5;241m.\u001b[39mget_extra_info(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mssl_object\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_sync/connection.py:124\u001b[0m, in \u001b[0;36mHTTPConnection._connect\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 123\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m Trace(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mconnect_tcp\u001b[39m\u001b[38;5;124m\"\u001b[39m, logger, request, kwargs) \u001b[38;5;28;01mas\u001b[39;00m trace:\n\u001b[0;32m--> 124\u001b[0m stream \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_network_backend\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mconnect_tcp\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 125\u001b[0m trace\u001b[38;5;241m.\u001b[39mreturn_value \u001b[38;5;241m=\u001b[39m stream\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_backends/sync.py:205\u001b[0m, in \u001b[0;36mSyncBackend.connect_tcp\u001b[0;34m(self, host, port, timeout, local_address, socket_options)\u001b[0m\n\u001b[1;32m 200\u001b[0m exc_map: ExceptionMapping \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 201\u001b[0m socket\u001b[38;5;241m.\u001b[39mtimeout: ConnectTimeout,\n\u001b[1;32m 202\u001b[0m \u001b[38;5;167;01mOSError\u001b[39;00m: ConnectError,\n\u001b[1;32m 203\u001b[0m }\n\u001b[0;32m--> 205\u001b[0m \u001b[43m\u001b[49m\u001b[38;5;28;43;01mwith\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mmap_exceptions\u001b[49m\u001b[43m(\u001b[49m\u001b[43mexc_map\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[1;32m 206\u001b[0m \u001b[43m \u001b[49m\u001b[43msock\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43msocket\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcreate_connection\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 207\u001b[0m \u001b[43m \u001b[49m\u001b[43maddress\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 208\u001b[0m \u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 209\u001b[0m \u001b[43m \u001b[49m\u001b[43msource_address\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43msource_address\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 210\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py:155\u001b[0m, in \u001b[0;36m_GeneratorContextManager.__exit__\u001b[0;34m(self, typ, value, traceback)\u001b[0m\n\u001b[1;32m 154\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 155\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mgen\u001b[38;5;241m.\u001b[39mthrow(typ, value, traceback)\n\u001b[1;32m 156\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mStopIteration\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m 157\u001b[0m \u001b[38;5;66;03m# Suppress StopIteration *unless* it's the same exception that\u001b[39;00m\n\u001b[1;32m 158\u001b[0m \u001b[38;5;66;03m# was passed to throw(). This prevents a StopIteration\u001b[39;00m\n\u001b[1;32m 159\u001b[0m \u001b[38;5;66;03m# raised inside the \"with\" statement from being suppressed.\u001b[39;00m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpcore/_exceptions.py:14\u001b[0m, in \u001b[0;36mmap_exceptions\u001b[0;34m(map)\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(exc, from_exc):\n\u001b[0;32m---> 14\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m to_exc(exc) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mexc\u001b[39;00m\n\u001b[1;32m 15\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m\n",
- "\u001b[0;31mConnectError\u001b[0m: [Errno 61] Connection refused",
- "\nThe above exception was the direct cause of the following exception:\n",
- "\u001b[0;31mConnectError\u001b[0m Traceback (most recent call last)",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py:103\u001b[0m, in \u001b[0;36mApiClient.send_inner\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 102\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 103\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_client\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msend\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 104\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_client.py:915\u001b[0m, in \u001b[0;36mClient.send\u001b[0;34m(self, request, stream, auth, follow_redirects)\u001b[0m\n\u001b[1;32m 913\u001b[0m auth \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_build_request_auth(request, auth)\n\u001b[0;32m--> 915\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_send_handling_auth\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 916\u001b[0m \u001b[43m \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 917\u001b[0m \u001b[43m \u001b[49m\u001b[43mauth\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mauth\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 918\u001b[0m \u001b[43m \u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 919\u001b[0m \u001b[43m \u001b[49m\u001b[43mhistory\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 920\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 921\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_client.py:943\u001b[0m, in \u001b[0;36mClient._send_handling_auth\u001b[0;34m(self, request, auth, follow_redirects, history)\u001b[0m\n\u001b[1;32m 942\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[0;32m--> 943\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_send_handling_redirects\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 944\u001b[0m \u001b[43m \u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 945\u001b[0m \u001b[43m \u001b[49m\u001b[43mfollow_redirects\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfollow_redirects\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 946\u001b[0m \u001b[43m \u001b[49m\u001b[43mhistory\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mhistory\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 947\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 948\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_client.py:980\u001b[0m, in \u001b[0;36mClient._send_handling_redirects\u001b[0;34m(self, request, follow_redirects, history)\u001b[0m\n\u001b[1;32m 978\u001b[0m hook(request)\n\u001b[0;32m--> 980\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_send_single_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 981\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_client.py:1016\u001b[0m, in \u001b[0;36mClient._send_single_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 1015\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m request_context(request\u001b[38;5;241m=\u001b[39mrequest):\n\u001b[0;32m-> 1016\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[43mtransport\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1018\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(response\u001b[38;5;241m.\u001b[39mstream, SyncByteStream)\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_transports/default.py:230\u001b[0m, in \u001b[0;36mHTTPTransport.handle_request\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 218\u001b[0m req \u001b[38;5;241m=\u001b[39m httpcore\u001b[38;5;241m.\u001b[39mRequest(\n\u001b[1;32m 219\u001b[0m method\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mmethod,\n\u001b[1;32m 220\u001b[0m url\u001b[38;5;241m=\u001b[39mhttpcore\u001b[38;5;241m.\u001b[39mURL(\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 228\u001b[0m extensions\u001b[38;5;241m=\u001b[39mrequest\u001b[38;5;241m.\u001b[39mextensions,\n\u001b[1;32m 229\u001b[0m )\n\u001b[0;32m--> 230\u001b[0m \u001b[43m\u001b[49m\u001b[38;5;28;43;01mwith\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mmap_httpcore_exceptions\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[1;32m 231\u001b[0m \u001b[43m \u001b[49m\u001b[43mresp\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_pool\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhandle_request\u001b[49m\u001b[43m(\u001b[49m\u001b[43mreq\u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m/opt/homebrew/Cellar/[email protected]/3.11.6/Frameworks/Python.framework/Versions/3.11/lib/python3.11/contextlib.py:155\u001b[0m, in \u001b[0;36m_GeneratorContextManager.__exit__\u001b[0;34m(self, typ, value, traceback)\u001b[0m\n\u001b[1;32m 154\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 155\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mgen\u001b[38;5;241m.\u001b[39mthrow(typ, value, traceback)\n\u001b[1;32m 156\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mStopIteration\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m exc:\n\u001b[1;32m 157\u001b[0m \u001b[38;5;66;03m# Suppress StopIteration *unless* it's the same exception that\u001b[39;00m\n\u001b[1;32m 158\u001b[0m \u001b[38;5;66;03m# was passed to throw(). This prevents a StopIteration\u001b[39;00m\n\u001b[1;32m 159\u001b[0m \u001b[38;5;66;03m# raised inside the \"with\" statement from being suppressed.\u001b[39;00m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/httpx/_transports/default.py:84\u001b[0m, in \u001b[0;36mmap_httpcore_exceptions\u001b[0;34m()\u001b[0m\n\u001b[1;32m 83\u001b[0m message \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mstr\u001b[39m(exc)\n\u001b[0;32m---> 84\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m mapped_exc(message) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mexc\u001b[39;00m\n",
- "\u001b[0;31mConnectError\u001b[0m: [Errno 61] Connection refused",
- "\nDuring handling of the above exception, another exception occurred:\n",
- "\u001b[0;31mResponseHandlingException\u001b[0m Traceback (most recent call last)",
- "Cell \u001b[0;32mIn[13], line 13\u001b[0m\n\u001b[1;32m 10\u001b[0m doc \u001b[38;5;241m=\u001b[39m InputType(prompt\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m, document\u001b[38;5;241m=\u001b[39mpdf_base64)\n\u001b[1;32m 11\u001b[0m \u001b[38;5;66;03m# doc = InputType(prompt=\"What is CRM?\", document=None)\u001b[39;00m\n\u001b[0;32m---> 13\u001b[0m \u001b[43mapp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m{\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43minput\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[43mdoc\u001b[49m\u001b[43m}\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mhalt_after\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mprompt_response\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mingest_response\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 15\u001b[0m \u001b[38;5;66;03m# %%\u001b[39;00m\n\u001b[1;32m 16\u001b[0m app\u001b[38;5;241m.\u001b[39mvisualize(include_conditions\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, include_state\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, \u001b[38;5;28mformat\u001b[39m\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpng\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
- "File \u001b[0;32m~/dev/dagworks/os/burr/burr/telemetry.py:273\u001b[0m, in \u001b[0;36mcapture_function_usage.<locals>.wrapped_fn\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 270\u001b[0m \u001b[38;5;129m@functools\u001b[39m\u001b[38;5;241m.\u001b[39mwraps(call_fn)\n\u001b[1;32m 271\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mwrapped_fn\u001b[39m(\u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 272\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 273\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcall_fn\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 274\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m 275\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_telemetry_enabled():\n",
- "File \u001b[0;32m~/dev/dagworks/os/burr/burr/core/application.py:694\u001b[0m, in \u001b[0;36mApplication.run\u001b[0;34m(self, halt_before, halt_after, inputs)\u001b[0m\n\u001b[1;32m 692\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28;01mTrue\u001b[39;00m:\n\u001b[1;32m 693\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 694\u001b[0m \u001b[38;5;28;43mnext\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mgen\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 695\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mStopIteration\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 696\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m e\u001b[38;5;241m.\u001b[39mvalue\n",
- "File \u001b[0;32m~/dev/dagworks/os/burr/burr/core/application.py:639\u001b[0m, in \u001b[0;36mApplication.iterate\u001b[0;34m(self, halt_before, halt_after, inputs)\u001b[0m\n\u001b[1;32m 636\u001b[0m prior_action: Optional[Action] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[1;32m 637\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mhas_next_action():\n\u001b[1;32m 638\u001b[0m \u001b[38;5;66;03m# self.step will only return None if there is no next action, so we can rely on tuple unpacking\u001b[39;00m\n\u001b[0;32m--> 639\u001b[0m prior_action, result, state \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstep\u001b[49m\u001b[43m(\u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43minputs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 640\u001b[0m \u001b[38;5;28;01myield\u001b[39;00m prior_action, result, state\n\u001b[1;32m 641\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_should_halt_iterate(halt_before, halt_after, prior_action):\n",
- "File \u001b[0;32m~/dev/dagworks/os/burr/burr/core/application.py:346\u001b[0m, in \u001b[0;36mApplication.step\u001b[0;34m(self, inputs)\u001b[0m\n\u001b[1;32m 343\u001b[0m \u001b[38;5;66;03m# we need to increment the sequence before we start computing\u001b[39;00m\n\u001b[1;32m 344\u001b[0m \u001b[38;5;66;03m# that way if we're replaying from state, we don't get stuck\u001b[39;00m\n\u001b[1;32m 345\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_increment_sequence_id()\n\u001b[0;32m--> 346\u001b[0m out \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_step\u001b[49m\u001b[43m(\u001b[49m\u001b[43minputs\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43minputs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m_run_hooks\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 347\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m out\n",
- "File \u001b[0;32m~/dev/dagworks/os/burr/burr/core/application.py:387\u001b[0m, in \u001b[0;36mApplication._step\u001b[0;34m(self, inputs, _run_hooks)\u001b[0m\n\u001b[1;32m 385\u001b[0m exc \u001b[38;5;241m=\u001b[39m e\n\u001b[1;32m 386\u001b[0m logger\u001b[38;5;241m.\u001b[39mexception(_format_error_message(next_action, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_state, inputs))\n\u001b[0;32m--> 387\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[1;32m 388\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[1;32m 389\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m _run_hooks:\n",
- "File \u001b[0;32m~/dev/dagworks/os/burr/burr/core/application.py:375\u001b[0m, in \u001b[0;36mApplication._step\u001b[0;34m(self, inputs, _run_hooks)\u001b[0m\n\u001b[1;32m 373\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m 374\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m next_action\u001b[38;5;241m.\u001b[39msingle_step:\n\u001b[0;32m--> 375\u001b[0m result, new_state \u001b[38;5;241m=\u001b[39m \u001b[43m_run_single_step_action\u001b[49m\u001b[43m(\u001b[49m\u001b[43mnext_action\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_state\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43maction_inputs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 376\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 377\u001b[0m result \u001b[38;5;241m=\u001b[39m _run_function(\n\u001b[1;32m 378\u001b[0m next_action, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_state, action_inputs, name\u001b[38;5;241m=\u001b[39mnext_action\u001b[38;5;241m.\u001b[39mname\n\u001b[1;32m 379\u001b[0m )\n",
- "File \u001b[0;32m~/dev/dagworks/os/burr/burr/core/application.py:219\u001b[0m, in \u001b[0;36m_run_single_step_action\u001b[0;34m(action, state, inputs)\u001b[0m\n\u001b[1;32m 217\u001b[0m \u001b[38;5;66;03m# TODO -- guard all reads/writes with a subset of the state\u001b[39;00m\n\u001b[1;32m 218\u001b[0m action\u001b[38;5;241m.\u001b[39mvalidate_inputs(inputs)\n\u001b[0;32m--> 219\u001b[0m result, new_state \u001b[38;5;241m=\u001b[39m \u001b[43maction\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun_and_update\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43minputs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 220\u001b[0m _validate_result(result, action\u001b[38;5;241m.\u001b[39mname)\n\u001b[1;32m 221\u001b[0m out \u001b[38;5;241m=\u001b[39m result, _state_update(state, new_state)\n",
- "File \u001b[0;32m~/dev/dagworks/os/burr/burr/core/action.py:472\u001b[0m, in \u001b[0;36mFunctionBasedAction.run_and_update\u001b[0;34m(self, state, **run_kwargs)\u001b[0m\n\u001b[1;32m 471\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mrun_and_update\u001b[39m(\u001b[38;5;28mself\u001b[39m, state: State, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mrun_kwargs) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m \u001b[38;5;28mtuple\u001b[39m[\u001b[38;5;28mdict\u001b[39m, State]:\n\u001b[0;32m--> 472\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_fn\u001b[49m\u001b[43m(\u001b[49m\u001b[43mstate\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_bound_params\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mrun_kwargs\u001b[49m\u001b[43m)\u001b[49m\n",
- "Cell \u001b[0;32mIn[10], line 151\u001b[0m, in \u001b[0;36membeddings_to_db\u001b[0;34m(state)\u001b[0m\n\u001b[1;32m 149\u001b[0m \u001b[38;5;66;03m# Define the collection name\u001b[39;00m\n\u001b[1;32m 150\u001b[0m collection_name \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39menviron\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mQDRANT_COLLECTION\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124membeddings_collection\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m--> 151\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[43mclient\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcollection_exists\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;132;43;01m{collection_name}\u001b[39;49;00m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m:\n\u001b[1;32m 152\u001b[0m client\u001b[38;5;241m.\u001b[39mcreate_collection(\n\u001b[1;32m 153\u001b[0m collection_name\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;132;01m{collection_name}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m,\n\u001b[1;32m 154\u001b[0m vectors_config\u001b[38;5;241m=\u001b[39mmodels\u001b[38;5;241m.\u001b[39mVectorParams(size\u001b[38;5;241m=\u001b[39membeddings_dimension, distance\u001b[38;5;241m=\u001b[39mmodels\u001b[38;5;241m.\u001b[39mDistance\u001b[38;5;241m.\u001b[39mCOSINE),\n\u001b[1;32m 155\u001b[0m )\n\u001b[1;32m 157\u001b[0m \u001b[38;5;66;03m# Insert points into the collection\u001b[39;00m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/qdrant_client.py:1591\u001b[0m, in \u001b[0;36mQdrantClient.collection_exists\u001b[0;34m(self, collection_name, **kwargs)\u001b[0m\n\u001b[1;32m 1581\u001b[0m \u001b[38;5;250m\u001b[39m\u001b[38;5;124;03m\"\"\"Check whether collection already exists\u001b[39;00m\n\u001b[1;32m 1582\u001b[0m \n\u001b[1;32m 1583\u001b[0m \u001b[38;5;124;03mArgs:\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1587\u001b[0m \u001b[38;5;124;03m True if collection exists, False if not\u001b[39;00m\n\u001b[1;32m 1588\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1589\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(kwargs) \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m, \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnknown arguments: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;28mlist\u001b[39m(kwargs\u001b[38;5;241m.\u001b[39mkeys())\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m-> 1591\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_client\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcollection_exists\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcollection_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcollection_name\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/qdrant_remote.py:2063\u001b[0m, in \u001b[0;36mQdrantRemote.collection_exists\u001b[0;34m(self, collection_name, **kwargs)\u001b[0m\n\u001b[1;32m 2057\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_prefer_grpc:\n\u001b[1;32m 2058\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mgrpc_collections\u001b[38;5;241m.\u001b[39mCollectionExists(\n\u001b[1;32m 2059\u001b[0m grpc\u001b[38;5;241m.\u001b[39mCollectionExistsRequest(collection_name\u001b[38;5;241m=\u001b[39mcollection_name),\n\u001b[1;32m 2060\u001b[0m timeout\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_timeout,\n\u001b[1;32m 2061\u001b[0m )\u001b[38;5;241m.\u001b[39mresult\u001b[38;5;241m.\u001b[39mexists\n\u001b[0;32m-> 2063\u001b[0m result: Optional[models\u001b[38;5;241m.\u001b[39mCollectionExistence] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhttp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcollections_api\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcollection_exists\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 2064\u001b[0m \u001b[43m \u001b[49m\u001b[43mcollection_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcollection_name\u001b[49m\n\u001b[1;32m 2065\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mresult\n\u001b[1;32m 2066\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m result \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCollection exists returned None\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 2067\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m result\u001b[38;5;241m.\u001b[39mexists\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api/collections_api.py:1157\u001b[0m, in \u001b[0;36mSyncCollectionsApi.collection_exists\u001b[0;34m(self, collection_name)\u001b[0m\n\u001b[1;32m 1150\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcollection_exists\u001b[39m(\n\u001b[1;32m 1151\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 1152\u001b[0m collection_name: \u001b[38;5;28mstr\u001b[39m,\n\u001b[1;32m 1153\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m m\u001b[38;5;241m.\u001b[39mInlineResponse2008:\n\u001b[1;32m 1154\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 1155\u001b[0m \u001b[38;5;124;03m Returns \\\"true\\\" if the given collection name exists, and \\\"false\\\" otherwise\u001b[39;00m\n\u001b[1;32m 1156\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m-> 1157\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_build_for_collection_exists\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1158\u001b[0m \u001b[43m \u001b[49m\u001b[43mcollection_name\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcollection_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1159\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api/collections_api.py:87\u001b[0m, in \u001b[0;36m_CollectionsApi._build_for_collection_exists\u001b[0;34m(self, collection_name)\u001b[0m\n\u001b[1;32m 82\u001b[0m path_params \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 83\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcollection_name\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;28mstr\u001b[39m(collection_name),\n\u001b[1;32m 84\u001b[0m }\n\u001b[1;32m 86\u001b[0m headers \u001b[38;5;241m=\u001b[39m {}\n\u001b[0;32m---> 87\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mapi_client\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrequest\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 88\u001b[0m \u001b[43m \u001b[49m\u001b[43mtype_\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mm\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mInlineResponse2008\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 89\u001b[0m \u001b[43m \u001b[49m\u001b[43mmethod\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mGET\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 90\u001b[0m \u001b[43m \u001b[49m\u001b[43murl\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m/collections/\u001b[39;49m\u001b[38;5;132;43;01m{collection_name}\u001b[39;49;00m\u001b[38;5;124;43m/exists\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 91\u001b[0m \u001b[43m \u001b[49m\u001b[43mheaders\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mheaders\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mif\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mheaders\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01melse\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 92\u001b[0m \u001b[43m \u001b[49m\u001b[43mpath_params\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpath_params\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 93\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py:76\u001b[0m, in \u001b[0;36mApiClient.request\u001b[0;34m(self, type_, method, url, path_params, **kwargs)\u001b[0m\n\u001b[1;32m 74\u001b[0m kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtimeout\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mint\u001b[39m(kwargs[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mparams\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtimeout\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n\u001b[1;32m 75\u001b[0m request \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_client\u001b[38;5;241m.\u001b[39mbuild_request(method, url, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n\u001b[0;32m---> 76\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msend\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtype_\u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py:93\u001b[0m, in \u001b[0;36mApiClient.send\u001b[0;34m(self, request, type_)\u001b[0m\n\u001b[1;32m 92\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21msend\u001b[39m(\u001b[38;5;28mself\u001b[39m, request: Request, type_: Type[T]) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m T:\n\u001b[0;32m---> 93\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmiddleware\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msend_inner\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 94\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m response\u001b[38;5;241m.\u001b[39mstatus_code \u001b[38;5;129;01min\u001b[39;00m [\u001b[38;5;241m200\u001b[39m, \u001b[38;5;241m201\u001b[39m, \u001b[38;5;241m202\u001b[39m]:\n\u001b[1;32m 95\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py:202\u001b[0m, in \u001b[0;36mBaseMiddleware.__call__\u001b[0;34m(self, request, call_next)\u001b[0m\n\u001b[1;32m 201\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__call__\u001b[39m(\u001b[38;5;28mself\u001b[39m, request: Request, call_next: Send) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m Response:\n\u001b[0;32m--> 202\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mcall_next\u001b[49m\u001b[43m(\u001b[49m\u001b[43mrequest\u001b[49m\u001b[43m)\u001b[49m\n",
- "File \u001b[0;32m~/.pyenv/versions/3.11/envs/burr-3-11/lib/python3.11/site-packages/qdrant_client/http/api_client.py:105\u001b[0m, in \u001b[0;36mApiClient.send_inner\u001b[0;34m(self, request)\u001b[0m\n\u001b[1;32m 103\u001b[0m response \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_client\u001b[38;5;241m.\u001b[39msend(request)\n\u001b[1;32m 104\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m--> 105\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m ResponseHandlingException(e)\n\u001b[1;32m 106\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m response\n",
- "\u001b[0;31mResponseHandlingException\u001b[0m: [Errno 61] Connection refused"
- ]
- }
- ],
- "source": [
- "\n",
- "# %%\n",
- "# Read the PDF file and create the document input\n",
- "with open(\"/Users/elijahbenizzy/Downloads/smoke_co_detectors.pdf\", \"rb\") as f:\n",
- " pdf_content = f.read()\n",
- "\n",
- "# Encode the PDF content to base64\n",
- "pdf_base64 = base64.b64encode(pdf_content).decode(\"utf-8\")\n",
- "\n",
- "# Create an instance of InputType with the PDF content\n",
- "doc = InputType(prompt=None, document=pdf_base64)\n",
- "# doc = InputType(prompt=\"What is CRM?\", document=None)\n",
- "\n",
- "app.run(inputs={\"input\": doc}, halt_after=[\"prompt_response\", \"ingest_response\"])\n",
- "\n",
- "# %%\n",
- "app.visualize(include_conditions=True, include_state=True, format=\"png\")\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "f0266f08-e960-48fd-b3a4-b149922b7b47",
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3 (ipykernel)",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.11.6"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}