From 81df19259298182aeabcf1b31f1225e64b624d65 Mon Sep 17 00:00:00 2001 From: Caleb Courier Date: Thu, 21 Nov 2024 09:50:55 -0600 Subject: [PATCH 1/3] limit PII detection; update prompt --- docs/integrations/llama_index.ipynb | 35 ++++++++++++++--------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/docs/integrations/llama_index.ipynb b/docs/integrations/llama_index.ipynb index 533919ae7..bdf618692 100644 --- a/docs/integrations/llama_index.ipynb +++ b/docs/integrations/llama_index.ipynb @@ -38,7 +38,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -50,15 +50,14 @@ "\n", "\n", "Installing hub:\u001b[35m/\u001b[0m\u001b[35m/guardrails/\u001b[0m\u001b[95mcompetitor_check...\u001b[0m\n", - "✅Successfully installed guardrails/competitor_check version \u001b[1;36m0.0\u001b[0m.\u001b[1;36m1\u001b[0m!\n", + "✅Successfully installed guardrails/competitor_check!\n", "\n", "\n" ] } ], "source": [ - "! guardrails hub install hub://guardrails/detect_pii --no-install-local-models -q\n", - "! guardrails hub install hub://guardrails/competitor_check --no-install-local-models -q" + "! guardrails hub install hub://guardrails/detect_pii hub://guardrails/competitor_check --no-install-local-models -q" ] }, { @@ -70,7 +69,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -79,7 +78,7 @@ "text": [ " % Total % Received % Xferd Average Speed Time Time Time Current\n", " Dload Upload Total Spent Left Speed\n", - "100 75042 100 75042 0 0 959k 0 --:--:-- --:--:-- --:--:-- 964k\n" + "100 75042 100 75042 0 0 353k 0 --:--:-- --:--:-- --:--:-- 354k\n" ] } ], @@ -99,7 +98,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -136,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -148,7 +147,7 @@ " competitors=[\"Fortran\", \"Ada\", \"Pascal\"],\n", " on_fail=\"fix\"\n", " )\n", - ").use(DetectPII(pii_entities=\"pii\", on_fail=\"fix\"))" + ").use(DetectPII(pii_entities=[\"PERSON\", \"EMAIL_ADDRESS\"], on_fail=\"fix\"))" ] }, { @@ -162,21 +161,21 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The author worked on writing short stories and programming, starting with early attempts on an IBM 1401 using Fortran in 9th grade, and later transitioning to microcomputers like the TRS-80 and Apple II to write games, rocket prediction programs, and a word processor.\n" + "The author is Paul Graham. Growing up, he worked on writing short stories and programming, starting with the IBM 1401 in 9th grade using an early version of Fortran. Later, he transitioned to microcomputers like the TRS-80 and began programming more extensively, creating simple games and a word processor.\n" ] } ], "source": [ "# Use index on it's own\n", "query_engine = index.as_query_engine()\n", - "response = query_engine.query(\"What did the author do growing up?\")\n", + "response = query_engine.query(\"Who is the author and what did they do growing up?\")\n", "print(response)" ] }, @@ -189,14 +188,14 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The author worked on writing short stories and programming, starting with early attempts on an IBM 1401 using [COMPETITOR] in 9th er, the author transitioned to microcomputers, building a Heathkit kit and eventually getting a TRS-80 to write simple games and spite enjoying programming, the author initially planned to study philosophy in college but eventually switched to AI due to a lack of interest in philosophy courses.\n" + "The author is . Growing up, he worked on writing short stories and programming, starting with the IBM 1401 in 9th grade using an early version of [COMPETITOR]. Later, he transitioned to microcomputers like the TRS-80 and Apple II, where he wrote simple games, programs, and a word processor. \n" ] } ], @@ -206,7 +205,7 @@ "\n", "guardrails_query_engine = GuardrailsQueryEngine(engine=query_engine, guard=guard)\n", "\n", - "response = guardrails_query_engine.query(\"What did the author do growing up?\")\n", + "response = guardrails_query_engine.query(\"Who is the author and what did they do growing up?\")\n", "print(response)\n", " " ] @@ -220,14 +219,14 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The author worked on writing short stories and programming while growing ey started with early attempts on an IBM 1401 using [COMPETITOR] in 9th er, they transitioned to microcomputers, building simple games and a word processor on a TRS-80 in .\n" + "The author is . Growing up, he worked on writing short stories and programming. He started with early attempts on an IBM 1401 using [COMPETITOR] in 9th grade. Later, he transitioned to microcomputers, building a Heathkit kit and eventually getting a TRS-80 to write simple games and programs. Despite enjoying programming, he initially planned to study philosophy in college but eventually switched to AI due to a lack of interest in philosophy courses. \n" ] } ], @@ -237,7 +236,7 @@ "chat_engine = index.as_chat_engine()\n", "guardrails_chat_engine = GuardrailsChatEngine(engine=chat_engine, guard=guard)\n", "\n", - "response = guardrails_chat_engine.chat(\"Tell me what the author did growing up.\")\n", + "response = guardrails_chat_engine.chat(\"Tell me who the author is and what they did growing up.\")\n", "print(response)" ] } From 5d84a2aab32e615cbbf7f1485784197daab0de1f Mon Sep 17 00:00:00 2001 From: Caleb Courier Date: Thu, 21 Nov 2024 09:52:07 -0600 Subject: [PATCH 2/3] format --- docs/integrations/llama_index.ipynb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/integrations/llama_index.ipynb b/docs/integrations/llama_index.ipynb index bdf618692..fa96e3288 100644 --- a/docs/integrations/llama_index.ipynb +++ b/docs/integrations/llama_index.ipynb @@ -135,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -147,7 +147,12 @@ " competitors=[\"Fortran\", \"Ada\", \"Pascal\"],\n", " on_fail=\"fix\"\n", " )\n", - ").use(DetectPII(pii_entities=[\"PERSON\", \"EMAIL_ADDRESS\"], on_fail=\"fix\"))" + ").use(\n", + " DetectPII(\n", + " pii_entities=[\"PERSON\", \"EMAIL_ADDRESS\"], \n", + " on_fail=\"fix\"\n", + " )\n", + ")" ] }, { From e123c2815593fa4782d1ef2dd760e54f102811e9 Mon Sep 17 00:00:00 2001 From: Caleb Courier Date: Thu, 21 Nov 2024 09:54:00 -0600 Subject: [PATCH 3/3] sidbar item --- docusaurus/sidebars.js | 1 + 1 file changed, 1 insertion(+) diff --git a/docusaurus/sidebars.js b/docusaurus/sidebars.js index a737c415e..10640e644 100644 --- a/docusaurus/sidebars.js +++ b/docusaurus/sidebars.js @@ -104,6 +104,7 @@ const sidebars = { integrations: [ // "integrations/azure_openai", "integrations/langchain", + "integrations/llama_index", { type: "category", label: "Telemetry",