From df06041eb2a9d593b7242763f2abd9b8460fe86b Mon Sep 17 00:00:00 2001 From: ccurme Date: Thu, 3 Jul 2025 14:12:10 -0400 Subject: [PATCH] docs: Anthropic search_result nits (#31855) --- docs/docs/integrations/chat/anthropic.ipynb | 31 +++++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/docs/integrations/chat/anthropic.ipynb b/docs/docs/integrations/chat/anthropic.ipynb index ceb06d2c05d..17a3f67d58a 100644 --- a/docs/docs/integrations/chat/anthropic.ipynb +++ b/docs/docs/integrations/chat/anthropic.ipynb @@ -988,9 +988,10 @@ " return [\n", " {\n", " \"type\": \"search_result\",\n", - " \"title\": \"Leave policy\",\n", - " \"source\": \"HR Leave Policy 2025\",\n", - " \"citations\": { \"enabled\": True },\n", + " # Customize fields as desired, using document metadata or otherwise\n", + " \"title\": \"My Document Title\",\n", + " \"source\": \"Source description or provenance\",\n", + " \"citations\": {\"enabled\": True},\n", " \"content\": [{\"type\": \"text\", \"text\": doc.page_content}],\n", " }\n", " for doc in results\n", @@ -1026,12 +1027,20 @@ " \"To request vacation days, submit a leave request form through the \"\n", " \"HR portal. Approval will be sent by email.\"\n", " ),\n", - " metadata={\"category\": \"HR Policy\"},\n", + " metadata={\n", + " \"category\": \"HR Policy\",\n", + " \"doc_title\": \"Leave Policy\",\n", + " \"provenance\": \"Leave Policy - page 1\",\n", + " },\n", ")\n", "document_2 = Document(\n", " id=\"2\",\n", " page_content=\"Managers will review vacation requests within 3 business days.\",\n", - " metadata={\"category\": \"HR Policy\"},\n", + " metadata={\n", + " \"category\": \"HR Policy\",\n", + " \"doc_title\": \"Leave Policy\",\n", + " \"provenance\": \"Leave Policy - page 2\",\n", + " },\n", ")\n", "document_3 = Document(\n", " id=\"3\",\n", @@ -1039,7 +1048,11 @@ " \"Employees with over 6 months tenure are eligible for 20 paid vacation days \"\n", " \"per year.\"\n", " ),\n", - " metadata={\"category\": \"Benefits Policy\"},\n", + " metadata={\n", + " \"category\": \"Benefits Policy\",\n", + " \"doc_title\": \"Benefits Guide 2025\",\n", + " \"provenance\": \"Benefits Policy - page 1\",\n", + " },\n", ")\n", "\n", "documents = [document_1, document_2, document_3]\n", @@ -1062,9 +1075,9 @@ " return [\n", " {\n", " \"type\": \"search_result\",\n", - " \"title\": \"Leave policy\",\n", - " \"source\": \"HR Leave Policy 2025\",\n", - " \"citations\": { \"enabled\": True },\n", + " \"title\": doc.metadata[\"doc_title\"],\n", + " \"source\": doc.metadata[\"provenance\"],\n", + " \"citations\": {\"enabled\": True},\n", " \"content\": [{\"type\": \"text\", \"text\": doc.page_content}],\n", " }\n", " for doc in results\n",