diff --git a/README.md b/README.md index 7639f0df7..f5b3a2d21 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ Call the `Guard` object with the LLM API call as the first argument and add any import openai # Wrap the OpenAI API call with the `guard` object -raw_llm_output, validated_output = guard( +raw_llm_output, validated_output, *rest = guard( openai.Completion.create, engine="text-davinci-003", max_tokens=1024, diff --git a/docs/concepts/guard.md b/docs/concepts/guard.md index 11b4f400c..5d420d866 100644 --- a/docs/concepts/guard.md +++ b/docs/concepts/guard.md @@ -19,7 +19,7 @@ from guardrails import Guard guard = Guard.from_rail(...) -raw_output, validated_output = guard( +raw_output, validated_output, *rest = guard( openai.Completion.create, engine="text-davinci-003", max_tokens=1024, diff --git a/docs/concepts/validators.md b/docs/concepts/validators.md index 69b0d5275..793e99512 100644 --- a/docs/concepts/validators.md +++ b/docs/concepts/validators.md @@ -35,7 +35,7 @@ Sometimes validators need addtional parameters that are only availble during run ```python guard = Guard.from_rail("my_railspec.rail") -raw_output, guarded_output = guard( +raw_output, guarded_output, *rest = guard( llm_api=openai.ChatCompletion.create, model="gpt-3.5-turbo", num_reasks=3, @@ -134,7 +134,7 @@ ${guardrails.complete_json_suffix} guard = Guard.from_rail_string(rail_string=rail_str) -raw_output, guarded_output = guard( +raw_output, guarded_output, *rest = guard( llm_api=openai.ChatCompletion.create, model="gpt-3.5-turbo" ) diff --git a/docs/defining_guards/pydantic.ipynb b/docs/defining_guards/pydantic.ipynb index 5d1c0fd15..a55295999 100644 --- a/docs/defining_guards/pydantic.ipynb +++ b/docs/defining_guards/pydantic.ipynb @@ -71,7 +71,7 @@ "\"\"\"\n", "guard = Guard.from_pydantic(output_class=Pet, prompt=prompt)\n", "\n", - "raw_llm_output, validated_output = guard(\n", + "raw_llm_output, validated_output, *rest = guard(\n", " llm_api=openai.Completion.create,\n", " engine=\"text-davinci-003\"\n", ")\n", @@ -378,7 +378,7 @@ "\n", "guard = Guard.from_pydantic(output_class=Pet, prompt=prompt)\n", "\n", - "raw_llm_output, validated_output = guard(\n", + "raw_llm_output, validated_output, *rest = guard(\n", " llm_api=openai.Completion.create,\n", " engine=\"text-davinci-003\",\n", " max_tokens=1024,\n", @@ -576,7 +576,7 @@ "\"\"\"\n", "\n", "guard = Guard.from_pydantic(output_class=Pet, prompt=prompt)\n", - "raw_llm_output, validated_output = guard(\n", + "raw_llm_output, validated_output, *rest = guard(\n", " llm_api=openai.Completion.create,\n", " engine=\"text-davinci-003\",\n", " max_tokens=1024,\n", diff --git a/docs/defining_guards/rail.md b/docs/defining_guards/rail.md index 54012e98a..c71d7cdcf 100644 --- a/docs/defining_guards/rail.md +++ b/docs/defining_guards/rail.md @@ -98,7 +98,7 @@ import guardrails as gd # Create a Guard object guard = gd.Guard.from_rail('path/to/rail/spec.xml') # (1)! -validated_output = guard( +_, validated_output, *rest = guard( openai.Completion.create, # (2)! **prompt_args, *args, diff --git a/docs/defining_guards/strings.ipynb b/docs/defining_guards/strings.ipynb index 06d71e2db..6d951c3df 100644 --- a/docs/defining_guards/strings.ipynb +++ b/docs/defining_guards/strings.ipynb @@ -209,7 +209,7 @@ " prompt=\"Generate a puppy name\"\n", ")\n", "\n", - "raw_llm_output, validated_llm_response = guard(openai.Completion.create)\n", + "raw_llm_output, validated_llm_response, *rest = guard(openai.Completion.create)\n", "print(validated_llm_response)\n", "print(guard.state.most_recent_call.tree)" ] diff --git a/docs/examples/bug_free_python_code.ipynb b/docs/examples/bug_free_python_code.ipynb index 03bcc71fe..414e22bba 100644 --- a/docs/examples/bug_free_python_code.ipynb +++ b/docs/examples/bug_free_python_code.ipynb @@ -38,7 +38,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -75,7 +75,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -113,7 +113,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -131,18 +131,9 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 4, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/Users/zaydsimjee/workspace/guardrails/guardrails/validatorsattr.py:285: UserWarning: Validator bug-free-python is not valid for element pythoncode.\n", - " warnings.warn(\n" - ] - } - ], + "outputs": [], "source": [ "guard = gd.Guard.from_rail_string(rail_str)" ] @@ -156,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -173,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -254,7 +245,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -264,7 +255,7 @@ "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.\n", "\"\"\"\n", "\n", - "raw_llm_response, validated_response = guard(\n", + "response = guard(\n", " openai.Completion.create,\n", " prompt_params={\"leetcode_problem\": leetcode_problem},\n", " engine=\"text-davinci-003\",\n", @@ -285,7 +276,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -313,7 +304,7 @@ } ], "source": [ - "print(validated_response)" + "print(response.validated_output)" ] }, { @@ -326,7 +317,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -358,7 +349,10 @@ } ], "source": [ - "print(validated_response[\"python_code\"])" + "if response.validated_output is not None:\n", + " print(response.validated_output[\"python_code\"])\n", + "elif response.error is not None:\n", + " print(response.error)" ] }, { @@ -371,7 +365,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -390,7 +384,7 @@ ], "source": [ "try:\n", - " exec(validated_response[\"python_code\"])\n", + " exec(response.validated_output[\"python_code\"])\n", " print(\"Success!\")\n", "except Exception as e:\n", " print(\"Failed!\")" @@ -413,7 +407,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.11.6" }, "orig_nbformat": 4, "vscode": { diff --git a/docs/examples/extracting_entities.ipynb b/docs/examples/extracting_entities.ipynb index 7c125a2db..f3bc00ff8 100644 --- a/docs/examples/extracting_entities.ipynb +++ b/docs/examples/extracting_entities.ipynb @@ -25,7 +25,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -94,7 +94,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -139,7 +139,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -192,20 +192,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 4, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/zayd/workspace/guardrails-poc/.venv/lib/python3.11/site-packages/guardrails/schema.py:218: UserWarning: Validator 1-indexed is not valid for element integer.\n", - " warnings.warn(\n", - "/home/zayd/workspace/guardrails-poc/.venv/lib/python3.11/site-packages/guardrails/schema.py:218: UserWarning: Validator percentage is not valid for element float.\n", - " warnings.warn(\n" - ] - } - ], + "outputs": [], "source": [ "guard = gd.Guard.from_rail_string(rail_str)" ] @@ -219,7 +208,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -238,7 +227,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -323,22 +312,13 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 7, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Async event loop found, but guard was invoked synchronously.For validator parallelization, please call `validate_async` instead.\n", - "Async event loop found, but guard was invoked synchronously.For validator parallelization, please call `validate_async` instead.\n" - ] - } - ], + "outputs": [], "source": [ "import openai\n", "\n", - "raw_llm_response, validated_response = guard(\n", + "raw_llm_response, validated_response, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={\"document\": content[:6000]},\n", " engine=\"text-davinci-003\",\n", @@ -359,7 +339,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -367,62 +347,44 @@ "text/html": [ "
{\n", " 'fees': [\n", - " {'index': 1, 'name': 'annual membership', 'explanation': 'Annual Membership Fee', 'value': 0},\n", + " {'index': 1, 'name': 'annual_membership', 'explanation': 'Annual Membership Fee', 'value': 0.0},\n", " {\n", " 'index': 2,\n", - " 'name': 'my chase',\n", + " 'name': 'my_chase_plan',\n", " 'explanation': 'My Chase Plan Fee (fixed finance charge)',\n", - " 'value': 0.0172\n", + " 'value': 1.72\n", " },\n", " {\n", " 'index': 3,\n", - " 'name': 'balance transfers',\n", + " 'name': 'balance_transfers',\n", " 'explanation': 'Balance Transfers Intro fee of either $5 or 3% of the amount of each transfer, \n", "whichever is greater, on transfers made within 60 days of account opening. After that: Either $5 or 5% of the \n", "amount of each transfer, whichever is greater.',\n", - " 'value': 0.05\n", + " 'value': 3.0\n", " },\n", " {\n", " 'index': 4,\n", - " 'name': 'cash advances',\n", + " 'name': 'cash_advances',\n", " 'explanation': 'Either $10 or 5% of the amount of each transaction, whichever is greater.',\n", - " 'value': 0.05\n", + " 'value': 5.0\n", " },\n", " {\n", " 'index': 5,\n", - " 'name': 'foreign transactions',\n", + " 'name': 'foreign_transactions',\n", " 'explanation': 'Foreign Transactions 3% of the amount of each transaction in U.S. dollars.',\n", - " 'value': 0.03\n", + " 'value': 3.0\n", " },\n", - " {'index': 6, 'name': 'late payment', 'explanation': 'Late Payment Up to $40.', 'value': 0},\n", - " {'index': 7, 'name': 'over-the-credit-limit', 'explanation': 'Over-the-Credit-Limit None', 'value': 0},\n", - " {'index': 8, 'name': 'return payment', 'explanation': 'Return Payment Up to $40.', 'value': 0},\n", - " {'index': 9, 'name': 'return check', 'explanation': 'Return Check None', 'value': 0}\n", + " {'index': 6, 'name': 'late_payment', 'explanation': 'Late Payment Up to $40.', 'value': 0.0},\n", + " {'index': 7, 'name': 'over_the_credit_limit', 'explanation': 'Over-the-Credit-Limit None', 'value': 0.0},\n", + " {'index': 8, 'name': 'return_payment', 'explanation': 'Return Payment Up to $40.', 'value': 0.0},\n", + " {'index': 9, 'name': 'return_check', 'explanation': 'Return Check None', 'value': 0.0}\n", " ],\n", " 'interest_rates': {\n", - " 'purchase': {\n", - " 'apr': 0,\n", - " 'explanation': 'Purchase Annual Percentage Rate (APR) 0% Intro APR for the first 18 months that your \n", - "Account is open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.'\n", - " },\n", - " 'my_chase_loan': {\n", - " 'apr': 19.49,\n", - " 'explanation': 'My Chase Loan SM APR 19.49%. This APR will vary with the market based on the Prime \n", - "Rate.'\n", - " },\n", - " 'balance_transfer': {\n", - " 'apr': 0,\n", - " 'explanation': 'Balance Transfer APR 0% Intro APR for the first 18 months that your Account is open. \n", - "After that, 19.49%. This APR will vary with the market based on the Prime Rate.'\n", - " },\n", - " 'cash_advance': {\n", - " 'apr': 29.49,\n", - " 'explanation': 'Cash Advance APR 29.49%. This APR will vary with the market based on the Prime Rate.'\n", - " },\n", - " 'penalty': {\n", - " 'apr': 29.99,\n", - " 'explanation': 'Up to 29.99%. This APR will vary with the market based on the Prime Rate.'\n", - " }\n", + " 'purchase': {'apr': 0, 'after_apr': 19.49},\n", + " 'my_chase_loan': {'apr': 19.49},\n", + " 'balance_transfer': {'apr': 0, 'after_apr': 19.49},\n", + " 'cash_advance': {'apr': 29.49},\n", + " 'penalty': {'apr': 0, 'maximum_apr': 29.99}\n", " }\n", "}\n", "\n" @@ -430,62 +392,44 @@ "text/plain": [ "\u001b[1m{\u001b[0m\n", " \u001b[32m'fees'\u001b[0m: \u001b[1m[\u001b[0m\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m1\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'annual membership'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Annual Membership Fee'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m1\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'annual_membership'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Annual Membership Fee'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0.0\u001b[0m\u001b[1m}\u001b[0m,\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'index'\u001b[0m: \u001b[1;36m2\u001b[0m,\n", - " \u001b[32m'name'\u001b[0m: \u001b[32m'my chase'\u001b[0m,\n", + " \u001b[32m'name'\u001b[0m: \u001b[32m'my_chase_plan'\u001b[0m,\n", " \u001b[32m'explanation'\u001b[0m: \u001b[32m'My Chase Plan Fee \u001b[0m\u001b[32m(\u001b[0m\u001b[32mfixed finance charge\u001b[0m\u001b[32m)\u001b[0m\u001b[32m'\u001b[0m,\n", - " \u001b[32m'value'\u001b[0m: \u001b[1;36m0.0172\u001b[0m\n", + " \u001b[32m'value'\u001b[0m: \u001b[1;36m1.72\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'index'\u001b[0m: \u001b[1;36m3\u001b[0m,\n", - " \u001b[32m'name'\u001b[0m: \u001b[32m'balance transfers'\u001b[0m,\n", + " \u001b[32m'name'\u001b[0m: \u001b[32m'balance_transfers'\u001b[0m,\n", " \u001b[32m'explanation'\u001b[0m: \u001b[32m'Balance Transfers Intro fee of either $5 or 3% of the amount of each transfer, \u001b[0m\n", "\u001b[32mwhichever is greater, on transfers made within 60 days of account opening. After that: Either $5 or 5% of the \u001b[0m\n", "\u001b[32mamount of each transfer, whichever is greater.'\u001b[0m,\n", - " \u001b[32m'value'\u001b[0m: \u001b[1;36m0.05\u001b[0m\n", + " \u001b[32m'value'\u001b[0m: \u001b[1;36m3.0\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'index'\u001b[0m: \u001b[1;36m4\u001b[0m,\n", - " \u001b[32m'name'\u001b[0m: \u001b[32m'cash advances'\u001b[0m,\n", + " \u001b[32m'name'\u001b[0m: \u001b[32m'cash_advances'\u001b[0m,\n", " \u001b[32m'explanation'\u001b[0m: \u001b[32m'Either $10 or 5% of the amount of each transaction, whichever is greater.'\u001b[0m,\n", - " \u001b[32m'value'\u001b[0m: \u001b[1;36m0.05\u001b[0m\n", + " \u001b[32m'value'\u001b[0m: \u001b[1;36m5.0\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'index'\u001b[0m: \u001b[1;36m5\u001b[0m,\n", - " \u001b[32m'name'\u001b[0m: \u001b[32m'foreign transactions'\u001b[0m,\n", + " \u001b[32m'name'\u001b[0m: \u001b[32m'foreign_transactions'\u001b[0m,\n", " \u001b[32m'explanation'\u001b[0m: \u001b[32m'Foreign Transactions 3% of the amount of each transaction in U.S. dollars.'\u001b[0m,\n", - " \u001b[32m'value'\u001b[0m: \u001b[1;36m0.03\u001b[0m\n", + " \u001b[32m'value'\u001b[0m: \u001b[1;36m3.0\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m6\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'late payment'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Late Payment Up to $40.'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0\u001b[0m\u001b[1m}\u001b[0m,\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m7\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'over-the-credit-limit'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Over-the-Credit-Limit None'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0\u001b[0m\u001b[1m}\u001b[0m,\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m8\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'return payment'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Return Payment Up to $40.'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0\u001b[0m\u001b[1m}\u001b[0m,\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m9\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'return check'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Return Check None'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0\u001b[0m\u001b[1m}\u001b[0m\n", + " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m6\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'late_payment'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Late Payment Up to $40.'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0.0\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m7\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'over_the_credit_limit'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Over-the-Credit-Limit None'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0.0\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m8\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'return_payment'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Return Payment Up to $40.'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0.0\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m9\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'return_check'\u001b[0m, \u001b[32m'explanation'\u001b[0m: \u001b[32m'Return Check None'\u001b[0m, \u001b[32m'value'\u001b[0m: \u001b[1;36m0.0\u001b[0m\u001b[1m}\u001b[0m\n", " \u001b[1m]\u001b[0m,\n", " \u001b[32m'interest_rates'\u001b[0m: \u001b[1m{\u001b[0m\n", - " \u001b[32m'purchase'\u001b[0m: \u001b[1m{\u001b[0m\n", - " \u001b[32m'apr'\u001b[0m: \u001b[1;36m0\u001b[0m,\n", - " \u001b[32m'explanation'\u001b[0m: \u001b[32m'Purchase Annual Percentage Rate \u001b[0m\u001b[32m(\u001b[0m\u001b[32mAPR\u001b[0m\u001b[32m)\u001b[0m\u001b[32m 0% Intro APR for the first 18 months that your \u001b[0m\n", - "\u001b[32mAccount is open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.'\u001b[0m\n", - " \u001b[1m}\u001b[0m,\n", - " \u001b[32m'my_chase_loan'\u001b[0m: \u001b[1m{\u001b[0m\n", - " \u001b[32m'apr'\u001b[0m: \u001b[1;36m19.49\u001b[0m,\n", - " \u001b[32m'explanation'\u001b[0m: \u001b[32m'My Chase Loan SM APR 19.49%. This APR will vary with the market based on the Prime \u001b[0m\n", - "\u001b[32mRate.'\u001b[0m\n", - " \u001b[1m}\u001b[0m,\n", - " \u001b[32m'balance_transfer'\u001b[0m: \u001b[1m{\u001b[0m\n", - " \u001b[32m'apr'\u001b[0m: \u001b[1;36m0\u001b[0m,\n", - " \u001b[32m'explanation'\u001b[0m: \u001b[32m'Balance Transfer APR 0% Intro APR for the first 18 months that your Account is open. \u001b[0m\n", - "\u001b[32mAfter that, 19.49%. This APR will vary with the market based on the Prime Rate.'\u001b[0m\n", - " \u001b[1m}\u001b[0m,\n", - " \u001b[32m'cash_advance'\u001b[0m: \u001b[1m{\u001b[0m\n", - " \u001b[32m'apr'\u001b[0m: \u001b[1;36m29.49\u001b[0m,\n", - " \u001b[32m'explanation'\u001b[0m: \u001b[32m'Cash Advance APR 29.49%. This APR will vary with the market based on the Prime Rate.'\u001b[0m\n", - " \u001b[1m}\u001b[0m,\n", - " \u001b[32m'penalty'\u001b[0m: \u001b[1m{\u001b[0m\n", - " \u001b[32m'apr'\u001b[0m: \u001b[1;36m29.99\u001b[0m,\n", - " \u001b[32m'explanation'\u001b[0m: \u001b[32m'Up to 29.99%. This APR will vary with the market based on the Prime Rate.'\u001b[0m\n", - " \u001b[1m}\u001b[0m\n", + " \u001b[32m'purchase'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'apr'\u001b[0m: \u001b[1;36m0\u001b[0m, \u001b[32m'after_apr'\u001b[0m: \u001b[1;36m19.49\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[32m'my_chase_loan'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'apr'\u001b[0m: \u001b[1;36m19.49\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[32m'balance_transfer'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'apr'\u001b[0m: \u001b[1;36m0\u001b[0m, \u001b[32m'after_apr'\u001b[0m: \u001b[1;36m19.49\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[32m'cash_advance'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'apr'\u001b[0m: \u001b[1;36m29.49\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[32m'penalty'\u001b[0m: \u001b[1m{\u001b[0m\u001b[32m'apr'\u001b[0m: \u001b[1;36m0\u001b[0m, \u001b[32m'maximum_apr'\u001b[0m: \u001b[1;36m29.99\u001b[0m\u001b[1m}\u001b[0m\n", " \u001b[1m}\u001b[0m\n", "\u001b[1m}\u001b[0m\n" ] @@ -500,7 +444,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -666,10 +610,7 @@ "│ │ │ │ │\n", "│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", "│ │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", - "│ │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n", - "│ │ │ ┃ Role ┃ Content ┃ │ │\n", - "│ │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n", - "│ │ │ └──────┴─────────┘ │ │\n", + "│ │ │ No message history. │ │\n", "│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", "│ │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", "│ │ │ { │ │\n", @@ -692,20 +633,20 @@ "│ │ │ \"explanation\": \"Balance Transfers Intro fee of either $5 or 3% of the amount of each │ │\n", "│ │ │ transfer, whichever is greater, on transfers made within 60 days of account opening. After that: Either │ │\n", "│ │ │ $5 or 5% of the amount of each transfer, whichever is greater.\", │ │\n", - "│ │ │ \"value\": 0.05 │ │\n", + "│ │ │ \"value\": 3 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ \"index\": 4, │ │\n", "│ │ │ \"name\": \"cash advances\", │ │\n", "│ │ │ \"explanation\": \"Either $10 or 5% of the amount of each transaction, whichever is greater.\", │ │\n", - "│ │ │ \"value\": 0.05 │ │\n", + "│ │ │ \"value\": 5 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ \"index\": 5, │ │\n", "│ │ │ \"name\": \"foreign transactions\", │ │\n", "│ │ │ \"explanation\": \"Foreign Transactions 3% of the amount of each transaction in U.S. │ │\n", "│ │ │ dollars.\", │ │\n", - "│ │ │ \"value\": 0.03 │ │\n", + "│ │ │ \"value\": 3 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ \"index\": 6, │ │\n", @@ -735,28 +676,21 @@ "│ │ │ \"interest_rates\": { │ │\n", "│ │ │ \"purchase\": { │ │\n", "│ │ │ \"apr\": 0, │ │\n", - "│ │ │ \"explanation\": \"Purchase Annual Percentage Rate (APR) 0% Intro APR for the first 18 months │ │\n", - "│ │ │ that your Account is open. After that, 19.49%. This APR will vary with the market based on the Prime │ │\n", - "│ │ │ Rate.\" │ │\n", + "│ │ │ \"after_apr\": 19.49 │ │\n", "│ │ │ }, │ │\n", "│ │ │ \"my_chase_loan\": { │ │\n", - "│ │ │ \"apr\": 19.49, │ │\n", - "│ │ │ \"explanation\": \"My Chase Loan SM APR 19.49%. This APR will vary with the market based on │ │\n", - "│ │ │ the Prime Rate.\" │ │\n", + "│ │ │ \"apr\": 19.49 │ │\n", "│ │ │ }, │ │\n", "│ │ │ \"balance_transfer\": { │ │\n", "│ │ │ \"apr\": 0, │ │\n", - "│ │ │ \"explanation\": \"Balance Transfer APR 0% Intro APR for the first 18 months that your Account │ │\n", - "│ │ │ is open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.\" │ │\n", + "│ │ │ \"after_apr\": 19.49 │ │\n", "│ │ │ }, │ │\n", "│ │ │ \"cash_advance\": { │ │\n", - "│ │ │ \"apr\": 29.49, │ │\n", - "│ │ │ \"explanation\": \"Cash Advance APR 29.49%. This APR will vary with the market based on the │ │\n", - "│ │ │ Prime Rate.\" │ │\n", + "│ │ │ \"apr\": 29.49 │ │\n", "│ │ │ }, │ │\n", "│ │ │ \"penalty\": { │ │\n", - "│ │ │ \"apr\": 29.99, │ │\n", - "│ │ │ \"explanation\": \"Up to 29.99%. This APR will vary with the market based on the Prime Rate.\" │ │\n", + "│ │ │ \"apr\": 0, │ │\n", + "│ │ │ \"maximum_apr\": 29.99 │ │\n", "│ │ │ } │ │\n", "│ │ │ } │ │\n", "│ │ │ } │ │\n", @@ -768,7 +702,7 @@ "│ │ │ 'index': 1, │ │\n", "│ │ │ 'name': 'annual membership', │ │\n", "│ │ │ 'explanation': 'Annual Membership Fee', │ │\n", - "│ │ │ 'value': 0 │ │\n", + "│ │ │ 'value': 0.0 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ 'index': 2, │ │\n", @@ -793,26 +727,26 @@ "│ │ │ 'explanation': 'Balance Transfers Intro fee of either $5 or 3% of the amount of each │ │\n", "│ │ │ transfer, whichever is greater, on transfers made within 60 days of account opening. After that: Either │ │\n", "│ │ │ $5 or 5% of the amount of each transfer, whichever is greater.', │ │\n", - "│ │ │ 'value': 0.05 │ │\n", + "│ │ │ 'value': 3.0 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ 'index': 4, │ │\n", "│ │ │ 'name': 'cash advances', │ │\n", "│ │ │ 'explanation': 'Either $10 or 5% of the amount of each transaction, whichever is greater.', │ │\n", - "│ │ │ 'value': 0.05 │ │\n", + "│ │ │ 'value': 5.0 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ 'index': 5, │ │\n", "│ │ │ 'name': 'foreign transactions', │ │\n", "│ │ │ 'explanation': 'Foreign Transactions 3% of the amount of each transaction in U.S. │ │\n", "│ │ │ dollars.', │ │\n", - "│ │ │ 'value': 0.03 │ │\n", + "│ │ │ 'value': 3.0 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ 'index': 6, │ │\n", "│ │ │ 'name': 'late payment', │ │\n", "│ │ │ 'explanation': 'Late Payment Up to $40.', │ │\n", - "│ │ │ 'value': 0 │ │\n", + "│ │ │ 'value': 0.0 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ 'index': 7, │ │\n", @@ -829,47 +763,27 @@ "│ │ │ path=['fees', 6, 'name'] │ │\n", "│ │ │ ), │ │\n", "│ │ │ 'explanation': 'Over-the-Credit-Limit None', │ │\n", - "│ │ │ 'value': 0 │ │\n", + "│ │ │ 'value': 0.0 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ 'index': 8, │ │\n", "│ │ │ 'name': 'return payment', │ │\n", "│ │ │ 'explanation': 'Return Payment Up to $40.', │ │\n", - "│ │ │ 'value': 0 │ │\n", + "│ │ │ 'value': 0.0 │ │\n", "│ │ │ }, │ │\n", "│ │ │ { │ │\n", "│ │ │ 'index': 9, │ │\n", "│ │ │ 'name': 'return check', │ │\n", "│ │ │ 'explanation': 'Return Check None', │ │\n", - "│ │ │ 'value': 0 │ │\n", + "│ │ │ 'value': 0.0 │ │\n", "│ │ │ } │ │\n", "│ │ │ ], │ │\n", "│ │ │ 'interest_rates': { │ │\n", - "│ │ │ 'purchase': { │ │\n", - "│ │ │ 'apr': 0, │ │\n", - "│ │ │ 'explanation': 'Purchase Annual Percentage Rate (APR) 0% Intro APR for the first 18 months │ │\n", - "│ │ │ that your Account is open. After that, 19.49%. This APR will vary with the market based on the Prime │ │\n", - "│ │ │ Rate.' │ │\n", - "│ │ │ }, │ │\n", - "│ │ │ 'my_chase_loan': { │ │\n", - "│ │ │ 'apr': 19.49, │ │\n", - "│ │ │ 'explanation': 'My Chase Loan SM APR 19.49%. This APR will vary with the market based on │ │\n", - "│ │ │ the Prime Rate.' │ │\n", - "│ │ │ }, │ │\n", - "│ │ │ 'balance_transfer': { │ │\n", - "│ │ │ 'apr': 0, │ │\n", - "│ │ │ 'explanation': 'Balance Transfer APR 0% Intro APR for the first 18 months that your Account │ │\n", - "│ │ │ is open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.' │ │\n", - "│ │ │ }, │ │\n", - "│ │ │ 'cash_advance': { │ │\n", - "│ │ │ 'apr': 29.49, │ │\n", - "│ │ │ 'explanation': 'Cash Advance APR 29.49%. This APR will vary with the market based on the │ │\n", - "│ │ │ Prime Rate.' │ │\n", - "│ │ │ }, │ │\n", - "│ │ │ 'penalty': { │ │\n", - "│ │ │ 'apr': 29.99, │ │\n", - "│ │ │ 'explanation': 'Up to 29.99%. This APR will vary with the market based on the Prime Rate.' │ │\n", - "│ │ │ } │ │\n", + "│ │ │ 'purchase': {'apr': 0, 'after_apr': 19.49}, │ │\n", + "│ │ │ 'my_chase_loan': {'apr': 19.49}, │ │\n", + "│ │ │ 'balance_transfer': {'apr': 0, 'after_apr': 19.49}, │ │\n", + "│ │ │ 'cash_advance': {'apr': 29.49}, │ │\n", + "│ │ │ 'penalty': {'apr': 0, 'maximum_apr': 29.99} │ │\n", "│ │ │ } │ │\n", "│ │ │ } │ │\n", "│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", @@ -885,7 +799,7 @@ " │ │ \"index\": 1, │ │\n", " │ │ \"name\": \"annual membership\", │ │\n", " │ │ \"explanation\": \"Annual Membership Fee\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 2, │ │\n", @@ -904,25 +818,25 @@ " │ │ \"explanation\": \"Balance Transfers Intro fee of either $5 or 3% of the amount of each transfer, │ │\n", " │ │ whichever is greater, on transfers made within 60 days of account opening. After that: Either $5 or 5% │ │\n", " │ │ of the amount of each transfer, whichever is greater.\", │ │\n", - " │ │ \"value\": 0.05 │ │\n", + " │ │ \"value\": 3.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 4, │ │\n", " │ │ \"name\": \"cash advances\", │ │\n", " │ │ \"explanation\": \"Either $10 or 5% of the amount of each transaction, whichever is greater.\", │ │\n", - " │ │ \"value\": 0.05 │ │\n", + " │ │ \"value\": 5.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 5, │ │\n", " │ │ \"name\": \"foreign transactions\", │ │\n", " │ │ \"explanation\": \"Foreign Transactions 3% of the amount of each transaction in U.S. dollars.\", │ │\n", - " │ │ \"value\": 0.03 │ │\n", + " │ │ \"value\": 3.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 6, │ │\n", " │ │ \"name\": \"late payment\", │ │\n", " │ │ \"explanation\": \"Late Payment Up to $40.\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 7, │ │\n", @@ -933,45 +847,39 @@ " │ │ ] │ │\n", " │ │ }, │ │\n", " │ │ \"explanation\": \"Over-the-Credit-Limit None\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 8, │ │\n", " │ │ \"name\": \"return payment\", │ │\n", " │ │ \"explanation\": \"Return Payment Up to $40.\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 9, │ │\n", " │ │ \"name\": \"return check\", │ │\n", " │ │ \"explanation\": \"Return Check None\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ } │ │\n", " │ │ ], │ │\n", " │ │ \"interest_rates\": { │ │\n", " │ │ \"purchase\": { │ │\n", " │ │ \"apr\": 0, │ │\n", - " │ │ \"explanation\": \"Purchase Annual Percentage Rate (APR) 0% Intro APR for the first 18 months that │ │\n", - " │ │ your Account is open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.\" │ │\n", + " │ │ \"after_apr\": 19.49 │ │\n", " │ │ }, │ │\n", " │ │ \"my_chase_loan\": { │ │\n", - " │ │ \"apr\": 19.49, │ │\n", - " │ │ \"explanation\": \"My Chase Loan SM APR 19.49%. This APR will vary with the market based on the │ │\n", - " │ │ Prime Rate.\" │ │\n", + " │ │ \"apr\": 19.49 │ │\n", " │ │ }, │ │\n", " │ │ \"balance_transfer\": { │ │\n", " │ │ \"apr\": 0, │ │\n", - " │ │ \"explanation\": \"Balance Transfer APR 0% Intro APR for the first 18 months that your Account is │ │\n", - " │ │ open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.\" │ │\n", + " │ │ \"after_apr\": 19.49 │ │\n", " │ │ }, │ │\n", " │ │ \"cash_advance\": { │ │\n", - " │ │ \"apr\": 29.49, │ │\n", - " │ │ \"explanation\": \"Cash Advance APR 29.49%. This APR will vary with the market based on the Prime │ │\n", - " │ │ Rate.\" │ │\n", + " │ │ \"apr\": 29.49 │ │\n", " │ │ }, │ │\n", " │ │ \"penalty\": { │ │\n", - " │ │ \"apr\": 29.99, │ │\n", - " │ │ \"explanation\": \"Up to 29.99%. This APR will vary with the market based on the Prime Rate.\" │ │\n", + " │ │ \"apr\": 0, │ │\n", + " │ │ \"maximum_apr\": 29.99 │ │\n", " │ │ } │ │\n", " │ │ } │ │\n", " │ │ } │ │\n", @@ -1006,24 +914,6 @@ " │ │ │ │\n", " │ │ │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", - " │ ╭───────────────────────────────────────────── Instructions ──────────────────────────────────────────────╮ │\n", - " │ │ │ │\n", - " │ │ You are a helpful assistant only capable of communicating with valid JSON, and no other text. │ │\n", - " │ │ │ │\n", - " │ │ ONLY return a valid JSON object (no other text is necessary), where the key of the field in JSON is the │ │\n", - " │ │ `name` attribute of the corresponding XML, and the value is of the type specified by the corresponding │ │\n", - " │ │ XML's tag. The JSON MUST conform to the XML format, including any types and format requests e.g. │ │\n", - " │ │ requests for lists, objects and specific types. Be correct and concise. If you are unsure anywhere, │ │\n", - " │ │ enter `null`. │ │\n", - " │ │ │ │\n", - " │ │ Here are examples of simple (XML, JSON) pairs that show the expected behavior: │ │\n", - " │ │ - `<string name='foo' format='two-words lower-case' />` => `{'foo': 'example one'}` │ │\n", - " │ │ - `<list name='bar'><string format='upper-case' /></list>` => `{\"bar\": ['STRING ONE', 'STRING TWO', │ │\n", - " │ │ etc.]}` │ │\n", - " │ │ - `<object name='baz'><string name=\"foo\" format=\"capitalize two-words\" /><integer name=\"index\" │ │\n", - " │ │ format=\"1-indexed\" /></object>` => `{'baz': {'foo': 'Some String', 'index': 1}}` │ │\n", - " │ │ │ │\n", - " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", " │ │ No message history. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", @@ -1032,85 +922,79 @@ " │ │ \"fees\": [ │ │\n", " │ │ { │ │\n", " │ │ \"index\": 1, │ │\n", - " │ │ \"name\": \"annual membership\", │ │\n", + " │ │ \"name\": \"annual_membership\", │ │\n", " │ │ \"explanation\": \"Annual Membership Fee\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 2, │ │\n", - " │ │ \"name\": \"my chase plan\", │ │\n", + " │ │ \"name\": \"my_chase_plan\", │ │\n", " │ │ \"explanation\": \"My Chase Plan Fee (fixed finance charge)\", │ │\n", - " │ │ \"value\": 0.0172 │ │\n", + " │ │ \"value\": 1.72 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 3, │ │\n", - " │ │ \"name\": \"balance transfers\", │ │\n", + " │ │ \"name\": \"balance_transfers\", │ │\n", " │ │ \"explanation\": \"Balance Transfers Intro fee of either $5 or 3% of the amount of each transfer, │ │\n", " │ │ whichever is greater, on transfers made within 60 days of account opening. After that: Either $5 or 5% │ │\n", " │ │ of the amount of each transfer, whichever is greater.\", │ │\n", - " │ │ \"value\": 0.05 │ │\n", + " │ │ \"value\": 3.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 4, │ │\n", - " │ │ \"name\": \"cash advances\", │ │\n", + " │ │ \"name\": \"cash_advances\", │ │\n", " │ │ \"explanation\": \"Either $10 or 5% of the amount of each transaction, whichever is greater.\", │ │\n", - " │ │ \"value\": 0.05 │ │\n", + " │ │ \"value\": 5.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 5, │ │\n", - " │ │ \"name\": \"foreign transactions\", │ │\n", + " │ │ \"name\": \"foreign_transactions\", │ │\n", " │ │ \"explanation\": \"Foreign Transactions 3% of the amount of each transaction in U.S. dollars.\", │ │\n", - " │ │ \"value\": 0.03 │ │\n", + " │ │ \"value\": 3.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 6, │ │\n", - " │ │ \"name\": \"late payment\", │ │\n", + " │ │ \"name\": \"late_payment\", │ │\n", " │ │ \"explanation\": \"Late Payment Up to $40.\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 7, │ │\n", - " │ │ \"name\": \"over-the-credit-limit\", │ │\n", + " │ │ \"name\": \"over_the_credit_limit\", │ │\n", " │ │ \"explanation\": \"Over-the-Credit-Limit None\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 8, │ │\n", - " │ │ \"name\": \"return payment\", │ │\n", + " │ │ \"name\": \"return_payment\", │ │\n", " │ │ \"explanation\": \"Return Payment Up to $40.\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ \"index\": 9, │ │\n", - " │ │ \"name\": \"return check\", │ │\n", + " │ │ \"name\": \"return_check\", │ │\n", " │ │ \"explanation\": \"Return Check None\", │ │\n", - " │ │ \"value\": 0 │ │\n", + " │ │ \"value\": 0.0 │ │\n", " │ │ } │ │\n", " │ │ ], │ │\n", " │ │ \"interest_rates\": { │ │\n", " │ │ \"purchase\": { │ │\n", " │ │ \"apr\": 0, │ │\n", - " │ │ \"explanation\": \"Purchase Annual Percentage Rate (APR) 0% Intro APR for the first 18 months that │ │\n", - " │ │ your Account is open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.\" │ │\n", + " │ │ \"after_apr\": 19.49 │ │\n", " │ │ }, │ │\n", " │ │ \"my_chase_loan\": { │ │\n", - " │ │ \"apr\": 19.49, │ │\n", - " │ │ \"explanation\": \"My Chase Loan SM APR 19.49%. This APR will vary with the market based on the │ │\n", - " │ │ Prime Rate.\" │ │\n", + " │ │ \"apr\": 19.49 │ │\n", " │ │ }, │ │\n", " │ │ \"balance_transfer\": { │ │\n", " │ │ \"apr\": 0, │ │\n", - " │ │ \"explanation\": \"Balance Transfer APR 0% Intro APR for the first 18 months that your Account is │ │\n", - " │ │ open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.\" │ │\n", + " │ │ \"after_apr\": 19.49 │ │\n", " │ │ }, │ │\n", " │ │ \"cash_advance\": { │ │\n", - " │ │ \"apr\": 29.49, │ │\n", - " │ │ \"explanation\": \"Cash Advance APR 29.49%. This APR will vary with the market based on the Prime │ │\n", - " │ │ Rate.\" │ │\n", + " │ │ \"apr\": 29.49 │ │\n", " │ │ }, │ │\n", " │ │ \"penalty\": { │ │\n", - " │ │ \"apr\": 29.99, │ │\n", - " │ │ \"explanation\": \"Up to 29.99%. This APR will vary with the market based on the Prime Rate.\" │ │\n", + " │ │ \"apr\": 0, │ │\n", + " │ │ \"maximum_apr\": 29.99 │ │\n", " │ │ } │ │\n", " │ │ } │ │\n", " │ │ } │ │\n", @@ -1120,88 +1004,68 @@ " │ │ 'fees': [ │ │\n", " │ │ { │ │\n", " │ │ 'index': 1, │ │\n", - " │ │ 'name': 'annual membership', │ │\n", + " │ │ 'name': 'annual_membership', │ │\n", " │ │ 'explanation': 'Annual Membership Fee', │ │\n", - " │ │ 'value': 0 │ │\n", + " │ │ 'value': 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ 'index': 2, │ │\n", - " │ │ 'name': 'my chase', │ │\n", + " │ │ 'name': 'my_chase_plan', │ │\n", " │ │ 'explanation': 'My Chase Plan Fee (fixed finance charge)', │ │\n", - " │ │ 'value': 0.0172 │ │\n", + " │ │ 'value': 1.72 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ 'index': 3, │ │\n", - " │ │ 'name': 'balance transfers', │ │\n", + " │ │ 'name': 'balance_transfers', │ │\n", " │ │ 'explanation': 'Balance Transfers Intro fee of either $5 or 3% of the amount of each │ │\n", " │ │ transfer, whichever is greater, on transfers made within 60 days of account opening. After that: Either │ │\n", " │ │ $5 or 5% of the amount of each transfer, whichever is greater.', │ │\n", - " │ │ 'value': 0.05 │ │\n", + " │ │ 'value': 3.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ 'index': 4, │ │\n", - " │ │ 'name': 'cash advances', │ │\n", + " │ │ 'name': 'cash_advances', │ │\n", " │ │ 'explanation': 'Either $10 or 5% of the amount of each transaction, whichever is greater.', │ │\n", - " │ │ 'value': 0.05 │ │\n", + " │ │ 'value': 5.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ 'index': 5, │ │\n", - " │ │ 'name': 'foreign transactions', │ │\n", + " │ │ 'name': 'foreign_transactions', │ │\n", " │ │ 'explanation': 'Foreign Transactions 3% of the amount of each transaction in U.S. │ │\n", " │ │ dollars.', │ │\n", - " │ │ 'value': 0.03 │ │\n", + " │ │ 'value': 3.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ 'index': 6, │ │\n", - " │ │ 'name': 'late payment', │ │\n", + " │ │ 'name': 'late_payment', │ │\n", " │ │ 'explanation': 'Late Payment Up to $40.', │ │\n", - " │ │ 'value': 0 │ │\n", + " │ │ 'value': 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ 'index': 7, │ │\n", - " │ │ 'name': 'over-the-credit-limit', │ │\n", + " │ │ 'name': 'over_the_credit_limit', │ │\n", " │ │ 'explanation': 'Over-the-Credit-Limit None', │ │\n", - " │ │ 'value': 0 │ │\n", + " │ │ 'value': 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ 'index': 8, │ │\n", - " │ │ 'name': 'return payment', │ │\n", + " │ │ 'name': 'return_payment', │ │\n", " │ │ 'explanation': 'Return Payment Up to $40.', │ │\n", - " │ │ 'value': 0 │ │\n", + " │ │ 'value': 0.0 │ │\n", " │ │ }, │ │\n", " │ │ { │ │\n", " │ │ 'index': 9, │ │\n", - " │ │ 'name': 'return check', │ │\n", + " │ │ 'name': 'return_check', │ │\n", " │ │ 'explanation': 'Return Check None', │ │\n", - " │ │ 'value': 0 │ │\n", + " │ │ 'value': 0.0 │ │\n", " │ │ } │ │\n", " │ │ ], │ │\n", " │ │ 'interest_rates': { │ │\n", - " │ │ 'purchase': { │ │\n", - " │ │ 'apr': 0, │ │\n", - " │ │ 'explanation': 'Purchase Annual Percentage Rate (APR) 0% Intro APR for the first 18 months │ │\n", - " │ │ that your Account is open. After that, 19.49%. This APR will vary with the market based on the Prime │ │\n", - " │ │ Rate.' │ │\n", - " │ │ }, │ │\n", - " │ │ 'my_chase_loan': { │ │\n", - " │ │ 'apr': 19.49, │ │\n", - " │ │ 'explanation': 'My Chase Loan SM APR 19.49%. This APR will vary with the market based on │ │\n", - " │ │ the Prime Rate.' │ │\n", - " │ │ }, │ │\n", - " │ │ 'balance_transfer': { │ │\n", - " │ │ 'apr': 0, │ │\n", - " │ │ 'explanation': 'Balance Transfer APR 0% Intro APR for the first 18 months that your Account │ │\n", - " │ │ is open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.' │ │\n", - " │ │ }, │ │\n", - " │ │ 'cash_advance': { │ │\n", - " │ │ 'apr': 29.49, │ │\n", - " │ │ 'explanation': 'Cash Advance APR 29.49%. This APR will vary with the market based on the │ │\n", - " │ │ Prime Rate.' │ │\n", - " │ │ }, │ │\n", - " │ │ 'penalty': { │ │\n", - " │ │ 'apr': 29.99, │ │\n", - " │ │ 'explanation': 'Up to 29.99%. This APR will vary with the market based on the Prime Rate.' │ │\n", - " │ │ } │ │\n", + " │ │ 'purchase': {'apr': 0, 'after_apr': 19.49}, │ │\n", + " │ │ 'my_chase_loan': {'apr': 19.49}, │ │\n", + " │ │ 'balance_transfer': {'apr': 0, 'after_apr': 19.49}, │ │\n", + " │ │ 'cash_advance': {'apr': 29.49}, │ │\n", + " │ │ 'penalty': {'apr': 0, 'maximum_apr': 29.99} │ │\n", " │ │ } │ │\n", " │ │ } │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", @@ -1369,10 +1233,7 @@ "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", "│ │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", "│ │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", - "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", "│ │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", @@ -1395,20 +1256,20 @@ "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"explanation\": \"Balance Transfers Intro fee of either $5 or 3% of the amount of each \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mtransfer, whichever is greater, on transfers made within 60 days of account opening. After that: Either\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m$5 or 5% of the amount of each transfer, whichever is greater.\",\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"value\": 0.05\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"value\": 3\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m },\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m {\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"index\": 4,\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"name\": \"cash advances\",\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"explanation\": \"Either $10 or 5% of the amount of each transaction, whichever is greater.\",\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"value\": 0.05\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"value\": 5\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m },\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m {\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"index\": 5,\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"name\": \"foreign transactions\",\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"explanation\": \"Foreign Transactions 3% of the amount of each transaction in U.S. \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mdollars.\",\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"value\": 0.03\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"value\": 3\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m },\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m {\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"index\": 6,\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", @@ -1438,28 +1299,21 @@ "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"interest_rates\": {\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"purchase\": {\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"apr\": 0,\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"explanation\": \"Purchase Annual Percentage Rate (APR) 0% Intro APR for the first 18 months \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mthat your Account is open. After that, 19.49%. This APR will vary with the market based on the Prime \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mRate.\"\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"after_apr\": 19.49\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m },\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"my_chase_loan\": {\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"apr\": 19.49,\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"explanation\": \"My Chase Loan SM APR 19.49%. This APR will vary with the market based on \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mthe Prime Rate.\"\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"apr\": 19.49\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m },\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"balance_transfer\": {\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"apr\": 0,\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"explanation\": \"Balance Transfer APR 0% Intro APR for the first 18 months that your Account\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mis open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.\"\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"after_apr\": 19.49\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m },\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"cash_advance\": {\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"apr\": 29.49,\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"explanation\": \"Cash Advance APR 29.49%. This APR will vary with the market based on the \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mPrime Rate.\"\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"apr\": 29.49\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m },\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"penalty\": {\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"apr\": 29.99,\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"explanation\": \"Up to 29.99%. This APR will vary with the market based on the Prime Rate.\"\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"apr\": 0,\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \"maximum_apr\": 29.99\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m }\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m }\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m}\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", @@ -1471,7 +1325,7 @@ "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 1,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'annual membership',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Annual Membership Fee',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0.0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 2,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", @@ -1496,26 +1350,26 @@ "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Balance Transfers Intro fee of either $5 or 3% of the amount of each \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mtransfer, whichever is greater, on transfers made within 60 days of account opening. After that: Either\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m$5 or 5% of the amount of each transfer, whichever is greater.',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0.05\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 3.0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 4,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'cash advances',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Either $10 or 5% of the amount of each transaction, whichever is greater.',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0.05\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 5.0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 5,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'foreign transactions',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Foreign Transactions 3% of the amount of each transaction in U.S. \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mdollars.',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0.03\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 3.0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 6,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'late payment',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Late Payment Up to $40.',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0.0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 7,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", @@ -1532,47 +1386,27 @@ "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m path=['fees', 6, 'name']\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m ),\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Over-the-Credit-Limit None',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0.0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 8,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'return payment',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Return Payment Up to $40.',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0.0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 9,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'return check',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Return Check None',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'value': 0.0\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m }\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m ],\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'interest_rates': {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'purchase': {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'apr': 0,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Purchase Annual Percentage Rate (APR) 0% Intro APR for the first 18 months \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mthat your Account is open. After that, 19.49%. This APR will vary with the market based on the Prime \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mRate.'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'my_chase_loan': {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'apr': 19.49,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'My Chase Loan SM APR 19.49%. This APR will vary with the market based on \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mthe Prime Rate.'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'balance_transfer': {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'apr': 0,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Balance Transfer APR 0% Intro APR for the first 18 months that your Account\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mis open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'cash_advance': {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'apr': 29.49,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Cash Advance APR 29.49%. This APR will vary with the market based on the \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mPrime Rate.'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m },\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'penalty': {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'apr': 29.99,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'explanation': 'Up to 29.99%. This APR will vary with the market based on the Prime Rate.'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m }\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'purchase': {'apr': 0, 'after_apr': 19.49},\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'my_chase_loan': {'apr': 19.49},\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'balance_transfer': {'apr': 0, 'after_apr': 19.49},\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'cash_advance': {'apr': 29.49},\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'penalty': {'apr': 0, 'maximum_apr': 29.99}\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m }\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m}\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", @@ -1588,7 +1422,7 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"index\": 1,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"name\": \"annual membership\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Annual Membership Fee\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0.0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"index\": 2,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", @@ -1607,25 +1441,25 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Balance Transfers Intro fee of either $5 or 3% of the amount of each transfer, \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mwhichever is greater, on transfers made within 60 days of account opening. After that: Either $5 or 5% \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mof the amount of each transfer, whichever is greater.\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0.05\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 3.0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"index\": 4,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"name\": \"cash advances\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Either $10 or 5% of the amount of each transaction, whichever is greater.\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0.05\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 5.0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"index\": 5,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"name\": \"foreign transactions\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Foreign Transactions 3% of the amount of each transaction in U.S. dollars.\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0.03\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 3.0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"index\": 6,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"name\": \"late payment\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Late Payment Up to $40.\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0.0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"index\": 7,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", @@ -1636,45 +1470,39 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m ]\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Over-the-Credit-Limit None\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0.0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"index\": 8,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"name\": \"return payment\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Return Payment Up to $40.\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0.0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"index\": 9,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"name\": \"return check\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Return Check None\",\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"value\": 0.0\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m }\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m ],\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"interest_rates\": {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"purchase\": {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"apr\": 0,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Purchase Annual Percentage Rate (APR) 0% Intro APR for the first 18 months that \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255myour Account is open. After that, 19.49%. This APR will vary with the market based on the Prime Rate.\"\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"after_apr\": 19.49\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"my_chase_loan\": {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"apr\": 19.49,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"My Chase Loan SM APR 19.49%. This APR will vary with the market based on the \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mPrime Rate.\"\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"apr\": 19.49\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"balance_transfer\": {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"apr\": 0,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Balance Transfer APR 0% Intro APR for the first 18 months that your Account is \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mopen. After that, 19.49%. This APR will vary with the market based on the Prime Rate.\"\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"after_apr\": 19.49\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"cash_advance\": {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"apr\": 29.49,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Cash Advance APR 29.49%. This APR will vary with the market based on the Prime \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mRate.\"\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"apr\": 29.49\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m },\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"penalty\": {\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"apr\": 29.99,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"explanation\": \"Up to 29.99%. This APR will vary with the market based on the Prime Rate.\"\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"apr\": 0,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \"maximum_apr\": 29.99\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m }\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m }\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m}\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", @@ -1709,24 +1537,6 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m╭─\u001b[0m\u001b[48;2;255;240;242m────────────────────────────────────────────\u001b[0m\u001b[48;2;255;240;242m Instructions \u001b[0m\u001b[48;2;255;240;242m─────────────────────────────────────────────\u001b[0m\u001b[48;2;255;240;242m─╮\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242mYou are a helpful assistant only capable of communicating with valid JSON, and no other text.\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242mONLY return a valid JSON object (no other text is necessary), where the key of the field in JSON is the\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m`name` attribute of the corresponding XML, and the value is of the type specified by the corresponding \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242mXML's tag. The JSON MUST conform to the XML format, including any types and format requests e.g. \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242mrequests for lists, objects and specific types. Be correct and concise. If you are unsure anywhere, \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242menter `null`.\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242mHere are examples of simple (XML, JSON) pairs that show the expected behavior:\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m- `
None\n",
+ "
\n"
+ ],
+ "text/plain": [
+ "\u001b[3;35mNone\u001b[0m\n"
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
{
"data": {
"text/html": [
@@ -634,12 +636,13 @@
}
],
"source": [
- "print(validated_response)"
+ "print(response.validated_output)\n",
+ "print(response.reask)"
]
},
{
"cell_type": "code",
- "execution_count": 48,
+ "execution_count": 61,
"metadata": {},
"outputs": [
{
@@ -815,10 +818,7 @@
"│ │ │ │ │\n",
"│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n",
"│ │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n",
- "│ │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n",
- "│ │ │ ┃ Role ┃ Content ┃ │ │\n",
- "│ │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n",
- "│ │ │ └──────┴─────────┘ │ │\n",
+ "│ │ │ No message history. │ │\n",
"│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n",
"│ │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n",
"│ │ │ { │ │\n",
@@ -1408,10 +1408,7 @@
"│ │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n",
"│ │ \u001b[48;2;255;240;242m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n",
"│ │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n",
- "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
- "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
- "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
- "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
+ "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n",
"│ │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n",
"│ │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n",
"│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n",
@@ -1830,7 +1827,7 @@
" ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n"
]
},
- "execution_count": 48,
+ "execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
diff --git a/docs/examples/no_secrets_in_generated_text.ipynb b/docs/examples/no_secrets_in_generated_text.ipynb
index 648a4185e..8d4fc120d 100644
--- a/docs/examples/no_secrets_in_generated_text.ipynb
+++ b/docs/examples/no_secrets_in_generated_text.ipynb
@@ -43,7 +43,7 @@
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -115,7 +115,7 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
@@ -148,7 +148,7 @@
},
{
"cell_type": "code",
- "execution_count": 11,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
@@ -182,7 +182,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
@@ -199,7 +199,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -213,8 +213,8 @@
"Given below is XML that describes the information to extract from this document and the tags to extract it into.\n",
"\n",
"<output>\n",
- " <string name=\"api_help\" format=\"no-code-secrets\" description=\"Show an example curl command for using openai \n",
- "Completion API\"/>\n",
+ " <string name=\"api_help\" description=\"Show an example curl command for using openai Completion API\" \n",
+ "format=\"no-code-secrets\"/>\n",
"</output>\n",
"\n",
"\n",
@@ -241,8 +241,8 @@
"Given below is XML that describes the information to extract from this document and the tags to extract it into.\n",
"\n",
"\u001b[1m<\u001b[0m\u001b[1;95moutput\u001b[0m\u001b[39m>\u001b[0m\n",
- "\u001b[39m {\n", " 'ingredients': [\n", - " {'index': 1, 'name': 'macaroni', 'brand': None, 'optional': False, 'quantity': 8.0, 'units': 'oz'},\n", + " {'index': 1, 'name': 'macaroni', 'brand': 'None', 'optional': False, 'quantity': 8.0, 'units': 'oz'},\n", " {\n", " 'index': 2,\n", " 'name': 'vegan butter',\n", @@ -396,7 +375,7 @@ " {\n", " 'index': 3,\n", " 'name': 'all-purpose flour',\n", - " 'brand': None,\n", + " 'brand': 'None',\n", " 'optional': False,\n", " 'quantity': 2.0,\n", " 'units': 'tbsp'\n", @@ -413,15 +392,29 @@ " {\n", " 'index': 6,\n", " 'name': 'nutritional yeast',\n", - " 'brand': None,\n", + " 'brand': 'None',\n", " 'optional': False,\n", " 'quantity': 2.0,\n", " 'units': 'tbsp'\n", " },\n", - " {'index': 7, 'name': 'garlic powder', 'brand': None, 'optional': False, 'quantity': 1.0, 'units': 'tsp'},\n", - " {'index': 8, 'name': 'onion powder', 'brand': None, 'optional': False, 'quantity': 1.0, 'units': 'tsp'},\n", - " {'index': 9, 'name': 'salt', 'brand': None, 'optional': False, 'quantity': 0.5, 'units': 'tsp'},\n", - " {'index': 10, 'name': 'black pepper', 'brand': None, 'optional': False, 'quantity': 0.5, 'units': 'tsp'}\n", + " {\n", + " 'index': 7,\n", + " 'name': 'garlic powder',\n", + " 'brand': 'None',\n", + " 'optional': False,\n", + " 'quantity': 1.0,\n", + " 'units': 'tsp'\n", + " },\n", + " {'index': 8, 'name': 'onion powder', 'brand': 'None', 'optional': False, 'quantity': 1.0, 'units': 'tsp'},\n", + " {'index': 9, 'name': 'salt', 'brand': 'None', 'optional': False, 'quantity': 0.5, 'units': 'tsp'},\n", + " {\n", + " 'index': 10,\n", + " 'name': 'black pepper',\n", + " 'brand': 'None',\n", + " 'optional': False,\n", + " 'quantity': 0.5,\n", + " 'units': 'tsp'\n", + " }\n", " ],\n", " 'instructions': [\n", " {\n", @@ -456,7 +449,7 @@ "text/plain": [ "\u001b[1m{\u001b[0m\n", " \u001b[32m'ingredients'\u001b[0m: \u001b[1m[\u001b[0m\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m1\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'macaroni'\u001b[0m, \u001b[32m'brand'\u001b[0m: \u001b[3;35mNone\u001b[0m, \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m, \u001b[32m'quantity'\u001b[0m: \u001b[1;36m8.0\u001b[0m, \u001b[32m'units'\u001b[0m: \u001b[32m'oz'\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m1\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'macaroni'\u001b[0m, \u001b[32m'brand'\u001b[0m: \u001b[32m'None'\u001b[0m, \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m, \u001b[32m'quantity'\u001b[0m: \u001b[1;36m8.0\u001b[0m, \u001b[32m'units'\u001b[0m: \u001b[32m'oz'\u001b[0m\u001b[1m}\u001b[0m,\n", " \u001b[1m{\u001b[0m\n", " \u001b[32m'index'\u001b[0m: \u001b[1;36m2\u001b[0m,\n", " \u001b[32m'name'\u001b[0m: \u001b[32m'vegan butter'\u001b[0m,\n", @@ -468,7 +461,7 @@ " \u001b[1m{\u001b[0m\n", " \u001b[32m'index'\u001b[0m: \u001b[1;36m3\u001b[0m,\n", " \u001b[32m'name'\u001b[0m: \u001b[32m'all-purpose flour'\u001b[0m,\n", - " \u001b[32m'brand'\u001b[0m: \u001b[3;35mNone\u001b[0m,\n", + " \u001b[32m'brand'\u001b[0m: \u001b[32m'None'\u001b[0m,\n", " \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", " \u001b[32m'quantity'\u001b[0m: \u001b[1;36m2.0\u001b[0m,\n", " \u001b[32m'units'\u001b[0m: \u001b[32m'tbsp'\u001b[0m\n", @@ -485,15 +478,29 @@ " \u001b[1m{\u001b[0m\n", " \u001b[32m'index'\u001b[0m: \u001b[1;36m6\u001b[0m,\n", " \u001b[32m'name'\u001b[0m: \u001b[32m'nutritional yeast'\u001b[0m,\n", - " \u001b[32m'brand'\u001b[0m: \u001b[3;35mNone\u001b[0m,\n", + " \u001b[32m'brand'\u001b[0m: \u001b[32m'None'\u001b[0m,\n", " \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", " \u001b[32m'quantity'\u001b[0m: \u001b[1;36m2.0\u001b[0m,\n", " \u001b[32m'units'\u001b[0m: \u001b[32m'tbsp'\u001b[0m\n", " \u001b[1m}\u001b[0m,\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m7\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'garlic powder'\u001b[0m, \u001b[32m'brand'\u001b[0m: \u001b[3;35mNone\u001b[0m, \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m, \u001b[32m'quantity'\u001b[0m: \u001b[1;36m1.0\u001b[0m, \u001b[32m'units'\u001b[0m: \u001b[32m'tsp'\u001b[0m\u001b[1m}\u001b[0m,\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m8\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'onion powder'\u001b[0m, \u001b[32m'brand'\u001b[0m: \u001b[3;35mNone\u001b[0m, \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m, \u001b[32m'quantity'\u001b[0m: \u001b[1;36m1.0\u001b[0m, \u001b[32m'units'\u001b[0m: \u001b[32m'tsp'\u001b[0m\u001b[1m}\u001b[0m,\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m9\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'salt'\u001b[0m, \u001b[32m'brand'\u001b[0m: \u001b[3;35mNone\u001b[0m, \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m, \u001b[32m'quantity'\u001b[0m: \u001b[1;36m0.5\u001b[0m, \u001b[32m'units'\u001b[0m: \u001b[32m'tsp'\u001b[0m\u001b[1m}\u001b[0m,\n", - " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m10\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'black pepper'\u001b[0m, \u001b[32m'brand'\u001b[0m: \u001b[3;35mNone\u001b[0m, \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m, \u001b[32m'quantity'\u001b[0m: \u001b[1;36m0.5\u001b[0m, \u001b[32m'units'\u001b[0m: \u001b[32m'tsp'\u001b[0m\u001b[1m}\u001b[0m\n", + " \u001b[1m{\u001b[0m\n", + " \u001b[32m'index'\u001b[0m: \u001b[1;36m7\u001b[0m,\n", + " \u001b[32m'name'\u001b[0m: \u001b[32m'garlic powder'\u001b[0m,\n", + " \u001b[32m'brand'\u001b[0m: \u001b[32m'None'\u001b[0m,\n", + " \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + " \u001b[32m'quantity'\u001b[0m: \u001b[1;36m1.0\u001b[0m,\n", + " \u001b[32m'units'\u001b[0m: \u001b[32m'tsp'\u001b[0m\n", + " \u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m8\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'onion powder'\u001b[0m, \u001b[32m'brand'\u001b[0m: \u001b[32m'None'\u001b[0m, \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m, \u001b[32m'quantity'\u001b[0m: \u001b[1;36m1.0\u001b[0m, \u001b[32m'units'\u001b[0m: \u001b[32m'tsp'\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\u001b[32m'index'\u001b[0m: \u001b[1;36m9\u001b[0m, \u001b[32m'name'\u001b[0m: \u001b[32m'salt'\u001b[0m, \u001b[32m'brand'\u001b[0m: \u001b[32m'None'\u001b[0m, \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m, \u001b[32m'quantity'\u001b[0m: \u001b[1;36m0.5\u001b[0m, \u001b[32m'units'\u001b[0m: \u001b[32m'tsp'\u001b[0m\u001b[1m}\u001b[0m,\n", + " \u001b[1m{\u001b[0m\n", + " \u001b[32m'index'\u001b[0m: \u001b[1;36m10\u001b[0m,\n", + " \u001b[32m'name'\u001b[0m: \u001b[32m'black pepper'\u001b[0m,\n", + " \u001b[32m'brand'\u001b[0m: \u001b[32m'None'\u001b[0m,\n", + " \u001b[32m'optional'\u001b[0m: \u001b[3;91mFalse\u001b[0m,\n", + " \u001b[32m'quantity'\u001b[0m: \u001b[1;36m0.5\u001b[0m,\n", + " \u001b[32m'units'\u001b[0m: \u001b[32m'tsp'\u001b[0m\n", + " \u001b[1m}\u001b[0m\n", " \u001b[1m]\u001b[0m,\n", " \u001b[32m'instructions'\u001b[0m: \u001b[1m[\u001b[0m\n", " \u001b[1m{\u001b[0m\n", @@ -535,7 +542,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -590,10 +597,7 @@ " │ │ │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", - " │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n", - " │ │ ┃ Role ┃ Content ┃ │ │\n", - " │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n", - " │ │ └──────┴─────────┘ │ │\n", + " │ │ No message history. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", " │ │ { │ │\n", @@ -718,7 +722,7 @@ " │ │ { │ │\n", " │ │ 'index': 1, │ │\n", " │ │ 'name': 'macaroni', │ │\n", - " │ │ 'brand': None, │ │\n", + " │ │ 'brand': 'None', │ │\n", " │ │ 'optional': False, │ │\n", " │ │ 'quantity': 8.0, │ │\n", " │ │ 'units': 'oz' │ │\n", @@ -734,7 +738,7 @@ " │ │ { │ │\n", " │ │ 'index': 3, │ │\n", " │ │ 'name': 'all-purpose flour', │ │\n", - " │ │ 'brand': None, │ │\n", + " │ │ 'brand': 'None', │ │\n", " │ │ 'optional': False, │ │\n", " │ │ 'quantity': 2.0, │ │\n", " │ │ 'units': 'tbsp' │ │\n", @@ -758,7 +762,7 @@ " │ │ { │ │\n", " │ │ 'index': 6, │ │\n", " │ │ 'name': 'nutritional yeast', │ │\n", - " │ │ 'brand': None, │ │\n", + " │ │ 'brand': 'None', │ │\n", " │ │ 'optional': False, │ │\n", " │ │ 'quantity': 2.0, │ │\n", " │ │ 'units': 'tbsp' │ │\n", @@ -766,7 +770,7 @@ " │ │ { │ │\n", " │ │ 'index': 7, │ │\n", " │ │ 'name': 'garlic powder', │ │\n", - " │ │ 'brand': None, │ │\n", + " │ │ 'brand': 'None', │ │\n", " │ │ 'optional': False, │ │\n", " │ │ 'quantity': 1.0, │ │\n", " │ │ 'units': 'tsp' │ │\n", @@ -774,7 +778,7 @@ " │ │ { │ │\n", " │ │ 'index': 8, │ │\n", " │ │ 'name': 'onion powder', │ │\n", - " │ │ 'brand': None, │ │\n", + " │ │ 'brand': 'None', │ │\n", " │ │ 'optional': False, │ │\n", " │ │ 'quantity': 1.0, │ │\n", " │ │ 'units': 'tsp' │ │\n", @@ -782,7 +786,7 @@ " │ │ { │ │\n", " │ │ 'index': 9, │ │\n", " │ │ 'name': 'salt', │ │\n", - " │ │ 'brand': None, │ │\n", + " │ │ 'brand': 'None', │ │\n", " │ │ 'optional': False, │ │\n", " │ │ 'quantity': 0.5, │ │\n", " │ │ 'units': 'tsp' │ │\n", @@ -790,7 +794,7 @@ " │ │ { │ │\n", " │ │ 'index': 10, │ │\n", " │ │ 'name': 'black pepper', │ │\n", - " │ │ 'brand': None, │ │\n", + " │ │ 'brand': 'None', │ │\n", " │ │ 'optional': False, │ │\n", " │ │ 'quantity': 0.5, │ │\n", " │ │ 'units': 'tsp' │ │\n", @@ -879,10 +883,7 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", @@ -1007,7 +1008,7 @@ " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 1,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'macaroni',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': None,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': 'None',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'optional': False,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'quantity': 8.0,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'units': 'oz'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", @@ -1023,7 +1024,7 @@ " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 3,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'all-purpose flour',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': None,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': 'None',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'optional': False,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'quantity': 2.0,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'units': 'tbsp'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", @@ -1047,7 +1048,7 @@ " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 6,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'nutritional yeast',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': None,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': 'None',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'optional': False,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'quantity': 2.0,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'units': 'tbsp'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", @@ -1055,7 +1056,7 @@ " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 7,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'garlic powder',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': None,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': 'None',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'optional': False,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'quantity': 1.0,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'units': 'tsp'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", @@ -1063,7 +1064,7 @@ " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 8,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'onion powder',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': None,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': 'None',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'optional': False,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'quantity': 1.0,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'units': 'tsp'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", @@ -1071,7 +1072,7 @@ " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 9,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'salt',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': None,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': 'None',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'optional': False,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'quantity': 0.5,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'units': 'tsp'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", @@ -1079,7 +1080,7 @@ " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m {\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'index': 10,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'name': 'black pepper',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': None,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'brand': 'None',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'optional': False,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'quantity': 0.5,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'units': 'tsp'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", diff --git a/docs/examples/regex_validation.ipynb b/docs/examples/regex_validation.ipynb index 0b77d1845..795aca039 100644 --- a/docs/examples/regex_validation.ipynb +++ b/docs/examples/regex_validation.ipynb @@ -20,7 +20,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -57,21 +57,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/zayd/workspace/shreya/guardrails/.venv/lib/python3.11/site-packages/guardrails/rail.py:115: UserWarning: Prompt must be provided during __call__.\n", - " warnings.warn(\"Prompt must be provided during __call__.\")\n", - "/home/zayd/workspace/shreya/guardrails/.venv/lib/python3.11/site-packages/guardrails/prompt/prompt.py:23: UserWarning: Prompt does not have any variables, if you are migrating follow the new variable convention documented here: https://docs.guardrailsai.com/0-2-migration/\n", - " warnings.warn(\n", - "/home/zayd/workspace/shreya/guardrails/.venv/lib/python3.11/site-packages/guardrails/prompt/instructions.py:32: UserWarning: Instructions do not have any variables, if you are migrating follow the new variable convention documented here: https://docs.guardrailsai.com/0-2-migration/\n", - " warn(\n" - ] - }, { "data": { "text/html": [ @@ -85,10 +73,7 @@ "│ │ │ │ │\n", "│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", "│ │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", - "│ │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n", - "│ │ │ ┃ Role ┃ Content ┃ │ │\n", - "│ │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n", - "│ │ │ └──────┴─────────┘ │ │\n", + "│ │ │ No message history. │ │\n", "│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", "│ │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", "│ │ │ │ │\n", @@ -102,7 +87,7 @@ "│ │ │ outcome='fail', │ │\n", "│ │ │ metadata=None, │ │\n", "│ │ │ error_message='Result must match ^\\\\d{3}-\\\\d{3}-\\\\d{4}$', │ │\n", - "│ │ │ fix_value='508-686-5748' │ │\n", + "│ │ │ fix_value='202-430-2040' │ │\n", "│ │ │ ) │ │\n", "│ │ │ ], │ │\n", "│ │ │ path=None │ │\n", @@ -133,9 +118,6 @@ " │ │ │ │\n", " │ │ │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", - " │ ╭───────────────────────────────────────────── Instructions ──────────────────────────────────────────────╮ │\n", - " │ │ You are a helpful assistant. │ │\n", - " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", " │ │ No message history. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", @@ -159,10 +141,7 @@ "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", "│ │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", "│ │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", - "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", "│ │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", @@ -176,7 +155,7 @@ "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m outcome='fail',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m metadata=None,\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m error_message='Result must match ^\\\\d{3}-\\\\d{3}-\\\\d{4}$',\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m fix_value='508-686-5748'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m fix_value='202-430-2040'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m )\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m ],\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m path=None\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", @@ -207,9 +186,6 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m╭─\u001b[0m\u001b[48;2;255;240;242m────────────────────────────────────────────\u001b[0m\u001b[48;2;255;240;242m Instructions \u001b[0m\u001b[48;2;255;240;242m─────────────────────────────────────────────\u001b[0m\u001b[48;2;255;240;242m─╮\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242mYou are a helpful assistant.\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", - " │ \u001b[48;2;255;240;242m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", diff --git a/docs/examples/secrets_detection.ipynb b/docs/examples/secrets_detection.ipynb index eab9e6fb9..162af6d3e 100644 --- a/docs/examples/secrets_detection.ipynb +++ b/docs/examples/secrets_detection.ipynb @@ -13,7 +13,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -21,7 +21,7 @@ "output_type": "stream", "text": [ "\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;49m23.3\u001b[0m\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;49m23.3.1\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;49mpip install --upgrade pip\u001b[0m\n" ] } @@ -33,7 +33,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -123,7 +123,7 @@ ")\n", "\n", "# Print the output\n", - "print(output)" + "print(output.validated_output)" ] }, { @@ -135,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -184,7 +184,7 @@ ")\n", "\n", "# Print the output\n", - "print(output)" + "print(output.validated_output)" ] }, { @@ -218,7 +218,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/docs/examples/select_choice_based_on_action.ipynb b/docs/examples/select_choice_based_on_action.ipynb index 727267c63..5d21d8d38 100644 --- a/docs/examples/select_choice_based_on_action.ipynb +++ b/docs/examples/select_choice_based_on_action.ipynb @@ -35,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2023-08-23T15:09:26.331177Z", @@ -79,7 +79,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -130,7 +130,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2023-08-23T15:09:28.590929Z", @@ -155,7 +155,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -175,7 +175,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2023-08-23T15:09:32.364711Z", @@ -283,26 +283,18 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2023-08-23T15:10:08.998121Z", "start_time": "2023-08-23T15:10:08.792027Z" } }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Async event loop found, but guard was invoked synchronously.For validator parallelization, please call `validate_async` instead.\n" - ] - } - ], + "outputs": [], "source": [ "import openai\n", "\n", - "raw_llm_response, validated_response = guard(\n", + "raw_llm_response, validated_response, *rest = guard(\n", " openai.ChatCompletion.create,\n", " prompt_params={'opp_type': 'giant'},\n", " model=\"gpt-3.5-turbo\",\n", @@ -324,7 +316,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -354,7 +346,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -405,10 +397,7 @@ " │ │ adhering to the provided XML schemas. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", - " │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n", - " │ │ ┃ Role ┃ Content ┃ │ │\n", - " │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n", - " │ │ └──────┴─────────┘ │ │\n", + " │ │ No message history. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", " │ │ { │ │\n", @@ -477,10 +466,7 @@ " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242madhering to the provided XML schemas.\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", " │ \u001b[48;2;255;240;242m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", @@ -522,19 +508,11 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 9, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Async event loop found, but guard was invoked synchronously.For validator parallelization, please call `validate_async` instead.\n" - ] - } - ], + "outputs": [], "source": [ - "raw_llm_response, validated_response = guard(\n", + "raw_llm_response, validated_response, *rest = guard(\n", " openai.ChatCompletion.create,\n", " prompt_params={'opp_type': 'goblin'},\n", " model=\"gpt-3.5-turbo\",\n", @@ -545,7 +523,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -575,7 +553,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -626,10 +604,7 @@ " │ │ adhering to the provided XML schemas. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", - " │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n", - " │ │ ┃ Role ┃ Content ┃ │ │\n", - " │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n", - " │ │ └──────┴─────────┘ │ │\n", + " │ │ No message history. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", " │ │ { │ │\n", @@ -691,10 +666,7 @@ " │ \u001b[48;2;255;240;242m│\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242madhering to the provided XML schemas.\u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m \u001b[0m\u001b[48;2;255;240;242m│\u001b[0m │\n", " │ \u001b[48;2;255;240;242m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", @@ -735,7 +707,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.3" + "version": "3.11.5" } }, "nbformat": 4, diff --git a/docs/examples/streaming.ipynb b/docs/examples/streaming.ipynb index f8d8d63ef..42139202a 100644 --- a/docs/examples/streaming.ipynb +++ b/docs/examples/streaming.ipynb @@ -151,7 +151,7 @@ ], "source": [ "# Wrap the OpenAI API call with the `guard` object\n", - "raw_llm_output, validated_output = guard(\n", + "raw_llm_output, validated_output, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={\"doctors_notes\": doctors_notes},\n", " engine=\"text-davinci-003\",\n", @@ -697,7 +697,7 @@ ], "source": [ "# Wrap the OpenAI API call with the `guard` object\n", - "raw_llm_output, validated_output = guard(\n", + "raw_llm_output, validated_output, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={\"doctors_notes\": doctors_notes},\n", " engine=\"text-davinci-003\",\n", diff --git a/docs/examples/syntax_error_free_sql.ipynb b/docs/examples/syntax_error_free_sql.ipynb index 6060798ab..d9acfc817 100644 --- a/docs/examples/syntax_error_free_sql.ipynb +++ b/docs/examples/syntax_error_free_sql.ipynb @@ -23,14 +23,17 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Requirement already satisfied: sqlvalidator in /home/zayd/workspace/guardrails-poc/.venv/lib/python3.11/site-packages (0.0.20)\n" + "Requirement already satisfied: sqlvalidator in /Users/calebcourier/Projects/gr-mono/guardrails-internal/.venv/lib/python3.11/site-packages (0.0.20)\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;49m23.3.1\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;49mpip install --upgrade pip\u001b[0m\n" ] } ], @@ -61,7 +64,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -101,7 +104,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -146,7 +149,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -164,7 +167,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -180,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -197,7 +200,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -213,8 +216,8 @@ "Given below is XML that describes the information to extract from this document and the tags to extract it into.\n", "\n", "<output>\n", - " <string name=\"generated_sql\" format=\"bug-free-sql\" description=\"Generate SQL for the given natural language \n", - "instruction.\"/>\n", + " <string name=\"generated_sql\" description=\"Generate SQL for the given natural language instruction.\" \n", + "format=\"bug-free-sql\"/>\n", "</output>\n", "\n", "\n", @@ -243,8 +246,8 @@ "Given below is XML that describes the information to extract from this document and the tags to extract it into.\n", "\n", "\u001b[1m<\u001b[0m\u001b[1;95moutput\u001b[0m\u001b[39m>\u001b[0m\n", - "\u001b[39m\u001b[0m\n", + "\u001b[39m \\n\\nThe House of Representatives shall chuse their Speaker and other \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mOfficers; and shall have the sole Power of Impeachment.\"\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mHelp me correct this by making it valid JSON.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mGiven below is XML that describes the information to extract from this document and the tags to extract\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mit into.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", @@ -762,28 +843,15 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mrequests for lists, objects and specific types. Be correct and concise. If you are unsure anywhere, \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255menter `null`.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mHere are examples of simple (XML, JSON) pairs that show the expected behavior:\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m- `\u001b[0m\n", "\u001b[39m<\u001b[0m\u001b[35m/\u001b[0m\u001b[95moutput\u001b[0m\u001b[39m>\u001b[0m\n", "\n", "\n", @@ -287,21 +290,13 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 8, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Async event loop found, but guard was invoked synchronously.For validator parallelization, please call `validate_async` instead.\n" - ] - } - ], + "outputs": [], "source": [ "import openai\n", "\n", - "raw_llm_response, validated_response = guard(\n", + "raw_llm_response, validated_response, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={\n", " \"nl_instruction\": \"Select the name of the employee who has the highest salary.\"\n", @@ -323,7 +318,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -346,7 +341,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -366,8 +361,8 @@ " │ │ it into. │ │\n", " │ │ │ │\n", " │ │ <output> │ │\n", - " │ │ <string name=\"generated_sql\" format=\"bug-free-sql\" description=\"Generate SQL for the given natural │ │\n", - " │ │ language instruction.\"/> │ │\n", + " │ │ <string name=\"generated_sql\" description=\"Generate SQL for the given natural language instruction.\" │ │\n", + " │ │ format=\"bug-free-sql\"/> │ │\n", " │ │ </output> │ │\n", " │ │ │ │\n", " │ │ │ │\n", @@ -391,10 +386,7 @@ " │ │ │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", - " │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n", - " │ │ ┃ Role ┃ Content ┃ │ │\n", - " │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n", - " │ │ └──────┴─────────┘ │ │\n", + " │ │ No message history. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", " │ │ {\"generated_sql\": \"SELECT name FROM employee ORDER BY salary DESC LIMIT 1\"} │ │\n", @@ -420,8 +412,8 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mit into.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", @@ -445,10 +437,7 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\"generated_sql\": \"SELECT name FROM employee ORDER BY salary DESC LIMIT 1\"}\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", diff --git a/docs/examples/text_summarization_quality.ipynb b/docs/examples/text_summarization_quality.ipynb index db2ec1836..887542a15 100644 --- a/docs/examples/text_summarization_quality.ipynb +++ b/docs/examples/text_summarization_quality.ipynb @@ -30,7 +30,10 @@ "name": "stdout", "output_type": "stream", "text": [ - "Requirement already satisfied: numpy in /Users/calebcourier/Projects/guardrails-ai/guardrails/.venv/lib/python3.11/site-packages (1.25.2)\n" + "Requirement already satisfied: numpy in /Users/calebcourier/Projects/gr-mono/guardrails-internal/.venv/lib/python3.11/site-packages (1.26.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;49m23.3.1\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;49mpip install --upgrade pip\u001b[0m\n" ] } ], @@ -310,31 +313,24 @@ "execution_count": 9, "metadata": {}, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Async event loop found, but guard was invoked synchronously.For validator parallelization, please call `validate_async` instead.\n" - ] - }, { "data": { "text/html": [ - " \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mThe House of Representatives shall chuse their Speaker and other Officers; and shall have the sole \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mPower of Impeachment.\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m╭─\u001b[0m\u001b[48;2;240;255;240m──────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m Validated Output \u001b[0m\u001b[48;2;240;255;240m───────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m─╮\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mNone\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;255;240m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", + "│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n", + "└── ╭────────────────────────────────────────────────── Step 1 ───────────────────────────────────────────────────╮\n", " │ \u001b[48;2;240;248;255m╭─\u001b[0m\u001b[48;2;240;248;255m───────────────────────────────────────────────\u001b[0m\u001b[48;2;240;248;255m Prompt \u001b[0m\u001b[48;2;240;248;255m────────────────────────────────────────────────\u001b[0m\u001b[48;2;240;248;255m─╮\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mSummarize the following document:\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mSection. 1.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mAll legislative Powers herein granted shall be vested in a Congress of the United States, which shall \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mconsist of a Senate and House of Representatives.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mSection. 2.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mThe House of Representatives shall be composed of Members chosen every second Year by the People of the\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mseveral States, and the Electors in each State shall have the Qualifications requisite for Electors of \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mthe most numerous Branch of the State Legislature.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mNo Person shall be a Representative who shall not have attained to the Age of twenty five Years, and \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mbeen seven Years a Citizen of the United States, and who shall not, when elected, be an Inhabitant of \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mthat State in which he shall be chosen.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mRepresentatives and direct Taxes shall be apportioned among the several States which may be included \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mwithin this Union, according to their respective Numbers, which shall be determined by adding to the \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mwhole Number of free Persons, including those bound to Service for a Term of Years, and excluding \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mIndians not taxed, three fifths of all other Persons. The actual Enumeration shall be made within three\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mYears after the first Meeting of the Congress of the United States, and within every subsequent Term of\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mten Years, in such Manner as they shall by Law direct. The Number of Representatives shall not exceed \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mone for every thirty Thousand, but each State shall have at Least one Representative; and until such \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255menumeration shall be made, the State of New Hampshire shall be entitled to chuse three, Massachusetts \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255meight, Rhode-Island and Providence Plantations one, Connecticut five, New-York six, New Jersey four, \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mPennsylvania eight, Delaware one, Maryland six, Virginia ten, North Carolina five, South Carolina five,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mand Georgia three.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mWhen vacancies happen in the Representation from any State, the Executive Authority thereof shall issue\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mWrits of Election to fill such Vacancies.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mI was given the following response, which was not parseable as JSON.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mThe House of Representatives shall chuse their Speaker and other Officers; and shall have the sole \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mPower of Impeachment.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m\"Validated Output: {'summary': 'The US Congress consists of a Senate and House of Representatives, with the House of\n", - "Representatives being chosen every two years by the people of the several states. Representatives must be at least \n", - "25 years old and have been a citizen of the US for seven years. Representation and taxes are apportioned among the \n", - "states according to their population, and the number of representatives cannot exceed one for every 30,000 people. \n", - "Vacancies are filled by the executive authority of the state. The House of Representatives chooses its speaker and \n", - "other officers, and has the sole power of impeachment.'}\n", + "Validated Output: {'summary': 'The US Congress is composed of a Senate and House of Representatives, with the House\n", + "of Representatives chosen every two years by the people of the several states. Representatives must be at least 25 \n", + "years old and have been a US citizen for seven years. Representatives and taxes are apportioned among the states \n", + "according to their population, and the number of representatives cannot exceed one for every 30,000 people. \n", + "Vacancies in the House of Representatives are filled by the executive authority of the state. The House of \n", + "Representatives chooses its own speaker and other officers, and has the sole power of impeachment.'}\n", "\n" ], "text/plain": [ - "Validated Output: \u001b[1m{\u001b[0m\u001b[32m'summary'\u001b[0m: \u001b[32m'The US Congress consists of a Senate and House of Representatives, with the House of\u001b[0m\n", - "\u001b[32mRepresentatives being chosen every two years by the people of the several states. Representatives must be at least \u001b[0m\n", - "\u001b[32m25 years old and have been a citizen of the US for seven years. Representation and taxes are apportioned among the \u001b[0m\n", - "\u001b[32mstates according to their population, and the number of representatives cannot exceed one for every 30,000 people. \u001b[0m\n", - "\u001b[32mVacancies are filled by the executive authority of the state. The House of Representatives chooses its speaker and \u001b[0m\n", - "\u001b[32mother officers, and has the sole power of impeachment.'\u001b[0m\u001b[1m}\u001b[0m\n" + "Validated Output: \u001b[1m{\u001b[0m\u001b[32m'summary'\u001b[0m: \u001b[32m'The US Congress is composed of a Senate and House of Representatives, with the House\u001b[0m\n", + "\u001b[32mof Representatives chosen every two years by the people of the several states. Representatives must be at least 25 \u001b[0m\n", + "\u001b[32myears old and have been a US citizen for seven years. Representatives and taxes are apportioned among the states \u001b[0m\n", + "\u001b[32maccording to their population, and the number of representatives cannot exceed one for every 30,000 people. \u001b[0m\n", + "\u001b[32mVacancies in the House of Representatives are filled by the executive authority of the state. The House of \u001b[0m\n", + "\u001b[32mRepresentatives chooses its own speaker and other officers, and has the sole power of impeachment.'\u001b[0m\u001b[1m}\u001b[0m\n" ] }, "metadata": {}, @@ -344,7 +340,7 @@ "source": [ "import openai\n", "\n", - "raw_llm_response, validated_response = guard(\n", + "raw_llm_response, validated_response, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={'document': document},\n", " engine='text-davinci-003',\n", @@ -437,29 +433,26 @@ " │ │ │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", - " │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n", - " │ │ ┃ Role ┃ Content ┃ │ │\n", - " │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n", - " │ │ └──────┴─────────┘ │ │\n", + " │ │ No message history. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", - " │ │ {\"summary\": \"The US Congress consists of a Senate and House of Representatives, with the House of │ │\n", - " │ │ Representatives being chosen every two years by the people of the several states. Representatives must │ │\n", - " │ │ be at least 25 years old and have been a citizen of the US for seven years. Representation and taxes │ │\n", - " │ │ are apportioned among the states according to their population, and the number of representatives │ │\n", - " │ │ cannot exceed one for every 30,000 people. Vacancies are filled by the executive authority of the │ │\n", - " │ │ state. The House of Representatives chooses its speaker and other officers, and has the sole power of │ │\n", - " │ │ impeachment.\"} │ │\n", + " │ │ {\"summary\": \"The US Congress is composed of a Senate and House of Representatives, with the House of │ │\n", + " │ │ Representatives chosen every two years by the people of the several states. Representatives must be at │ │\n", + " │ │ least 25 years old and have been a US citizen for seven years. Representatives and taxes are │ │\n", + " │ │ apportioned among the states according to their population, and the number of representatives cannot │ │\n", + " │ │ exceed one for every 30,000 people. Vacancies in the House of Representatives are filled by the │ │\n", + " │ │ executive authority of the state. The House of Representatives chooses its own speaker and other │ │\n", + " │ │ officers, and has the sole power of impeachment.\"} │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭─────────────────────────────────────────── Validated Output ────────────────────────────────────────────╮ │\n", " │ │ { │ │\n", - " │ │ 'summary': 'The US Congress consists of a Senate and House of Representatives, with the House of │ │\n", - " │ │ Representatives being chosen every two years by the people of the several states. Representatives must │ │\n", - " │ │ be at least 25 years old and have been a citizen of the US for seven years. Representation and taxes │ │\n", - " │ │ are apportioned among the states according to their population, and the number of representatives │ │\n", - " │ │ cannot exceed one for every 30,000 people. Vacancies are filled by the executive authority of the │ │\n", - " │ │ state. The House of Representatives chooses its speaker and other officers, and has the sole power of │ │\n", - " │ │ impeachment.' │ │\n", + " │ │ 'summary': 'The US Congress is composed of a Senate and House of Representatives, with the House of │ │\n", + " │ │ Representatives chosen every two years by the people of the several states. Representatives must be at │ │\n", + " │ │ least 25 years old and have been a US citizen for seven years. Representatives and taxes are │ │\n", + " │ │ apportioned among the states according to their population, and the number of representatives cannot │ │\n", + " │ │ exceed one for every 30,000 people. Vacancies in the House of Representatives are filled by the │ │\n", + " │ │ executive authority of the state. The House of Representatives chooses its own speaker and other │ │\n", + " │ │ officers, and has the sole power of impeachment.' │ │\n", " │ │ } │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n", @@ -532,29 +525,26 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\"summary\": \"The US Congress consists of a Senate and House of Representatives, with the House of \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mRepresentatives being chosen every two years by the people of the several states. Representatives must \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mbe at least 25 years old and have been a citizen of the US for seven years. Representation and taxes \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mare apportioned among the states according to their population, and the number of representatives \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mcannot exceed one for every 30,000 people. Vacancies are filled by the executive authority of the \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mstate. The House of Representatives chooses its speaker and other officers, and has the sole power of \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mimpeachment.\"}\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\"summary\": \"The US Congress is composed of a Senate and House of Representatives, with the House of \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mRepresentatives chosen every two years by the people of the several states. Representatives must be at \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mleast 25 years old and have been a US citizen for seven years. Representatives and taxes are \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mapportioned among the states according to their population, and the number of representatives cannot \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mexceed one for every 30,000 people. Vacancies in the House of Representatives are filled by the \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mexecutive authority of the state. The House of Representatives chooses its own speaker and other \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220mofficers, and has the sole power of impeachment.\"}\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", " │ \u001b[48;2;245;245;220m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;240;255;240m╭─\u001b[0m\u001b[48;2;240;255;240m──────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m Validated Output \u001b[0m\u001b[48;2;240;255;240m───────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m─╮\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m{\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'summary': 'The US Congress consists of a Senate and House of Representatives, with the House of \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mRepresentatives being chosen every two years by the people of the several states. Representatives must \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mbe at least 25 years old and have been a citizen of the US for seven years. Representation and taxes \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mare apportioned among the states according to their population, and the number of representatives \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mcannot exceed one for every 30,000 people. Vacancies are filled by the executive authority of the \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mstate. The House of Representatives chooses its speaker and other officers, and has the sole power of \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mimpeachment.'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m 'summary': 'The US Congress is composed of a Senate and House of Representatives, with the House of\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mRepresentatives chosen every two years by the people of the several states. Representatives must be at \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mleast 25 years old and have been a US citizen for seven years. Representatives and taxes are \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mapportioned among the states according to their population, and the number of representatives cannot \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mexceed one for every 30,000 people. Vacancies in the House of Representatives are filled by the \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mexecutive authority of the state. The House of Representatives chooses its own speaker and other \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240mofficers, and has the sole power of impeachment.'\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m}\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n" @@ -598,7 +588,7 @@ } ], "source": [ - "raw_llm_response, validated_response = guard(\n", + "raw_llm_response, validated_response, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={'document': open(\"data/article1.txt\", \"r\").read()},\n", " engine='text-ada-001',\n", @@ -626,42 +616,94 @@ "data": { "text/html": [ "Logs\n", - "└── ╭────────────────────────────────────────────────── Step 0 ───────────────────────────────────────────────────╮\n", + "├── ╭────────────────────────────────────────────────── Step 0 ───────────────────────────────────────────────────╮\n", + "│ │ ╭──────────────────────────────────────────────── Prompt ─────────────────────────────────────────────────╮ │\n", + "│ │ │ │ │\n", + "│ │ │ Summarize the following document: │ │\n", + "│ │ │ │ │\n", + "│ │ │ Section. 1. │ │\n", + "│ │ │ All legislative Powers herein granted shall be vested in a Congress of the United States, which shall │ │\n", + "│ │ │ consist of a Senate and House of Representatives. │ │\n", + "│ │ │ │ │\n", + "│ │ │ Section. 2. │ │\n", + "│ │ │ The House of Representatives shall be composed of Members chosen every second Year by the People of the │ │\n", + "│ │ │ several States, and the Electors in each State shall have the Qualifications requisite for Electors of │ │\n", + "│ │ │ the most numerous Branch of the State Legislature. │ │\n", + "│ │ │ │ │\n", + "│ │ │ No Person shall be a Representative who shall not have attained to the Age of twenty five Years, and │ │\n", + "│ │ │ been seven Years a Citizen of the United States, and who shall not, when elected, be an Inhabitant of │ │\n", + "│ │ │ that State in which he shall be chosen. │ │\n", + "│ │ │ │ │\n", + "│ │ │ Representatives and direct Taxes shall be apportioned among the several States which may be included │ │\n", + "│ │ │ within this Union, according to their respective Numbers, which shall be determined by adding to the │ │\n", + "│ │ │ whole Number of free Persons, including those bound to Service for a Term of Years, and excluding │ │\n", + "│ │ │ Indians not taxed, three fifths of all other Persons. The actual Enumeration shall be made within three │ │\n", + "│ │ │ Years after the first Meeting of the Congress of the United States, and within every subsequent Term of │ │\n", + "│ │ │ ten Years, in such Manner as they shall by Law direct. The Number of Representatives shall not exceed │ │\n", + "│ │ │ one for every thirty Thousand, but each State shall have at Least one Representative; and until such │ │\n", + "│ │ │ enumeration shall be made, the State of New Hampshire shall be entitled to chuse three, Massachusetts │ │\n", + "│ │ │ eight, Rhode-Island and Providence Plantations one, Connecticut five, New-York six, New Jersey four, │ │\n", + "│ │ │ Pennsylvania eight, Delaware one, Maryland six, Virginia ten, North Carolina five, South Carolina five, │ │\n", + "│ │ │ and Georgia three. │ │\n", + "│ │ │ │ │\n", + "│ │ │ When vacancies happen in the Representation from any State, the Executive Authority thereof shall issue │ │\n", + "│ │ │ Writs of Election to fill such Vacancies. │ │\n", + "│ │ │ │ │\n", + "│ │ │ The House of Representatives shall chuse their Speaker and other Officers; and shall have the sole │ │\n", + "│ │ │ Power of Impeachment. │ │\n", + "│ │ │ │ │\n", + "│ │ │ │ │\n", + "│ │ │ Given below is XML that describes the information to extract from this document and the tags to extract │ │\n", + "│ │ │ it into. │ │\n", + "│ │ │ │ │\n", + "│ │ │ <output> │ │\n", + "│ │ │ <string name=\"summary\" description=\"Summarize the given document faithfully.\"/> │ │\n", + "│ │ │ </output> │ │\n", + "│ │ │ │ │\n", + "│ │ │ │ │\n", + "│ │ │ ONLY return a valid JSON object (no other text is necessary), where the key of the field in JSON is the │ │\n", + "│ │ │ `name` attribute of the corresponding XML, and the value is of the type specified by the corresponding │ │\n", + "│ │ │ XML's tag. The JSON MUST conform to the XML format, including any types and format requests e.g. │ │\n", + "│ │ │ requests for lists, objects and specific types. Be correct and concise. If you are unsure anywhere, │ │\n", + "│ │ │ enter `null`. │ │\n", + "│ │ │ │ │\n", + "│ │ │ Here are examples of simple (XML, JSON) pairs that show the expected behavior: │ │\n", + "│ │ │ - `<string name='foo' format='two-words lower-case' />` => `{'foo': 'example one'}` │ │\n", + "│ │ │ - `<list name='bar'><string format='upper-case' /></list>` => `{\"bar\": ['STRING ONE', 'STRING TWO', │ │\n", + "│ │ │ etc.]}` │ │\n", + "│ │ │ - `<object name='baz'><string name=\"foo\" format=\"capitalize two-words\" /><integer name=\"index\" │ │\n", + "│ │ │ format=\"1-indexed\" /></object>` => `{'baz': {'foo': 'Some String', 'index': 1}}` │ │\n", + "│ │ │ │ │\n", + "│ │ │ │ │\n", + "│ │ │ │ │\n", + "│ │ │ Json Output: │ │\n", + "│ │ │ │ │\n", + "│ │ │ │ │\n", + "│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", + "│ │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", + "│ │ │ No message history. │ │\n", + "│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", + "│ │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", + "│ │ │ <string name=\"summary\" description=\"Summarize the given document faithfully.\"/> │ │\n", + "│ │ │ </string> │ │\n", + "│ │ │ │ │\n", + "│ │ │ The House of Representatives shall chuse their Speaker and other Officers; and shall have the sole │ │\n", + "│ │ │ Power of Impeachment. │ │\n", + "│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", + "│ │ ╭─────────────────────────────────────────── Validated Output ────────────────────────────────────────────╮ │\n", + "│ │ │ None │ │\n", + "│ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", + "│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n", + "└── ╭────────────────────────────────────────────────── Step 1 ───────────────────────────────────────────────────╮\n", " │ ╭──────────────────────────────────────────────── Prompt ─────────────────────────────────────────────────╮ │\n", " │ │ │ │\n", - " │ │ Summarize the following document: │ │\n", - " │ │ │ │\n", - " │ │ Section. 1. │ │\n", - " │ │ All legislative Powers herein granted shall be vested in a Congress of the United States, which shall │ │\n", - " │ │ consist of a Senate and House of Representatives. │ │\n", - " │ │ │ │\n", - " │ │ Section. 2. │ │\n", - " │ │ The House of Representatives shall be composed of Members chosen every second Year by the People of the │ │\n", - " │ │ several States, and the Electors in each State shall have the Qualifications requisite for Electors of │ │\n", - " │ │ the most numerous Branch of the State Legislature. │ │\n", - " │ │ │ │\n", - " │ │ No Person shall be a Representative who shall not have attained to the Age of twenty five Years, and │ │\n", - " │ │ been seven Years a Citizen of the United States, and who shall not, when elected, be an Inhabitant of │ │\n", - " │ │ that State in which he shall be chosen. │ │\n", - " │ │ │ │\n", - " │ │ Representatives and direct Taxes shall be apportioned among the several States which may be included │ │\n", - " │ │ within this Union, according to their respective Numbers, which shall be determined by adding to the │ │\n", - " │ │ whole Number of free Persons, including those bound to Service for a Term of Years, and excluding │ │\n", - " │ │ Indians not taxed, three fifths of all other Persons. The actual Enumeration shall be made within three │ │\n", - " │ │ Years after the first Meeting of the Congress of the United States, and within every subsequent Term of │ │\n", - " │ │ ten Years, in such Manner as they shall by Law direct. The Number of Representatives shall not exceed │ │\n", - " │ │ one for every thirty Thousand, but each State shall have at Least one Representative; and until such │ │\n", - " │ │ enumeration shall be made, the State of New Hampshire shall be entitled to chuse three, Massachusetts │ │\n", - " │ │ eight, Rhode-Island and Providence Plantations one, Connecticut five, New-York six, New Jersey four, │ │\n", - " │ │ Pennsylvania eight, Delaware one, Maryland six, Virginia ten, North Carolina five, South Carolina five, │ │\n", - " │ │ and Georgia three. │ │\n", - " │ │ │ │\n", - " │ │ When vacancies happen in the Representation from any State, the Executive Authority thereof shall issue │ │\n", - " │ │ Writs of Election to fill such Vacancies. │ │\n", + " │ │ I was given the following response, which was not parseable as JSON. │ │\n", " │ │ │ │\n", - " │ │ The House of Representatives shall chuse their Speaker and other Officers; and shall have the sole │ │\n", - " │ │ Power of Impeachment. │ │\n", + " │ │ \" <string name=\\\"summary\\\" description=\\\"Summarize the given document │ │\n", + " │ │ faithfully.\\\"/>\\n</string>\\n\\nThe House of Representatives shall chuse their Speaker and other │ │\n", + " │ │ Officers; and shall have the sole Power of Impeachment.\" │ │\n", " │ │ │ │\n", + " │ │ Help me correct this by making it valid JSON. │ │\n", " │ │ │ │\n", " │ │ Given below is XML that describes the information to extract from this document and the tags to extract │ │\n", " │ │ it into. │ │\n", @@ -677,28 +719,15 @@ " │ │ requests for lists, objects and specific types. Be correct and concise. If you are unsure anywhere, │ │\n", " │ │ enter `null`. │ │\n", " │ │ │ │\n", - " │ │ Here are examples of simple (XML, JSON) pairs that show the expected behavior: │ │\n", - " │ │ - `<string name='foo' format='two-words lower-case' />` => `{'foo': 'example one'}` │ │\n", - " │ │ - `<list name='bar'><string format='upper-case' /></list>` => `{\"bar\": ['STRING ONE', 'STRING TWO', │ │\n", - " │ │ etc.]}` │ │\n", - " │ │ - `<object name='baz'><string name=\"foo\" format=\"capitalize two-words\" /><integer name=\"index\" │ │\n", - " │ │ format=\"1-indexed\" /></object>` => `{'baz': {'foo': 'Some String', 'index': 1}}` │ │\n", - " │ │ │ │\n", - " │ │ │ │\n", " │ │ │ │\n", " │ │ Json Output: │ │\n", " │ │ │ │\n", " │ │ │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", - " │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n", - " │ │ ┃ Role ┃ Content ┃ │ │\n", - " │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n", - " │ │ └──────┴─────────┘ │ │\n", + " │ │ No message history. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", - " │ │ <string name=\"summary\" description=\"Summarize the given document faithfully.\"/> │ │\n", - " │ │ </string> │ │\n", " │ │ │ │\n", " │ │ The House of Representatives shall chuse their Speaker and other Officers; and shall have the sole │ │\n", " │ │ Power of Impeachment. │ │\n", @@ -711,42 +740,94 @@ ], "text/plain": [ "Logs\n", - "└── ╭────────────────────────────────────────────────── Step 0 ───────────────────────────────────────────────────╮\n", + "├── ╭────────────────────────────────────────────────── Step 0 ───────────────────────────────────────────────────╮\n", + "│ │ \u001b[48;2;240;248;255m╭─\u001b[0m\u001b[48;2;240;248;255m───────────────────────────────────────────────\u001b[0m\u001b[48;2;240;248;255m Prompt \u001b[0m\u001b[48;2;240;248;255m────────────────────────────────────────────────\u001b[0m\u001b[48;2;240;248;255m─╮\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mSummarize the following document:\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mSection. 1.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mAll legislative Powers herein granted shall be vested in a Congress of the United States, which shall \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mconsist of a Senate and House of Representatives.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mSection. 2.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mThe House of Representatives shall be composed of Members chosen every second Year by the People of the\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mseveral States, and the Electors in each State shall have the Qualifications requisite for Electors of \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mthe most numerous Branch of the State Legislature.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mNo Person shall be a Representative who shall not have attained to the Age of twenty five Years, and \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mbeen seven Years a Citizen of the United States, and who shall not, when elected, be an Inhabitant of \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mthat State in which he shall be chosen.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mRepresentatives and direct Taxes shall be apportioned among the several States which may be included \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mwithin this Union, according to their respective Numbers, which shall be determined by adding to the \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mwhole Number of free Persons, including those bound to Service for a Term of Years, and excluding \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mIndians not taxed, three fifths of all other Persons. The actual Enumeration shall be made within three\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mYears after the first Meeting of the Congress of the United States, and within every subsequent Term of\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mten Years, in such Manner as they shall by Law direct. The Number of Representatives shall not exceed \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mone for every thirty Thousand, but each State shall have at Least one Representative; and until such \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255menumeration shall be made, the State of New Hampshire shall be entitled to chuse three, Massachusetts \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255meight, Rhode-Island and Providence Plantations one, Connecticut five, New-York six, New Jersey four, \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mPennsylvania eight, Delaware one, Maryland six, Virginia ten, North Carolina five, South Carolina five,\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mand Georgia three.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mWhen vacancies happen in the Representation from any State, the Executive Authority thereof shall issue\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mWrits of Election to fill such Vacancies.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mThe House of Representatives shall chuse their Speaker and other Officers; and shall have the sole \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mPower of Impeachment.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mGiven below is XML that describes the information to extract from this document and the tags to extract\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mit into.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mONLY return a valid JSON object (no other text is necessary), where the key of the field in JSON is the\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m`name` attribute of the corresponding XML, and the value is of the type specified by the corresponding \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mXML's tag. The JSON MUST conform to the XML format, including any types and format requests e.g. \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mrequests for lists, objects and specific types. Be correct and concise. If you are unsure anywhere, \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255menter `null`.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mHere are examples of simple (XML, JSON) pairs that show the expected behavior:\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m- `` => `{'foo': 'example one'}`\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m- ` ` => `{\"bar\": ['STRING ONE', 'STRING TWO', \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255metc.]}`\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m- `
` => `{'baz': {'foo': 'Some String', 'index': 1}}`\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mJson Output:\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", + "│ │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", + "│ │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", + "│ │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + "│ │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + "│ │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \\n ` => `{'foo': 'example one'}`\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m- ` ` => `{\"bar\": ['STRING ONE', 'STRING TWO', \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255metc.]}`\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m- `
` => `{'baz': {'foo': 'Some String', 'index': 1}}`\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", - " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mJson Output:\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m
Validated Output: {'translated_statement': \"It is so bad that it's a letdown.\"}\n", + "\n" @@ -630,8 +610,8 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255mit into.\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", @@ -655,16 +635,13 @@ " │ \u001b[48;2;240;248;255m│\u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m \u001b[0m\u001b[48;2;240;248;255m│\u001b[0m │\n", " │ \u001b[48;2;240;248;255m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╭─\u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m Message History \u001b[0m\u001b[48;2;231;223;235m───────────────────────────────────────────\u001b[0m\u001b[48;2;231;223;235m─╮\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┏━━━━━━┳━━━━━━━━━┓\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mRole\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[1;48;2;231;223;235mContent\u001b[0m\u001b[1;48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┃\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m┡━━━━━━╇━━━━━━━━━┩\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", - " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m└──────┴─────────┘\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", + " │ \u001b[48;2;231;223;235m│\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235mNo message history.\u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m \u001b[0m\u001b[48;2;231;223;235m│\u001b[0m │\n", " │ \u001b[48;2;231;223;235m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;245;245;220m╭─\u001b[0m\u001b[48;2;245;245;220m───────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m Raw LLM Output \u001b[0m\u001b[48;2;245;245;220m────────────────────────────────────────────\u001b[0m\u001b[48;2;245;245;220m─╮\u001b[0m │\n", - " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\"translated_statement\": \"It is so bad that it's a letdown.\"}\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", + " │ \u001b[48;2;245;245;220m│\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m{\"translated_statement\": \"It's so bad that it's a letdown.\"}\u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m \u001b[0m\u001b[48;2;245;245;220m│\u001b[0m │\n", " │ \u001b[48;2;245;245;220m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " │ \u001b[48;2;240;255;240m╭─\u001b[0m\u001b[48;2;240;255;240m──────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m Validated Output \u001b[0m\u001b[48;2;240;255;240m───────────────────────────────────────────\u001b[0m\u001b[48;2;240;255;240m─╮\u001b[0m │\n", - " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m{'translated_statement': \"It is so bad that it's a letdown.\"}\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", + " │ \u001b[48;2;240;255;240m│\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m{'translated_statement': \"It's so bad that it's a letdown.\"}\u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m \u001b[0m\u001b[48;2;240;255;240m│\u001b[0m │\n", " │ \u001b[48;2;240;255;240m╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯\u001b[0m │\n", " ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n" ] diff --git a/docs/examples/valid_chess_moves.ipynb b/docs/examples/valid_chess_moves.ipynb index 804acf73b..9292857b0 100644 --- a/docs/examples/valid_chess_moves.ipynb +++ b/docs/examples/valid_chess_moves.ipynb @@ -344,7 +344,7 @@ "source": [ "import openai\n", "\n", - "raw_llm_response, validated_response = guard(\n", + "raw_llm_response, validated_response, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={\n", " \"board_state\": str(board.move_stack)\n", @@ -480,7 +480,7 @@ } ], "source": [ - "raw_llm_response, validated_response = guard(\n", + "raw_llm_response, validated_response, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={\n", " \"board_state\": str(board.move_stack)\n", diff --git a/docs/examples/value_within_distribution.ipynb b/docs/examples/value_within_distribution.ipynb index 386063d51..2d46d2801 100644 --- a/docs/examples/value_within_distribution.ipynb +++ b/docs/examples/value_within_distribution.ipynb @@ -17,7 +17,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -26,7 +26,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -48,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -66,7 +66,7 @@ " metadata={\"prev_values\": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]},\n", ")\n", "\n", - "print(output)" + "print(output.validated_output)" ] }, { @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -96,7 +96,7 @@ " metadata={\"prev_values\": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]},\n", ")\n", "\n", - "print(output)" + "print(output.validated_output)" ] }, { @@ -115,7 +115,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -137,7 +137,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -159,12 +159,12 @@ " },\n", ")\n", "\n", - "print(output)" + "print(output.validated_output)" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -186,7 +186,7 @@ " },\n", ")\n", "\n", - "print(output)" + "print(output.validated_output)" ] } ], diff --git a/docs/guardrails_ai/getting_started.ipynb b/docs/guardrails_ai/getting_started.ipynb index 076bbbd1f..1fd0a4e40 100644 --- a/docs/guardrails_ai/getting_started.ipynb +++ b/docs/guardrails_ai/getting_started.ipynb @@ -378,7 +378,7 @@ "import os\n", "\n", "# Wrap the OpenAI API call with the `guard` object\n", - "raw_llm_output, validated_output = guard(\n", + "raw_llm_output, validated_output, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={\"doctors_notes\": doctors_notes},\n", " engine=\"text-davinci-003\",\n", diff --git a/docs/integrations/azure_openai.ipynb b/docs/integrations/azure_openai.ipynb index 52d5db7ab..72a61665b 100644 --- a/docs/integrations/azure_openai.ipynb +++ b/docs/integrations/azure_openai.ipynb @@ -118,7 +118,7 @@ } ], "source": [ - "raw_llm_output, validated_output = guard(\n", + "raw_llm_output, validated_output, *rest = guard(\n", " openai.ChatCompletion.create,\n", " engine=os.environ.get(\"AZURE_OPENAI_API_ENGINE\"),\n", " max_tokens=1024,\n", diff --git a/docs/integrations/llm_api_wrappers.md b/docs/integrations/llm_api_wrappers.md index 7a2c2a165..f917e7e8d 100644 --- a/docs/integrations/llm_api_wrappers.md +++ b/docs/integrations/llm_api_wrappers.md @@ -18,7 +18,7 @@ import guardrails as gd guard = gd.Guard.from_rail(...) # Wrap openai API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( openai.Completion.create, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, engine="text-davinci-003", @@ -37,7 +37,7 @@ import guardrails as gd guard = gd.Guard.from_rail(...) # Wrap openai API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( openai.ChatCompletion.create, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, system_prompt="You are a helpful assistant...", @@ -62,7 +62,7 @@ guard = gd.Guard.from_rail(...) cohere_client = cohere.Client(api_key="my_api_key") # Wrap cohere API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( cohere_client.generate, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, model="command-nightly", @@ -91,7 +91,7 @@ manifest = manifest.Manifest( ) # Wrap openai API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( manifest, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, max_tokens=100, @@ -125,7 +125,7 @@ def my_llm_api(prompt: str, **kwargs) -> str: # Wrap your LLM API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( my_llm_api, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, **kwargs, diff --git a/docs/integrations/openai_functions.ipynb b/docs/integrations/openai_functions.ipynb index ecaee93a0..e79f34e38 100644 --- a/docs/integrations/openai_functions.ipynb +++ b/docs/integrations/openai_functions.ipynb @@ -77,7 +77,7 @@ "source": [ "guard = gd.Guard.from_pydantic(Director, prompt=\"Generate data about a movie director.\")\n", "\n", - "raw_llm_output, validated_output = guard(\n", + "raw_llm_output, validated_output, *rest = guard(\n", " openai.ChatCompletion.create,\n", " model=\"gpt-4-0613\",\n", " max_tokens=1024,\n", diff --git a/docs/llm_api_wrappers.md b/docs/llm_api_wrappers.md index 7a2c2a165..f917e7e8d 100644 --- a/docs/llm_api_wrappers.md +++ b/docs/llm_api_wrappers.md @@ -18,7 +18,7 @@ import guardrails as gd guard = gd.Guard.from_rail(...) # Wrap openai API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( openai.Completion.create, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, engine="text-davinci-003", @@ -37,7 +37,7 @@ import guardrails as gd guard = gd.Guard.from_rail(...) # Wrap openai API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( openai.ChatCompletion.create, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, system_prompt="You are a helpful assistant...", @@ -62,7 +62,7 @@ guard = gd.Guard.from_rail(...) cohere_client = cohere.Client(api_key="my_api_key") # Wrap cohere API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( cohere_client.generate, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, model="command-nightly", @@ -91,7 +91,7 @@ manifest = manifest.Manifest( ) # Wrap openai API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( manifest, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, max_tokens=100, @@ -125,7 +125,7 @@ def my_llm_api(prompt: str, **kwargs) -> str: # Wrap your LLM API call -raw_llm_output, guardrail_output = guard( +raw_llm_output, guardrail_output, *rest = guard( my_llm_api, prompt_params={"prompt_param_1": "value_1", "prompt_param_2": "value_2", ..}, **kwargs, diff --git a/guardrails/applications/text2sql.py b/guardrails/applications/text2sql.py index 8d28859fb..dc110f10b 100644 --- a/guardrails/applications/text2sql.py +++ b/guardrails/applications/text2sql.py @@ -2,7 +2,7 @@ import json import os from string import Template -from typing import Callable, Dict, Optional, Type +from typing import Callable, Dict, Optional, Type, cast from guardrails.document_store import DocumentStoreBase, EphemeralDocumentStore from guardrails.embedding import EmbeddingBase, OpenAIEmbedding @@ -186,21 +186,22 @@ def __call__(self, text: str) -> Optional[str]: "Async API is not supported in Text2SQL application. " "Please use a synchronous API." ) - if self.llm_api is None: - return None - try: - return self.guard( - self.llm_api, - prompt_params={ - "nl_instruction": text, - "examples": similar_examples_prompt, - "db_info": str(self.sql_schema), - }, - **self.llm_api_kwargs, - )[ # type: ignore - 1 - ][ - "generated_sql" - ] - except TypeError: - return None + else: + if self.llm_api is None: + return None + try: + response = self.guard( + self.llm_api, + prompt_params={ + "nl_instruction": text, + "examples": similar_examples_prompt, + "db_info": str(self.sql_schema), + }, + **self.llm_api_kwargs, + ) + validated_output: Dict = cast(Dict, response.validated_output) + output = validated_output["generated_sql"] + except TypeError: + output = None + + return output diff --git a/guardrails/classes/__init__.py b/guardrails/classes/__init__.py new file mode 100644 index 000000000..db686adbe --- /dev/null +++ b/guardrails/classes/__init__.py @@ -0,0 +1,5 @@ +from guardrails.classes.list_plus_plus import ListPlusPlus +from guardrails.classes.output_type import OT +from guardrails.classes.validation_outcome import ValidationOutcome + +__all__ = ["ListPlusPlus", "ValidationOutcome", "OT"] diff --git a/guardrails/classes/list_plus_plus.py b/guardrails/classes/list_plus_plus.py new file mode 100644 index 000000000..cc44fc9dc --- /dev/null +++ b/guardrails/classes/list_plus_plus.py @@ -0,0 +1,15 @@ +from typing import List, Optional, TypeVar + +T = TypeVar("T") + + +class ListPlusPlus(List[T]): + def __init__(self, *args): + list.__init__(self, args) + + def at(self, index: int) -> Optional[T]: + try: + value = self[index] + return value + except IndexError: + pass diff --git a/guardrails/classes/output_type.py b/guardrails/classes/output_type.py new file mode 100644 index 000000000..8c1c26135 --- /dev/null +++ b/guardrails/classes/output_type.py @@ -0,0 +1,3 @@ +from typing import Dict, TypeVar + +OT = TypeVar("OT", str, Dict) diff --git a/guardrails/classes/validation_outcome.py b/guardrails/classes/validation_outcome.py new file mode 100644 index 000000000..de51ed7fb --- /dev/null +++ b/guardrails/classes/validation_outcome.py @@ -0,0 +1,77 @@ +from typing import Generic, Iterator, Optional, Tuple, Union, cast + +from pydantic import Field + +from guardrails.classes.output_type import OT +from guardrails.utils.logs_utils import ArbitraryModel, GuardHistory +from guardrails.utils.reask_utils import ReAsk + + +class ValidationOutcome(Generic[OT], ArbitraryModel): + raw_llm_output: Optional[str] = Field( + description="The raw, unchanged output from the LLM call.", default=None + ) + validated_output: Optional[OT] = Field( + description="The validated, and potentially fixed," + " output from the LLM call after passing through validation.", + default=None, + ) + reask: Optional[ReAsk] = Field( + description="If validation continuously fails and all allocated" + " reasks are used, this field will contain the final reask that" + " would have been sent to the LLM if additional reasks were available.", + default=None, + ) + validation_passed: bool = Field( + description="A boolean to indicate whether or not" + " the LLM output passed validation." + " If this is False, the validated_output may be invalid." + ) + error: Optional[str] = Field(default=None) + + @classmethod + def from_guard_history( + cls, guard_history: GuardHistory, error_message: Optional[str] + ): + raw_output = guard_history.output + validated_output = guard_history.validated_output + any_validations_failed = len(guard_history.failed_validations) > 0 + if error_message: + return cls( + raw_llm_output=raw_output or "", + validation_passed=False, + error=error_message, + ) + elif isinstance(validated_output, ReAsk): + reask: ReAsk = validated_output + return cls( + raw_llm_output=raw_output, + reask=reask, + validation_passed=any_validations_failed, + ) + else: + output = cast(OT, validated_output) + return cls( + raw_llm_output=raw_output, + validated_output=output, + validation_passed=any_validations_failed, + ) + + def __iter__( + self, + ) -> Iterator[ + Union[Optional[str], Optional[OT], Optional[ReAsk], bool, Optional[str]] + ]: + as_tuple: Tuple[ + Optional[str], Optional[OT], Optional[ReAsk], bool, Optional[str] + ] = ( + self.raw_llm_output, + self.validated_output, + self.reask, + self.validation_passed, + self.error, + ) + return iter(as_tuple) + + def __getitem__(self, keys): + return iter(getattr(self, k) for k in keys) diff --git a/guardrails/cli.py b/guardrails/cli.py index de24c442f..6c246c4c8 100644 --- a/guardrails/cli.py +++ b/guardrails/cli.py @@ -1,4 +1,5 @@ import json +from typing import Dict, Union import typer @@ -12,11 +13,11 @@ def compile_rail(rail: str, out: str) -> None: raise NotImplementedError("Currently compiling rail is not supported.") -def validate_llm_output(rail: str, llm_output: str) -> dict: +def validate_llm_output(rail: str, llm_output: str) -> Union[str, Dict, None]: """Validate guardrails.yml file.""" guard = Guard.from_rail(rail) result = guard.parse(llm_output) - return result + return result.validated_output @cli.command() diff --git a/guardrails/guard.py b/guardrails/guard.py index 66edd4a71..93db04e1f 100644 --- a/guardrails/guard.py +++ b/guardrails/guard.py @@ -6,18 +6,21 @@ Awaitable, Callable, Dict, + Generic, List, Optional, Sequence, - Tuple, Type, Union, + cast, overload, ) from eliot import add_destinations, start_action from pydantic import BaseModel +from guardrails.classes import OT, ValidationOutcome +from guardrails.classes.list_plus_plus import ListPlusPlus from guardrails.llm_providers import get_async_llm_ask, get_llm_ask from guardrails.prompt import Instructions, Prompt from guardrails.rail import Rail @@ -32,7 +35,7 @@ add_destinations(actions_logger.debug) -class Guard: +class Guard(Generic[OT]): """The Guard class. This class is the main entry point for using Guardrails. It is @@ -58,7 +61,7 @@ def __init__( """Initialize the Guard.""" self.rail = rail self.num_reasks = num_reasks - self.guard_state = GuardState(all_histories=[]) + self.guard_state = GuardState(all_histories=ListPlusPlus()) self.base_model = base_model @property @@ -132,7 +135,7 @@ def configure( ) @classmethod - def from_rail(cls, rail_file: str, num_reasks: Optional[int] = None) -> "Guard": + def from_rail(cls, rail_file: str, num_reasks: Optional[int] = None): """Create a Schema from a `.rail` file. Args: @@ -142,12 +145,13 @@ def from_rail(cls, rail_file: str, num_reasks: Optional[int] = None) -> "Guard": Returns: An instance of the `Guard` class. """ - return cls(Rail.from_file(rail_file), num_reasks=num_reasks) + rail = Rail.from_file(rail_file) + if rail.output_type == "str": + return cast(Guard[str], cls(rail=rail, num_reasks=num_reasks)) + return cast(Guard[Dict], cls(rail=rail, num_reasks=num_reasks)) @classmethod - def from_rail_string( - cls, rail_string: str, num_reasks: Optional[int] = None - ) -> "Guard": + def from_rail_string(cls, rail_string: str, num_reasks: Optional[int] = None): """Create a Schema from a `.rail` string. Args: @@ -157,7 +161,10 @@ def from_rail_string( Returns: An instance of the `Guard` class. """ - return cls(Rail.from_string(rail_string), num_reasks=num_reasks) + rail = Rail.from_string(rail_string) + if rail.output_type == "str": + return cast(Guard[str], cls(rail=rail, num_reasks=num_reasks)) + return cast(Guard[Dict], cls(rail=rail, num_reasks=num_reasks)) @classmethod def from_pydantic( @@ -168,7 +175,7 @@ def from_pydantic( num_reasks: Optional[int] = None, reask_prompt: Optional[str] = None, reask_instructions: Optional[str] = None, - ) -> "Guard": + ): """Create a Guard instance from a Pydantic model and prompt.""" rail = Rail.from_pydantic( output_class=output_class, @@ -177,7 +184,9 @@ def from_pydantic( reask_prompt=reask_prompt, reask_instructions=reask_instructions, ) - return cls(rail, num_reasks=num_reasks, base_model=output_class) + return cast( + Guard[Dict], cls(rail, num_reasks=num_reasks, base_model=output_class) + ) @classmethod def from_string( @@ -189,7 +198,7 @@ def from_string( reask_prompt: Optional[str] = None, reask_instructions: Optional[str] = None, num_reasks: Optional[int] = None, - ) -> "Guard": + ): """Create a Guard instance for a string response with prompt, instructions, and validations. @@ -210,12 +219,12 @@ def from_string( reask_prompt=reask_prompt, reask_instructions=reask_instructions, ) - return cls(rail, num_reasks=num_reasks) + return cast(Guard[str], cls(rail, num_reasks=num_reasks)) @overload def __call__( self, - llm_api: Callable[[Any], Awaitable[Any]], + llm_api: Callable, prompt_params: Optional[Dict] = None, num_reasks: Optional[int] = None, prompt: Optional[str] = None, @@ -225,13 +234,13 @@ def __call__( full_schema_reask: Optional[bool] = None, *args, **kwargs, - ) -> Awaitable[Tuple[str, Any]]: + ) -> ValidationOutcome[OT]: ... @overload def __call__( self, - llm_api: Callable, + llm_api: Callable[[Any], Awaitable[Any]], prompt_params: Optional[Dict] = None, num_reasks: Optional[int] = None, prompt: Optional[str] = None, @@ -241,7 +250,7 @@ def __call__( full_schema_reask: Optional[bool] = None, *args, **kwargs, - ) -> Tuple[str, Any]: + ) -> Awaitable[ValidationOutcome[OT]]: ... def __call__( @@ -256,7 +265,7 @@ def __call__( full_schema_reask: Optional[bool] = None, *args, **kwargs, - ) -> Union[Tuple[Optional[str], Any], Awaitable[Tuple[Optional[str], Any]]]: + ) -> Union[ValidationOutcome[OT], Awaitable[ValidationOutcome[OT]]]: """Call the LLM and validate the output. Pass an async LLM API to return a coroutine. @@ -334,7 +343,7 @@ def _call_sync( full_schema_reask: bool, *args, **kwargs, - ) -> Tuple[Optional[str], Any]: + ) -> ValidationOutcome[OT]: instructions_obj = instructions or self.instructions prompt_obj = prompt or self.prompt msg_history_obj = msg_history or [] @@ -359,8 +368,10 @@ def _call_sync( guard_state=self.guard_state, full_schema_reask=full_schema_reask, ) - guard_history = runner(prompt_params=prompt_params) - return guard_history.output, guard_history.validated_output + guard_history, error_message = runner(prompt_params=prompt_params) + return ValidationOutcome[OT].from_guard_history( + guard_history, error_message + ) async def _call_async( self, @@ -374,7 +385,7 @@ async def _call_async( full_schema_reask: bool, *args, **kwargs, - ) -> Tuple[Optional[str], Any]: + ) -> ValidationOutcome[OT]: """Call the LLM asynchronously and validate the output. Args: @@ -416,8 +427,12 @@ async def _call_async( guard_state=self.guard_state, full_schema_reask=full_schema_reask, ) - guard_history = await runner.async_run(prompt_params=prompt_params) - return guard_history.output, guard_history.validated_output + guard_history, error_message = await runner.async_run( + prompt_params=prompt_params + ) + return ValidationOutcome[OT].from_guard_history( + guard_history, error_message + ) def __repr__(self): return f"Guard(RAIL={self.rail})" @@ -436,7 +451,7 @@ def parse( full_schema_reask: Optional[bool] = None, *args, **kwargs, - ) -> Any: + ) -> ValidationOutcome[OT]: ... @overload @@ -450,7 +465,7 @@ def parse( full_schema_reask: Optional[bool] = None, *args, **kwargs, - ) -> Awaitable[Any]: + ) -> Awaitable[ValidationOutcome[OT]]: ... @overload @@ -464,7 +479,7 @@ def parse( full_schema_reask: Optional[bool] = None, *args, **kwargs, - ) -> Any: + ) -> ValidationOutcome[OT]: ... def parse( @@ -477,7 +492,7 @@ def parse( full_schema_reask: Optional[bool] = None, *args, **kwargs, - ) -> Union[Any, Awaitable[Any]]: + ) -> Union[ValidationOutcome[OT], Awaitable[ValidationOutcome[OT]]]: """Alternate flow to using Guard where the llm_output is known. Args: @@ -545,7 +560,7 @@ def _sync_parse( full_schema_reask: bool, *args, **kwargs, - ) -> Any: + ) -> ValidationOutcome[OT]: """Alternate flow to using Guard where the llm_output is known. Args: @@ -571,8 +586,17 @@ def _sync_parse( guard_state=self.guard_state, full_schema_reask=full_schema_reask, ) - guard_history = runner(prompt_params=prompt_params) - return sub_reasks_with_fixed_values(guard_history.validated_output) + guard_history, error_message = runner(prompt_params=prompt_params) + if len(guard_history.history) > 0: + guard_history.history[ + -1 + ].validated_output = sub_reasks_with_fixed_values( + guard_history.validated_output + ) + validation_outcome = ValidationOutcome[OT].from_guard_history( + guard_history, error_message + ) + return validation_outcome async def _async_parse( self, @@ -584,7 +608,7 @@ async def _async_parse( full_schema_reask: bool, *args, **kwargs, - ) -> Any: + ) -> ValidationOutcome[OT]: """Alternate flow to using Guard where the llm_output is known. Args: @@ -610,5 +634,15 @@ async def _async_parse( guard_state=self.guard_state, full_schema_reask=full_schema_reask, ) - guard_history = await runner.async_run(prompt_params=prompt_params) - return sub_reasks_with_fixed_values(guard_history.validated_output) + guard_history, error_message = await runner.async_run( + prompt_params=prompt_params + ) + if len(guard_history.history) > 0: + guard_history.history[ + -1 + ].validated_output = sub_reasks_with_fixed_values( + guard_history.validated_output + ) + return ValidationOutcome[OT].from_guard_history( + guard_history, error_message + ) diff --git a/guardrails/llm_providers.py b/guardrails/llm_providers.py index 7bef463d7..d5fa47093 100644 --- a/guardrails/llm_providers.py +++ b/guardrails/llm_providers.py @@ -132,7 +132,7 @@ def _invoke_llm( Use Guardrails with OpenAI chat engines by doing ``` - raw_llm_response, validated_response = guard( + raw_llm_response, validated_response, *rest = guard( openai.ChatCompletion.create, prompt_params={...}, text=..., @@ -193,7 +193,7 @@ def _invoke_llm( To use manifest for guardrailse, do ``` client = Manifest(client_name=..., client_connection=...) - raw_llm_response, validated_response = guard( + raw_llm_response, validated_response, *rest = guard( client, prompt_params={...}, ... @@ -222,7 +222,7 @@ def _invoke_llm( """To use cohere for guardrails, do ``` client = cohere.Client(api_key=...) - raw_llm_response, validated_response = guard( + raw_llm_response, validated_response, *rest = guard( client.generate, prompt_params={...}, model="command-nightly", @@ -250,7 +250,7 @@ def _invoke_llm(self, *args, **kwargs) -> LLMResponse: To use an arbitrary callable for guardrails, do ``` - raw_llm_response, validated_response = guard( + raw_llm_response, validated_response, *rest = guard( my_callable, prompt_params={...}, ... @@ -397,7 +397,7 @@ async def invoke_llm( Use Guardrails with OpenAI chat engines by doing ``` - raw_llm_response, validated_response = guard( + raw_llm_response, validated_response, *rest = guard( openai.ChatCompletion.create, prompt_params={...}, text=..., @@ -458,7 +458,7 @@ async def invoke_llm( To use manifest for guardrails, do ``` client = Manifest(client_name=..., client_connection=...) - raw_llm_response, validated_response = guard( + raw_llm_response, validated_response, *rest = guard( client, prompt_params={...}, ... @@ -492,7 +492,7 @@ async def invoke_llm(self, *args, **kwargs) -> LLMResponse: To use an arbitrary callable for guardrails, do ``` - raw_llm_response, validated_response = guard( + raw_llm_response, validated_response, *rest = guard( my_callable, prompt_params={...}, ... diff --git a/guardrails/rail.py b/guardrails/rail.py index ca97c6fa4..70ba03b40 100644 --- a/guardrails/rail.py +++ b/guardrails/rail.py @@ -35,6 +35,13 @@ class Rail: prompt: Optional[Prompt] version: str = "0.1" + @property + def output_type(self): + if isinstance(self.output_schema, StringSchema): + return "str" + else: + return "dict" + @classmethod def from_pydantic( cls, diff --git a/guardrails/run.py b/guardrails/run.py index f370a53af..ea9535232 100644 --- a/guardrails/run.py +++ b/guardrails/run.py @@ -5,6 +5,7 @@ from eliot import add_destinations, start_action from pydantic import BaseModel +from guardrails.classes import ListPlusPlus from guardrails.datatypes import verify_metadata_requirements from guardrails.llm_providers import AsyncPromptCallableBase, PromptCallableBase from guardrails.prompt import Instructions, Prompt @@ -94,16 +95,18 @@ def __init__( self.num_reasks = num_reasks self.metadata = metadata or {} self.output = output - self.guard_history = guard_history or GuardHistory(history=[]) + self.guard_history = guard_history or GuardHistory(history=ListPlusPlus()) self.base_model = base_model self.full_schema_reask = full_schema_reask def _reset_guard_history(self): """Reset the guard history.""" - self.guard_history = GuardHistory(history=[]) + self.guard_history = GuardHistory(history=ListPlusPlus()) self.guard_state.push(self.guard_history) - def __call__(self, prompt_params: Optional[Dict] = None) -> GuardHistory: + def __call__( + self, prompt_params: Optional[Dict] = None + ) -> Tuple[GuardHistory, Optional[str]]: """Execute the runner by repeatedly calling step until the reask budget is exhausted. @@ -114,69 +117,77 @@ def __call__(self, prompt_params: Optional[Dict] = None) -> GuardHistory: Returns: The guard history. """ - if prompt_params is None: - prompt_params = {} + error_message = None + try: + if prompt_params is None: + prompt_params = {} - # check if validator requirements are fulfilled - missing_keys = verify_metadata_requirements( - self.metadata, self.output_schema.root_datatype - ) - if missing_keys: - raise ValueError( - f"Missing required metadata keys: {', '.join(missing_keys)}" + # check if validator requirements are fulfilled + missing_keys = verify_metadata_requirements( + self.metadata, self.output_schema.root_datatype ) + if missing_keys: + raise ValueError( + f"Missing required metadata keys: {', '.join(missing_keys)}" + ) - self._reset_guard_history() - - # Figure out if we need to include instructions in the prompt. - include_instructions = not ( - self.instructions is None and self.msg_history is None - ) + self._reset_guard_history() - with start_action( - action_type="run", - instructions=self.instructions, - prompt=self.prompt, - api=self.api, - input_schema=self.input_schema, - output_schema=self.output_schema, - num_reasks=self.num_reasks, - metadata=self.metadata, - ): - instructions, prompt, msg_history, input_schema, output_schema = ( - self.instructions, - self.prompt, - self.msg_history, - self.input_schema, - self.output_schema, + # Figure out if we need to include instructions in the prompt. + include_instructions = not ( + self.instructions is None and self.msg_history is None ) - for index in range(self.num_reasks + 1): - # Run a single step. - validated_output, reasks = self.step( - index=index, - api=self.api, - instructions=instructions, - prompt=prompt, - msg_history=msg_history, - prompt_params=prompt_params, - input_schema=input_schema, - output_schema=output_schema, - output=self.output if index == 0 else None, - ) - # Loop again? - if not self.do_loop(index, reasks): - break - # Get new prompt and output schema. - prompt, instructions, output_schema, msg_history = self.prepare_to_loop( - reasks, - validated_output, - output_schema, - prompt_params=prompt_params, - include_instructions=include_instructions, + with start_action( + action_type="run", + instructions=self.instructions, + prompt=self.prompt, + api=self.api, + input_schema=self.input_schema, + output_schema=self.output_schema, + num_reasks=self.num_reasks, + metadata=self.metadata, + ): + instructions, prompt, msg_history, input_schema, output_schema = ( + self.instructions, + self.prompt, + self.msg_history, + self.input_schema, + self.output_schema, ) + for index in range(self.num_reasks + 1): + # Run a single step. + validated_output, reasks = self.step( + index=index, + api=self.api, + instructions=instructions, + prompt=prompt, + msg_history=msg_history, + prompt_params=prompt_params, + input_schema=input_schema, + output_schema=output_schema, + output=self.output if index == 0 else None, + ) - return self.guard_history + # Loop again? + if not self.do_loop(index, reasks): + break + # Get new prompt and output schema. + ( + prompt, + instructions, + output_schema, + msg_history, + ) = self.prepare_to_loop( + reasks, + validated_output, + output_schema, + prompt_params=prompt_params, + include_instructions=include_instructions, + ) + except Exception as e: + error_message = str(e) + return self.guard_history, error_message def step( self, @@ -493,7 +504,9 @@ def __init__( ) self.api: Optional[AsyncPromptCallableBase] = api - async def async_run(self, prompt_params: Optional[Dict] = None) -> GuardHistory: + async def async_run( + self, prompt_params: Optional[Dict] = None + ) -> Tuple[GuardHistory, Optional[str]]: """Execute the runner by repeatedly calling step until the reask budget is exhausted. @@ -504,62 +517,72 @@ async def async_run(self, prompt_params: Optional[Dict] = None) -> GuardHistory: Returns: The guard history. """ - if prompt_params is None: - prompt_params = {} - self._reset_guard_history() - - # check if validator requirements are fulfilled - missing_keys = verify_metadata_requirements( - self.metadata, self.output_schema.root_datatype - ) - if missing_keys: - raise ValueError( - f"Missing required metadata keys: {', '.join(missing_keys)}" - ) + error_message = None + try: + if prompt_params is None: + prompt_params = {} + self._reset_guard_history() - with start_action( - action_type="run", - instructions=self.instructions, - prompt=self.prompt, - api=self.api, - input_schema=self.input_schema, - output_schema=self.output_schema, - num_reasks=self.num_reasks, - metadata=self.metadata, - ): - instructions, prompt, msg_history, input_schema, output_schema = ( - self.instructions, - self.prompt, - self.msg_history, - self.input_schema, - self.output_schema, + # check if validator requirements are fulfilled + missing_keys = verify_metadata_requirements( + self.metadata, self.output_schema.root_datatype ) - for index in range(self.num_reasks + 1): - # Run a single step. - validated_output, reasks = await self.async_step( - index=index, - api=self.api, - instructions=instructions, - prompt=prompt, - msg_history=msg_history, - prompt_params=prompt_params, - input_schema=input_schema, - output_schema=output_schema, - output=self.output if index == 0 else None, + if missing_keys: + raise ValueError( + f"Missing required metadata keys: {', '.join(missing_keys)}" ) - # Loop again? - if not self.do_loop(index, reasks): - break - # Get new prompt and output schema. - prompt, instructions, output_schema, msg_history = self.prepare_to_loop( - reasks, - validated_output, - output_schema, - prompt_params=prompt_params, + with start_action( + action_type="run", + instructions=self.instructions, + prompt=self.prompt, + api=self.api, + input_schema=self.input_schema, + output_schema=self.output_schema, + num_reasks=self.num_reasks, + metadata=self.metadata, + ): + instructions, prompt, msg_history, input_schema, output_schema = ( + self.instructions, + self.prompt, + self.msg_history, + self.input_schema, + self.output_schema, ) + for index in range(self.num_reasks + 1): + # Run a single step. + validated_output, reasks = await self.async_step( + index=index, + api=self.api, + instructions=instructions, + prompt=prompt, + msg_history=msg_history, + prompt_params=prompt_params, + input_schema=input_schema, + output_schema=output_schema, + output=self.output if index == 0 else None, + ) + + # Loop again? + if not self.do_loop(index, reasks): + break + # Get new prompt and output schema. + ( + prompt, + instructions, + output_schema, + msg_history, + ) = self.prepare_to_loop( + reasks, + validated_output, + output_schema, + prompt_params=prompt_params, + ) + + except Exception as e: + error_message = str(e) - return self.guard_history + return self.guard_history, error_message async def async_step( self, diff --git a/guardrails/utils/logs_utils.py b/guardrails/utils/logs_utils.py index 74d998ebf..582ff69c3 100644 --- a/guardrails/utils/logs_utils.py +++ b/guardrails/utils/logs_utils.py @@ -8,6 +8,7 @@ from rich.table import Table from rich.tree import Tree +from guardrails.classes.list_plus_plus import ListPlusPlus from guardrails.prompt import Instructions, Prompt from guardrails.utils.llm_response import LLMResponse from guardrails.utils.pydantic_utils import ArbitraryModel @@ -43,7 +44,7 @@ class GuardLogs(ArbitraryModel): llm_response: Optional[LLMResponse] = None msg_history: Optional[List[Dict[str, Prompt]]] = None parsed_output: Optional[Dict] = None - validated_output: Optional[Union[Dict, ReAsk]] = None + validated_output: Optional[Union[str, Dict, ReAsk, None]] = None reasks: Optional[Sequence[ReAsk]] = None field_validation_logs: Optional[FieldValidationLogs] = None @@ -127,14 +128,18 @@ def create_msg_history_table( class GuardHistory(ArbitraryModel): - history: List[GuardLogs] + history: ListPlusPlus[GuardLogs] = Field(default_factory=ListPlusPlus) + + def __init__(self, history: ListPlusPlus[GuardLogs]): + super().__init__() + self.history = ListPlusPlus(*history) def push(self, guard_log: GuardLogs) -> None: if len(self.history) > 0: - last_log = self.history[-1] + last_log = self.history.at(-1) guard_log._previous_logs = last_log - self.history += [guard_log] + self.history.append(guard_log) @property def tree(self) -> Tree: @@ -145,19 +150,23 @@ def tree(self) -> Tree: return tree @property - def validated_output(self) -> Optional[Union[Dict, ReAsk]]: + def last_entry(self) -> Union[GuardLogs, None]: + return self.history.at(-1) + + @property + def validated_output(self) -> Union[str, Dict, ReAsk, None]: """Returns the latest validated output.""" - return self.history[-1].validated_output + return self.last_entry.validated_output if self.last_entry is not None else None @property def output(self) -> Optional[str]: """Returns the latest output.""" - return self.history[-1].output + return self.last_entry.output if self.last_entry is not None else None @property def output_as_dict(self) -> Optional[Dict]: """Returns the latest output as a dict.""" - return self.history[-1].parsed_output + return self.last_entry.parsed_output if self.last_entry is not None else None @property def failed_validations(self) -> List[List[ReAsk]]: @@ -166,17 +175,21 @@ def failed_validations(self) -> List[List[ReAsk]]: class GuardState(ArbitraryModel): - all_histories: List[GuardHistory] = Field(default_factory=list) + all_histories: ListPlusPlus[GuardHistory] = Field(default_factory=ListPlusPlus) + + def __init__(self, all_histories: ListPlusPlus[GuardHistory]): + super().__init__() + self.all_histories = ListPlusPlus(*all_histories) def push(self, guard_history: GuardHistory) -> None: - self.all_histories += [guard_history] + self.all_histories.append(guard_history) @property def most_recent_call(self) -> Optional[GuardHistory]: """Returns the most recent call.""" if not len(self.all_histories): return None - return self.all_histories[-1] + return self.all_histories.at(-1) def update_response_by_path(output: dict, path: List[Any], value: Any) -> None: diff --git a/guardrails/utils/reask_utils.py b/guardrails/utils/reask_utils.py index 368b21686..9191dabba 100644 --- a/guardrails/utils/reask_utils.py +++ b/guardrails/utils/reask_utils.py @@ -24,12 +24,12 @@ class NonParseableReAsk(ReAsk): pass -def gather_reasks(validated_output: Optional[Union[Dict, ReAsk]]) -> List[ReAsk]: +def gather_reasks(validated_output: Optional[Union[str, Dict, ReAsk]]) -> List[ReAsk]: """Traverse output and gather all ReAsk objects. Args: - validated_output (Dict): The output of a model. Each value can be a ReAsk, - a list, a dictionary, or a single value. + validated_output (Union[str, Dict, ReAsk], optional): The output of a model. + Each value can be a ReAsk, a list, a dictionary, or a single value. Returns: A list of ReAsk objects found in the output. @@ -73,7 +73,8 @@ def _gather_reasks_in_list( _gather_reasks_in_list(item, path + [idx]) return - _gather_reasks_in_dict(validated_output) + if isinstance(validated_output, Dict): + _gather_reasks_in_dict(validated_output) return reasks diff --git a/guardrails/validators.py b/guardrails/validators.py index 70e2ce2ea..124bd62e9 100644 --- a/guardrails/validators.py +++ b/guardrails/validators.py @@ -1357,7 +1357,8 @@ def _get_topics(self, text: str, topics: Optional[List[str]] = None) -> List[str """ guard = Guard.from_rail_string(spec) - _, validated_output = guard(llm_api=self.llm_callable) # type: ignore + _, validated_output, *rest = guard(llm_api=self.llm_callable) # type: ignore + validated_output = cast(Dict, validated_output) return validated_output["topics"] def validate(self, value: Any, metadata: Dict) -> ValidationResult: @@ -1415,7 +1416,7 @@ def __init__( llm_callable if llm_callable else get_static_openai_chat_create_func() ) - def _selfeval(self, question: str, answer: str): + def _selfeval(self, question: str, answer: str) -> Dict: from guardrails import Guard spec = """ @@ -1436,13 +1437,14 @@ def _selfeval(self, question: str, answer: str): question=question, answer=answer, ) - guard = Guard.from_rail_string(spec) + guard = Guard[Dict].from_rail_string(spec) - _, validated_output = guard( + response = guard( self.llm_callable, # type: ignore max_tokens=10, temperature=0.1, ) + validated_output = cast(Dict, response.validated_output) return validated_output def validate(self, value: Any, metadata: Dict) -> ValidationResult: @@ -1453,7 +1455,8 @@ def validate(self, value: Any, metadata: Dict) -> ValidationResult: question = metadata["question"] - relevant = self._selfeval(question, value)["relevant"] + self_evaluation: Dict = self._selfeval(question, value) + relevant = self_evaluation["relevant"] if relevant: return PassResult() diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration_tests/test_assets/__init__.py b/tests/integration_tests/test_assets/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration_tests/test_assets/fixtures/__init__.py b/tests/integration_tests/test_assets/fixtures/__init__.py new file mode 100644 index 000000000..6b08e8913 --- /dev/null +++ b/tests/integration_tests/test_assets/fixtures/__init__.py @@ -0,0 +1,69 @@ +import pytest + + +@pytest.fixture(name="rail_spec") +def fixture_rail_spec(): + return """ +Validated Output: {'translated_statement': \"It's so bad that it's a letdown.\"}\n", "\n" ], "text/plain": [ - "Validated Output: \u001b[1m{\u001b[0m\u001b[32m'translated_statement'\u001b[0m: \u001b[32m\"It is so bad that it's a letdown.\"\u001b[0m\u001b[1m}\u001b[0m\n" + "Validated Output: \u001b[1m{\u001b[0m\u001b[32m'translated_statement'\u001b[0m: \u001b[32m\"It's so bad that it's a letdown.\"\u001b[0m\u001b[1m}\u001b[0m\n" ] }, "metadata": {}, @@ -536,7 +519,7 @@ } ], "source": [ - "raw_llm_response, validated_response = guard(\n", + "raw_llm_response, validated_response, *rest = guard(\n", " openai.Completion.create,\n", " prompt_params={'statement_to_be_translated': 'ドン引きするほど翻訳が悪い。'},\n", " metadata={'translation_source': 'ドン引きするほど翻訳が悪い。'},\n", @@ -558,7 +541,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -577,8 +560,8 @@ " │ │ it into. │ │\n", " │ │ │ │\n", " │ │ <output> │ │\n", - " │ │ <string name=\"translated_statement\" format=\"is-high-quality-translation\" description=\"Translate the │ │\n", - " │ │ given statement into the English language\"/> │ │\n", + " │ │ <string name=\"translated_statement\" description=\"Translate the given statement into the English │ │\n", + " │ │ language\" format=\"is-high-quality-translation\"/> │ │\n", " │ │ </output> │ │\n", " │ │ │ │\n", " │ │ │ │\n", @@ -602,16 +585,13 @@ " │ │ │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Message History ────────────────────────────────────────────╮ │\n", - " │ │ ┏━━━━━━┳━━━━━━━━━┓ │ │\n", - " │ │ ┃ Role ┃ Content ┃ │ │\n", - " │ │ ┡━━━━━━╇━━━━━━━━━┩ │ │\n", - " │ │ └──────┴─────────┘ │ │\n", + " │ │ No message history. │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭──────────────────────────────────────────── Raw LLM Output ─────────────────────────────────────────────╮ │\n", - " │ │ {\"translated_statement\": \"It is so bad that it's a letdown.\"} │ │\n", + " │ │ {\"translated_statement\": \"It's so bad that it's a letdown.\"} │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " │ ╭─────────────────────────────────────────── Validated Output ────────────────────────────────────────────╮ │\n", - " │ │ {'translated_statement': \"It is so bad that it's a letdown.\"} │ │\n", + " │ │ {'translated_statement': \"It's so bad that it's a letdown.\"} │ │\n", " │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────╯ │\n", " ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n", "