From bdb039327bad5c99caba2af064d8d27472a754f4 Mon Sep 17 00:00:00 2001 From: Sebastian Husch Lee Date: Tue, 25 Aug 2026 08:28:33 +0200 Subject: [PATCH] update to use agent tool --- .../45_Creating_a_Multi_Agent_System.ipynb | 206 ++++++++++++------ 1 file changed, 145 insertions(+), 61 deletions(-) diff --git a/tutorials/45_Creating_a_Multi_Agent_System.ipynb b/tutorials/45_Creating_a_Multi_Agent_System.ipynb index 8b1c8ec1..c2e4d5db 100644 --- a/tutorials/45_Creating_a_Multi_Agent_System.ipynb +++ b/tutorials/45_Creating_a_Multi_Agent_System.ipynb @@ -10,14 +10,14 @@ "\n", "- **Level**: Advanced\n", "- **Time to complete**: 20 minutes\n", - "- **Components Used**: [`Agent`](https://docs.haystack.deepset.ai/docs/agent), [`DuckduckgoApiWebSearch`](https://haystack.deepset.ai/integrations/duckduckgo-api-websearch), [`OpenAIChatGenerator`](https://docs.haystack.deepset.ai/docs/openaichatgenerator), [`DocumentWriter`](https://docs.haystack.deepset.ai/docs/documentwriter)\n", - "- **Prerequisites**: You need an [OpenAI API Key](https://platform.openai.com/api-keys), and a [Notion Integration](https://developers.notion.com/docs/create-a-notion-integration#getting-started) set up beforehand\n", + "- **Components Used**: [`Agent`](https://docs.haystack.deepset.ai/docs/agent), [`AgentTool`](https://docs.haystack.deepset.ai/docs/agenttool), [`DuckduckgoApiWebSearch`](https://haystack.deepset.ai/integrations/duckduckgo-api-websearch), [`OpenAIChatGenerator`](https://docs.haystack.deepset.ai/docs/openaichatgenerator), [`DocumentWriter`](https://docs.haystack.deepset.ai/docs/documentwriter)\n", + "- **Prerequisites**: You need Haystack 3.1 or newer, an [OpenAI API Key](https://platform.openai.com/api-keys), and a [Notion Integration](https://developers.notion.com/docs/create-a-notion-integration#getting-started) set up beforehand\n", "- **Goal**: After completing this tutorial, you'll have learned how to build a multi-agent system in Haystack where each agent is specialized for a specific task.\n", "\n", "## Overview\n", "**Multi-agent** systems are made up of several intelligent agents that work together to solve complex tasks more effectively than a single agent alone. Each agent takes on a specific role or skill, allowing for distributed reasoning, task specialization, and smooth coordination within one unified system.\n", "\n", - "What makes this possible in Haystack is the ability to use **agents as tools** for other agents. This powerful pattern allows you to compose modular, specialized agents and orchestrate them through a main agent that delegates tasks based on context.\n", + "What makes this possible in Haystack is the ability to use **agents as tools** for other agents. This powerful pattern allows you to compose modular, specialized agents and orchestrate them through a main agent that delegates tasks based on context. Since Haystack 3.1, [`AgentTool`](https://docs.haystack.deepset.ai/docs/agenttool) is the dedicated building block for it: it turns an `Agent` into a tool that another `Agent` can delegate to.\n", "\n", "In this tutorial, you'll build a simple yet powerful multi-agent setup with one main agent and two sub-agents: one focused on researching information, and the other on saving it." ] @@ -42,7 +42,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -50,23 +50,11 @@ "id": "8Q3xX8ppqrqC", "outputId": "895d9478-fd39-41a0-b255-4078acb08c0b" }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m514.7/514.7 kB\u001b[0m \u001b[31m8.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m96.7/96.7 kB\u001b[0m \u001b[31m8.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m74.5/74.5 kB\u001b[0m \u001b[31m5.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[2K \u001b[90m\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u001b[0m \u001b[32m3.3/3.3 MB\u001b[0m \u001b[31m55.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25h" - ] - } - ], + "outputs": [], "source": [ "%%bash\n", "\n", - "pip install -q haystack-ai duckduckgo-api-haystack" + "pip install -q \"haystack-ai>=3.1.0\" duckduckgo-api-haystack" ] }, { @@ -82,7 +70,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -90,7 +78,16 @@ "id": "PU26Ayr8rI3t", "outputId": "eea1c012-870f-4376-ac9c-879d4e4a14e2" }, - "outputs": [], + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter your OpenAI API key: ········\n", + "Enter your NOTION API key: ········\n" + ] + } + ], "source": [ "from getpass import getpass\n", "import os\n", @@ -118,7 +115,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": { "id": "YRREx0yzRaE2" }, @@ -168,7 +165,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "id": "4vnseY962j96" }, @@ -214,7 +211,7 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 5, "metadata": { "id": "nNWU3iwDxhsA" }, @@ -357,7 +354,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 6, "metadata": { "id": "nBPs30VuyBiK" }, @@ -462,7 +459,7 @@ "id": "OHA3nnEJIWEb" }, "source": [ - "> \ud83d\udca1 When turning a custom component into a tool using `ComponentTool`, make sure its input parameters are well-defined. You can do this in one of two ways:\n", + "> 💡 When turning a custom component into a tool using `ComponentTool`, make sure its input parameters are well-defined. You can do this in one of two ways:\n", "1. Pass a `properties` dictionary to `ComponentTool`, or\n", "2. Use parameter annotations in the `run` method's docstring, like so:\n", "```python\n", @@ -477,7 +474,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -497,7 +494,7 @@ " 'type': 'object'}" ] }, - "execution_count": 38, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -525,12 +522,12 @@ "\n", "To make this work, start by creating a pipeline that includes the custom `DocumentAdapter` component along with the [DocumentWriter](https://docs.haystack.deepset.ai/docs/documentwriter). Once the pipeline is ready, wrap it in a `PipelineTool` to expose it as an LLM-callable tool.\n", "\n", - "> \ud83d\udca1 **Tip**: You could also wrap the pipeline in a `@tool`-decorated function for full control over what the LLM sees \u2014 including simplified parameters, formatted output, and custom error handling. Use `PipelineTool` when you prefer **declarative configuration**: the pipeline is captured in one serializable object. Learn more in the [PipelineTool docs](https://docs.haystack.deepset.ai/docs/pipelinetool)." + "> 💡 **Tip**: You could also wrap the pipeline in a `@tool`-decorated function for full control over what the LLM sees — including simplified parameters, formatted output, and custom error handling. Use `PipelineTool` when you prefer **declarative configuration**: the pipeline is captured in one serializable object. Learn more in the [PipelineTool docs](https://docs.haystack.deepset.ai/docs/pipelinetool)." ] }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 8, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -549,12 +546,48 @@ " 'required': ['title', 'content']}" ] }, - "execution_count": 47, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], - "source": "from haystack import Pipeline, component, Document\nfrom haystack.components.writers import DocumentWriter\nfrom haystack.document_stores.in_memory import InMemoryDocumentStore\nfrom haystack.tools import PipelineTool\nfrom typing import List\n\n\n@component\nclass DocumentAdapter:\n @component.output_types(documents=List[Document])\n def run(self, content: str, title: str):\n return {\"documents\": [Document(content=content, meta={\"title\": title})]}\n\n\ndocument_store = InMemoryDocumentStore()\n\ndoc_store_writer_pipeline = Pipeline()\ndoc_store_writer_pipeline.add_component(\"adapter\", DocumentAdapter())\ndoc_store_writer_pipeline.add_component(\"writer\", DocumentWriter(document_store=document_store))\ndoc_store_writer_pipeline.connect(\"adapter\", \"writer\")\n\ndoc_store_writer = PipelineTool(\n pipeline=doc_store_writer_pipeline,\n name=\"doc_store_writer\",\n description=\"Use this tool to write/save content to document store\",\n parameters={\n \"type\": \"object\",\n \"properties\": {\n \"title\": {\"type\": \"string\", \"description\": \"The title of the Document\"},\n \"content\": {\"type\": \"string\", \"description\": \"The content of the Document\"},\n },\n \"required\": [\"title\", \"content\"],\n },\n)\ndoc_store_writer.parameters" + "source": [ + "from haystack import Pipeline, component, Document\n", + "from haystack.components.writers import DocumentWriter\n", + "from haystack.document_stores.in_memory import InMemoryDocumentStore\n", + "from haystack.tools import PipelineTool\n", + "from typing import List\n", + "\n", + "\n", + "@component\n", + "class DocumentAdapter:\n", + " @component.output_types(documents=List[Document])\n", + " def run(self, content: str, title: str):\n", + " return {\"documents\": [Document(content=content, meta={\"title\": title})]}\n", + "\n", + "\n", + "document_store = InMemoryDocumentStore()\n", + "\n", + "doc_store_writer_pipeline = Pipeline()\n", + "doc_store_writer_pipeline.add_component(\"adapter\", DocumentAdapter())\n", + "doc_store_writer_pipeline.add_component(\"writer\", DocumentWriter(document_store=document_store))\n", + "doc_store_writer_pipeline.connect(\"adapter\", \"writer\")\n", + "\n", + "doc_store_writer = PipelineTool(\n", + " pipeline=doc_store_writer_pipeline,\n", + " name=\"doc_store_writer\",\n", + " description=\"Use this tool to write/save content to document store\",\n", + " parameters={\n", + " \"type\": \"object\",\n", + " \"properties\": {\n", + " \"title\": {\"type\": \"string\", \"description\": \"The title of the Document\"},\n", + " \"content\": {\"type\": \"string\", \"description\": \"The content of the Document\"},\n", + " },\n", + " \"required\": [\"title\", \"content\"],\n", + " },\n", + ")\n", + "doc_store_writer.parameters" + ] }, { "cell_type": "markdown", @@ -575,7 +608,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 9, "metadata": { "id": "4zl5YDywzUxq" }, @@ -665,12 +698,19 @@ "\n", "So far, you've built two sub-agents, one for research and one for writing, along with their respective tools. Now it's time to bring everything together into a **single multi-agent system**.\n", "\n", - "To do this, wrap both `research_agent` and `writer_agent` with `ComponentTool`, then pass them as tools to your `main_agent`. This setup allows the main agent to coordinate the overall workflow by delegating tasks to the right sub-agent, each of which already knows how to handle its own tools." + "To do this, wrap both `research_agent` and `writer_agent` with [`AgentTool`](https://docs.haystack.deepset.ai/docs/agenttool), then pass them as tools to your `main_agent`. This setup allows the main agent to coordinate the overall workflow by delegating tasks to the right sub-agent, each of which already knows how to handle its own tools.\n", + "\n", + "`AgentTool` is designed for exactly this pattern and comes with defaults that fit delegation:\n", + "- The task is handed over as a **single user message**, so the main agent doesn't need to know anything about the sub-agent's internals.\n", + "- Only the sub-agent's **final reply** is returned to the main agent. All the intermediate steps the sub-agent takes (tool calls, tool results, drafts) stay out of the main agent's context.\n", + "- If the sub-agent stopped because it hit `max_agent_steps`, a warning is appended to the result, so the main agent doesn't mistake a truncated answer for a complete one.\n", + "\n", + "> 💡 Before Haystack 3.1, you would wrap an agent with `ComponentTool` and set `outputs_to_string={\"source\": \"last_message\"}` by hand. `AgentTool` does this for you and also validates that it's really an `Agent` being wrapped. If you need to customize the schema, the returned string, or share values through the calling agent's state, `AgentTool` accepts the same `parameters`, `outputs_to_string`, `inputs_from_state`, and `outputs_to_state` arguments as `ComponentTool`.\n" ] }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 10, "metadata": { "id": "uEoKaKpXBXHC" }, @@ -679,18 +719,15 @@ "from haystack.components.agents import Agent\n", "from haystack.components.generators.chat import OpenAIChatGenerator\n", "from haystack.components.generators.utils import print_streaming_chunk\n", + "from haystack.tools import AgentTool\n", "\n", - "research_tool = ComponentTool(\n", - " component=research_agent,\n", - " description=\"Use this tool to find information on web or specifically on wikipedia\",\n", + "research_tool = AgentTool(\n", + " agent=research_agent,\n", " name=\"research_tool\",\n", - " outputs_to_string={\"source\": \"last_message\"},\n", + " description=\"Use this tool to find information on web or specifically on wikipedia\",\n", ")\n", - "writer_tool = ComponentTool(\n", - " component=writer_agent,\n", - " description=\"Use this tool to write content into document store or Notion\",\n", - " name=\"writer_tool\",\n", - " outputs_to_string={\"source\": \"last_message\"},\n", + "writer_tool = AgentTool(\n", + " agent=writer_agent, name=\"writer_tool\", description=\"Use this tool to write content into document store or Notion\"\n", ")\n", "\n", "main_agent = Agent(\n", @@ -705,6 +742,43 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Take a look at the schema `AgentTool` generated for you. The main agent only has to fill in a single user message with the task it wants to delegate:" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'type': 'object',\n", + " 'properties': {'messages': {'type': 'array',\n", + " 'description': 'Exactly one user message.',\n", + " 'minItems': 1,\n", + " 'maxItems': 1,\n", + " 'items': {'type': 'object',\n", + " 'properties': {'role': {'type': 'string', 'enum': ['user']},\n", + " 'content': {'type': 'string',\n", + " 'description': 'The task to delegate to this tool.'}},\n", + " 'required': ['role', 'content']}}},\n", + " 'required': ['messages']}" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "research_tool.parameters" + ] + }, { "cell_type": "markdown", "metadata": { @@ -748,7 +822,7 @@ "\n", " The Silk Road was a network of Asian trade routes active from the second century BCE until the mid-15th century. Spanning over 6,400 km (4,000 mi), ...File Content for https://en.wikipedia.org/wiki/Silk_Road_(marketplace)\n", "\n", - " The name \"Silk Road\" comes from a historical network of trade routes started during the Han Dynasty (206 BCE \u2013 220 CE) between Europe, India, China, and many ...File Content for https://en.wikipedia.org/wiki/The_Silk_Roads\n", + " The name \"Silk Road\" comes from a historical network of trade routes started during the Han Dynasty (206 BCE – 220 CE) between Europe, India, China, and many ...File Content for https://en.wikipedia.org/wiki/The_Silk_Roads\n", "\n", " The Silk Roads: A New History of the World is a 2015 non-fiction book written by English historian Peter Frankopan, a historian at the University of Oxford.File Content for https://en.wikipedia.org/wiki/Cities_along_the_Silk_Road\n", "\n", @@ -758,7 +832,7 @@ "\n", "The Silk Road was a network of trade routes that facilitated commerce and cultural exchange between various civilizations, particularly between Europe and Asia. It was active from the 2nd century BCE until the mid-15th century and spanned over 6,400 kilometers (approximately 4,000 miles).\n", "\n", - "The name \"Silk Road\" is derived from the lucrative silk trade that was carried out along these routes, starting during the Han Dynasty (206 BCE \u2013 220 CE) under Emperor Wu. The routes connected China with India, Persia, and further to Europe, allowing for the exchange of goods, ideas, and cultures.\n", + "The name \"Silk Road\" is derived from the lucrative silk trade that was carried out along these routes, starting during the Han Dynasty (206 BCE – 220 CE) under Emperor Wu. The routes connected China with India, Persia, and further to Europe, allowing for the exchange of goods, ideas, and cultures.\n", "\n", "Historically, the Silk Road comprised various routes, including both overland and maritime paths. It played a significant role in the development of the civilizations that it connected by facilitating trade in not only silk but also other commodities like spices, textiles, and precious stones.\n", "\n", @@ -769,13 +843,13 @@ "\n", "\n", "[TOOL RESULT]\n", - "{'messages': [{'role': 'system', 'meta': {}, 'name': None, 'content': [{'text': '\\n You are a research agent that can find information on web or specifically on wikipedia. \\n Use wiki_search tool if you need facts and use web_search tool for latest news on topics.\\n Use one tool at a time. Try different queries if you need more information.\\n Only use the retrieved context, do not use your own knowledge.\\n Summarize the all retrieved information before returning response to the user.\\n '}]}, {'role': 'user', 'meta': {}, 'name': None, 'content': [{'text': 'Can you provide an overview of the history of the Silk Road?'}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:16:49.904424', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'History of the Silk Road'}, 'id': 'call_pxDTCHYeS27s9drCvQ507ie8'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Silk_Road\\n\\n The Silk Road was a network of Asian trade routes active from the second century BCE until the mid-15th century. Spanning over 6,400 km (4,000 mi), ...File Content for https://en.wikipedia.org/wiki/Silk_Road_(marketplace)\\n\\n The name \"Silk Road\" comes from a historical network of trade routes started during the Han Dynasty (206 BCE \u2013 220 CE) between Europe, India, China, and many ...File Content for https://en.wikipedia.org/wiki/The_Silk_Roads\\n\\n The Silk Roads: A New History of the World is a 2015 non-fiction book written by English historian Peter Frankopan, a historian at the University of Oxford.File Content for https://en.wikipedia.org/wiki/Cities_along_the_Silk_Road\\n\\n It came into existence in the 2nd century BCE, when Emperor Wu of the Han dynasty was in power, and lasted until the 15th century CE, when the Ottoman Empire ...File Content for https://en.wikipedia.org/wiki/Northern_Silk_Road\\n\\n The Northern Silk Road is a historic inland trade route in Northwest China and Central Asia originating in the ancient Chinese capital of Chang\\'an (modern ...', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'History of the Silk Road'}, 'id': 'call_pxDTCHYeS27s9drCvQ507ie8'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'stop', 'completion_start_time': '2025-05-28T15:16:51.627946', 'usage': None}, 'name': None, 'content': [{'text': 'The Silk Road was a network of trade routes that facilitated commerce and cultural exchange between various civilizations, particularly between Europe and Asia. It was active from the 2nd century BCE until the mid-15th century and spanned over 6,400 kilometers (approximately 4,000 miles).\\n\\nThe name \"Silk Road\" is derived from the lucrative silk trade that was carried out along these routes, starting during the Han Dynasty (206 BCE \u2013 220 CE) under Emperor Wu. The routes connected China with India, Persia, and further to Europe, allowing for the exchange of goods, ideas, and cultures.\\n\\nHistorically, the Silk Road comprised various routes, including both overland and maritime paths. It played a significant role in the development of the civilizations that it connected by facilitating trade in not only silk but also other commodities like spices, textiles, and precious stones.\\n\\nThe importance of the Silk Road diminished in the late 15th century due to the rise of maritime trade routes and the expansion of empires, such as the Ottoman Empire, which changed the dynamics of trade and cultural exchange in the regions it linked.\\n\\nOverall, the Silk Road is a crucial part of world history, representing an extensive system of trade that fostered interactions among diverse cultures over centuries.'}]}], 'last_message': {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'stop', 'completion_start_time': '2025-05-28T15:16:51.627946', 'usage': None}, 'name': None, 'content': [{'text': 'The Silk Road was a network of trade routes that facilitated commerce and cultural exchange between various civilizations, particularly between Europe and Asia. It was active from the 2nd century BCE until the mid-15th century and spanned over 6,400 kilometers (approximately 4,000 miles).\\n\\nThe name \"Silk Road\" is derived from the lucrative silk trade that was carried out along these routes, starting during the Han Dynasty (206 BCE \u2013 220 CE) under Emperor Wu. The routes connected China with India, Persia, and further to Europe, allowing for the exchange of goods, ideas, and cultures.\\n\\nHistorically, the Silk Road comprised various routes, including both overland and maritime paths. It played a significant role in the development of the civilizations that it connected by facilitating trade in not only silk but also other commodities like spices, textiles, and precious stones.\\n\\nThe importance of the Silk Road diminished in the late 15th century due to the rise of maritime trade routes and the expansion of empires, such as the Ottoman Empire, which changed the dynamics of trade and cultural exchange in the regions it linked.\\n\\nOverall, the Silk Road is a crucial part of world history, representing an extensive system of trade that fostered interactions among diverse cultures over centuries.'}]}}\n", + "{'messages': [{'role': 'system', 'meta': {}, 'name': None, 'content': [{'text': '\\n You are a research agent that can find information on web or specifically on wikipedia. \\n Use wiki_search tool if you need facts and use web_search tool for latest news on topics.\\n Use one tool at a time. Try different queries if you need more information.\\n Only use the retrieved context, do not use your own knowledge.\\n Summarize the all retrieved information before returning response to the user.\\n '}]}, {'role': 'user', 'meta': {}, 'name': None, 'content': [{'text': 'Can you provide an overview of the history of the Silk Road?'}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:16:49.904424', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'History of the Silk Road'}, 'id': 'call_pxDTCHYeS27s9drCvQ507ie8'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Silk_Road\\n\\n The Silk Road was a network of Asian trade routes active from the second century BCE until the mid-15th century. Spanning over 6,400 km (4,000 mi), ...File Content for https://en.wikipedia.org/wiki/Silk_Road_(marketplace)\\n\\n The name \"Silk Road\" comes from a historical network of trade routes started during the Han Dynasty (206 BCE – 220 CE) between Europe, India, China, and many ...File Content for https://en.wikipedia.org/wiki/The_Silk_Roads\\n\\n The Silk Roads: A New History of the World is a 2015 non-fiction book written by English historian Peter Frankopan, a historian at the University of Oxford.File Content for https://en.wikipedia.org/wiki/Cities_along_the_Silk_Road\\n\\n It came into existence in the 2nd century BCE, when Emperor Wu of the Han dynasty was in power, and lasted until the 15th century CE, when the Ottoman Empire ...File Content for https://en.wikipedia.org/wiki/Northern_Silk_Road\\n\\n The Northern Silk Road is a historic inland trade route in Northwest China and Central Asia originating in the ancient Chinese capital of Chang\\'an (modern ...', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'History of the Silk Road'}, 'id': 'call_pxDTCHYeS27s9drCvQ507ie8'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'stop', 'completion_start_time': '2025-05-28T15:16:51.627946', 'usage': None}, 'name': None, 'content': [{'text': 'The Silk Road was a network of trade routes that facilitated commerce and cultural exchange between various civilizations, particularly between Europe and Asia. It was active from the 2nd century BCE until the mid-15th century and spanned over 6,400 kilometers (approximately 4,000 miles).\\n\\nThe name \"Silk Road\" is derived from the lucrative silk trade that was carried out along these routes, starting during the Han Dynasty (206 BCE – 220 CE) under Emperor Wu. The routes connected China with India, Persia, and further to Europe, allowing for the exchange of goods, ideas, and cultures.\\n\\nHistorically, the Silk Road comprised various routes, including both overland and maritime paths. It played a significant role in the development of the civilizations that it connected by facilitating trade in not only silk but also other commodities like spices, textiles, and precious stones.\\n\\nThe importance of the Silk Road diminished in the late 15th century due to the rise of maritime trade routes and the expansion of empires, such as the Ottoman Empire, which changed the dynamics of trade and cultural exchange in the regions it linked.\\n\\nOverall, the Silk Road is a crucial part of world history, representing an extensive system of trade that fostered interactions among diverse cultures over centuries.'}]}], 'last_message': {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'stop', 'completion_start_time': '2025-05-28T15:16:51.627946', 'usage': None}, 'name': None, 'content': [{'text': 'The Silk Road was a network of trade routes that facilitated commerce and cultural exchange between various civilizations, particularly between Europe and Asia. It was active from the 2nd century BCE until the mid-15th century and spanned over 6,400 kilometers (approximately 4,000 miles).\\n\\nThe name \"Silk Road\" is derived from the lucrative silk trade that was carried out along these routes, starting during the Han Dynasty (206 BCE – 220 CE) under Emperor Wu. The routes connected China with India, Persia, and further to Europe, allowing for the exchange of goods, ideas, and cultures.\\n\\nHistorically, the Silk Road comprised various routes, including both overland and maritime paths. It played a significant role in the development of the civilizations that it connected by facilitating trade in not only silk but also other commodities like spices, textiles, and precious stones.\\n\\nThe importance of the Silk Road diminished in the late 15th century due to the rise of maritime trade routes and the expansion of empires, such as the Ottoman Empire, which changed the dynamics of trade and cultural exchange in the regions it linked.\\n\\nOverall, the Silk Road is a crucial part of world history, representing an extensive system of trade that fostered interactions among diverse cultures over centuries.'}]}}\n", "\n", - "The Silk Road was a vast network of trade routes that facilitated commerce and cultural exchange among various civilizations, primarily between Europe and Asia. Here\u2019s an overview of its history:\n", + "The Silk Road was a vast network of trade routes that facilitated commerce and cultural exchange among various civilizations, primarily between Europe and Asia. Here’s an overview of its history:\n", "\n", "- **Time Period**: The Silk Road was active from the 2nd century BCE until the mid-15th century, spanning over 6,400 kilometers (approximately 4,000 miles).\n", "\n", - "- **Origin of the Name**: The term \"Silk Road\" comes from the lucrative silk trade that flourished along these routes, a practice that began during the Han Dynasty (206 BCE \u2013 220 CE) under Emperor Wu.\n", + "- **Origin of the Name**: The term \"Silk Road\" comes from the lucrative silk trade that flourished along these routes, a practice that began during the Han Dynasty (206 BCE – 220 CE) under Emperor Wu.\n", "\n", "- **Geographical Connections**: The routes connected China with India, Persia, and extended to Europe, allowing not only for the trade of silk but also various commodities such as spices, textiles, and precious stones.\n", "\n", @@ -820,7 +894,7 @@ "type": "string" }, "text/plain": [ - "'The Silk Road was a vast network of trade routes that facilitated commerce and cultural exchange among various civilizations, primarily between Europe and Asia. Here\u2019s an overview of its history:\\n\\n- **Time Period**: The Silk Road was active from the 2nd century BCE until the mid-15th century, spanning over 6,400 kilometers (approximately 4,000 miles).\\n\\n- **Origin of the Name**: The term \"Silk Road\" comes from the lucrative silk trade that flourished along these routes, a practice that began during the Han Dynasty (206 BCE \u2013 220 CE) under Emperor Wu.\\n\\n- **Geographical Connections**: The routes connected China with India, Persia, and extended to Europe, allowing not only for the trade of silk but also various commodities such as spices, textiles, and precious stones.\\n\\n- **Cultural Exchange**: The Silk Road served as a conduit for the exchange of goods, ideas, technologies, and cultures, significantly impacting the development of the civilizations involved.\\n\\n- **Dynamics Changes**: The significance of the Silk Road diminished in the late 15th century due to the advent of maritime trade routes and the rise of empires like the Ottoman Empire, which altered trade dynamics in the regions connected by the Silk Road.\\n\\nOverall, the Silk Road represents a crucial chapter in world history, illustrating how trade can foster interactions among diverse cultures over centuries.'" + "'The Silk Road was a vast network of trade routes that facilitated commerce and cultural exchange among various civilizations, primarily between Europe and Asia. Here’s an overview of its history:\\n\\n- **Time Period**: The Silk Road was active from the 2nd century BCE until the mid-15th century, spanning over 6,400 kilometers (approximately 4,000 miles).\\n\\n- **Origin of the Name**: The term \"Silk Road\" comes from the lucrative silk trade that flourished along these routes, a practice that began during the Han Dynasty (206 BCE – 220 CE) under Emperor Wu.\\n\\n- **Geographical Connections**: The routes connected China with India, Persia, and extended to Europe, allowing not only for the trade of silk but also various commodities such as spices, textiles, and precious stones.\\n\\n- **Cultural Exchange**: The Silk Road served as a conduit for the exchange of goods, ideas, technologies, and cultures, significantly impacting the development of the civilizations involved.\\n\\n- **Dynamics Changes**: The significance of the Silk Road diminished in the late 15th century due to the advent of maritime trade routes and the rise of empires like the Ottoman Empire, which altered trade dynamics in the regions connected by the Silk Road.\\n\\nOverall, the Silk Road represents a crucial chapter in world history, illustrating how trade can foster interactions among diverse cultures over centuries.'" ] }, "execution_count": 66, @@ -887,13 +961,13 @@ "\n", " Retrieval-augmented generation (RAG) is a technique that enables large language models (LLMs) to retrieve and incorporate new information.File Content for https://en.wikipedia.org/wiki/Rag\n", "\n", - " Retrieval-augmented generation, generative AI with the addition of information retrieval capabilities. See also. edit \u00b7 All pages with titles beginning with Rag ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\n", + " Retrieval-augmented generation, generative AI with the addition of information retrieval capabilities. See also. edit · All pages with titles beginning with Rag ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\n", "\n", " Retrieval-augmented generation (RAG) is a technique that enables generative ... Graph retrieval-augmented generation. edit. GraphRAG with a knowledge ...File Content for https://en.wikipedia.org/wiki/Large_language_model\n", "\n", " Retrieval-augmented generation (RAG) is another approach that enhances LLMs by integrating them with document retrieval systems. Given a query, a document ...File Content for https://en.wikipedia.org/wiki/Category:Information_retrieval_systems\n", "\n", - " Retrieval-augmented generation \u00b7 RetrievalWare \u00b7 Reverse DNS lookup \u00b7 Reverse telephone directory. S. List of search appliance vendors \u00b7 Search engine ( ...\n", + " Retrieval-augmented generation · RetrievalWare · Reverse DNS lookup · Reverse telephone directory. S. List of search appliance vendors · Search engine ( ...\n", "\n", "\n", "\n", @@ -937,7 +1011,7 @@ "\n", " Confidential computing is a security and privacy-enhancing computational technique focused on protecting data in use.\n", "\n", - "Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here\u2019s a summary of how RAG pipelines work:\n", + "Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here’s a summary of how RAG pipelines work:\n", "\n", "1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\n", "\n", @@ -950,19 +1024,19 @@ "\n", "\n", "[TOOL RESULT]\n", - "{'messages': [{'role': 'system', 'meta': {}, 'name': None, 'content': [{'text': '\\n You are a research agent that can find information on web or specifically on wikipedia. \\n Use wiki_search tool if you need facts and use web_search tool for latest news on topics.\\n Use one tool at a time. Try different queries if you need more information.\\n Only use the retrieved context, do not use your own knowledge.\\n Summarize the all retrieved information before returning response to the user.\\n '}]}, {'role': 'user', 'meta': {}, 'name': None, 'content': [{'text': 'Summarize how RAG pipelines work.'}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:33.573590', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'RAG pipelines'}, 'id': 'call_xnAEMUy7iCVrRSDbViUJHqXG'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Retrieval-augmented_generation\\n\\n Retrieval-augmented generation (RAG) is a technique that enables large language models (LLMs) to retrieve and incorporate new information. With RAG, LLMs do ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\\n\\n GraphRAG (coined by Microsoft Research) is a technique that extends RAG with the use of a knowledge graph (usually, LLM-generated) to allow the model to ...File Content for https://en.wikipedia.org/wiki/Large_language_model\\n\\n Retrieval-augmented generation (RAG) is another approach that enhances LLMs by integrating them with document retrieval systems. Given a query, a document ...File Content for https://en.wikipedia.org/wiki/RagTime\\n\\n RagTime is a frame-oriented business publishing software which combines word processing, spreadsheets, simple drawings, image processing, and chartsFile Content for https://en.wikipedia.org/wiki/Zelten_oil_field\\n\\n SOC operates the Raguba field in the central part of the Sirte Basin. The field is connected by pipeline to the main line between the Zelten field and Brega.', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'RAG pipelines'}, 'id': 'call_xnAEMUy7iCVrRSDbViUJHqXG'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:35.182539', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'Retrieval-augmented generation'}, 'id': 'call_ECjlLz2bcH0JO0po00qG50LT'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Retrieval-augmented_generation\\n\\n Retrieval-augmented generation (RAG) is a technique that enables large language models (LLMs) to retrieve and incorporate new information.File Content for https://en.wikipedia.org/wiki/Rag\\n\\n Retrieval-augmented generation, generative AI with the addition of information retrieval capabilities. See also. edit \u00b7 All pages with titles beginning with Rag ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\\n\\n Retrieval-augmented generation (RAG) is a technique that enables generative ... Graph retrieval-augmented generation. edit. GraphRAG with a knowledge ...File Content for https://en.wikipedia.org/wiki/Large_language_model\\n\\n Retrieval-augmented generation (RAG) is another approach that enhances LLMs by integrating them with document retrieval systems. Given a query, a document ...File Content for https://en.wikipedia.org/wiki/Category:Information_retrieval_systems\\n\\n Retrieval-augmented generation \u00b7 RetrievalWare \u00b7 Reverse DNS lookup \u00b7 Reverse telephone directory. S. List of search appliance vendors \u00b7 Search engine ( ...', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'Retrieval-augmented generation'}, 'id': 'call_ECjlLz2bcH0JO0po00qG50LT'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:36.804910', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'how RAG pipelines work'}, 'id': 'call_fIBCEMoLaUUDoJnZw137JVSP'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Retrieval-augmented_generation\\n\\n RAG improves large language models (LLMs) by incorporating information retrieval before generating responses. Unlike traditional LLMs that rely on static ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\\n\\n Prompt engineering is the process of structuring or crafting an instruction in order to produce the best possible output from a generative artificial ...File Content for https://en.wikipedia.org/wiki/RNA_therapeutics\\n\\n The main types of RNA therapeutics are those based on messenger RNA (mRNA), antisense RNA (asRNA), RNA interference (RNAi), RNA activation (RNAa) and RNA ...File Content for https://en.wikipedia.org/wiki/Aviation_Cadet_Training_Program_(USN)\\n\\n The US Navy had four programs (NavCad, NAP, AVMIDN, and MarCad) for the training of naval aviators.File Content for https://en.wikipedia.org/wiki/DataStax\\n\\n DataStax, Inc. is a real-time data for AI company based in Santa Clara, California. Its product Astra DB is a cloud database-as-a-service based on Apache ...', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'how RAG pipelines work'}, 'id': 'call_fIBCEMoLaUUDoJnZw137JVSP'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:38.455416', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'Retrieval-augmented generation RAG mechanism'}, 'id': 'call_3GRCPA5myd3uwqFhqbvXn1qk'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Retrieval-augmented_generation\\n\\n Retrieval-augmented generation (RAG) is a technique that enables large language models (LLMs) to retrieve and incorporate new information. With RAG ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\\n\\n Retrieval-augmented generation (RAG) is a technique that enables generative artificial intelligence (Gen AI) models to retrieve and incorporate new information.File Content for https://en.wikipedia.org/wiki/Large_language_model\\n\\n Retrieval-augmented generation (RAG) is another approach that enhances LLMs by integrating them with document retrieval systems. Given a query, a document ...File Content for https://en.wikipedia.org/wiki/Generative_artificial_intelligence\\n\\n Generative artificial intelligence is a subfield of artificial intelligence that uses generative models to produce text, images, videos, or other forms of ...File Content for https://en.wikipedia.org/wiki/Confidential_computing\\n\\n Confidential computing is a security and privacy-enhancing computational technique focused on protecting data in use.', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'Retrieval-augmented generation RAG mechanism'}, 'id': 'call_3GRCPA5myd3uwqFhqbvXn1qk'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'stop', 'completion_start_time': '2025-05-28T15:18:41.265652', 'usage': None}, 'name': None, 'content': [{'text': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here\u2019s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}]}], 'last_message': {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'stop', 'completion_start_time': '2025-05-28T15:18:41.265652', 'usage': None}, 'name': None, 'content': [{'text': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here\u2019s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}]}}\n", + "{'messages': [{'role': 'system', 'meta': {}, 'name': None, 'content': [{'text': '\\n You are a research agent that can find information on web or specifically on wikipedia. \\n Use wiki_search tool if you need facts and use web_search tool for latest news on topics.\\n Use one tool at a time. Try different queries if you need more information.\\n Only use the retrieved context, do not use your own knowledge.\\n Summarize the all retrieved information before returning response to the user.\\n '}]}, {'role': 'user', 'meta': {}, 'name': None, 'content': [{'text': 'Summarize how RAG pipelines work.'}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:33.573590', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'RAG pipelines'}, 'id': 'call_xnAEMUy7iCVrRSDbViUJHqXG'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Retrieval-augmented_generation\\n\\n Retrieval-augmented generation (RAG) is a technique that enables large language models (LLMs) to retrieve and incorporate new information. With RAG, LLMs do ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\\n\\n GraphRAG (coined by Microsoft Research) is a technique that extends RAG with the use of a knowledge graph (usually, LLM-generated) to allow the model to ...File Content for https://en.wikipedia.org/wiki/Large_language_model\\n\\n Retrieval-augmented generation (RAG) is another approach that enhances LLMs by integrating them with document retrieval systems. Given a query, a document ...File Content for https://en.wikipedia.org/wiki/RagTime\\n\\n RagTime is a frame-oriented business publishing software which combines word processing, spreadsheets, simple drawings, image processing, and chartsFile Content for https://en.wikipedia.org/wiki/Zelten_oil_field\\n\\n SOC operates the Raguba field in the central part of the Sirte Basin. The field is connected by pipeline to the main line between the Zelten field and Brega.', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'RAG pipelines'}, 'id': 'call_xnAEMUy7iCVrRSDbViUJHqXG'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:35.182539', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'Retrieval-augmented generation'}, 'id': 'call_ECjlLz2bcH0JO0po00qG50LT'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Retrieval-augmented_generation\\n\\n Retrieval-augmented generation (RAG) is a technique that enables large language models (LLMs) to retrieve and incorporate new information.File Content for https://en.wikipedia.org/wiki/Rag\\n\\n Retrieval-augmented generation, generative AI with the addition of information retrieval capabilities. See also. edit · All pages with titles beginning with Rag ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\\n\\n Retrieval-augmented generation (RAG) is a technique that enables generative ... Graph retrieval-augmented generation. edit. GraphRAG with a knowledge ...File Content for https://en.wikipedia.org/wiki/Large_language_model\\n\\n Retrieval-augmented generation (RAG) is another approach that enhances LLMs by integrating them with document retrieval systems. Given a query, a document ...File Content for https://en.wikipedia.org/wiki/Category:Information_retrieval_systems\\n\\n Retrieval-augmented generation · RetrievalWare · Reverse DNS lookup · Reverse telephone directory. S. List of search appliance vendors · Search engine ( ...', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'Retrieval-augmented generation'}, 'id': 'call_ECjlLz2bcH0JO0po00qG50LT'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:36.804910', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'how RAG pipelines work'}, 'id': 'call_fIBCEMoLaUUDoJnZw137JVSP'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Retrieval-augmented_generation\\n\\n RAG improves large language models (LLMs) by incorporating information retrieval before generating responses. Unlike traditional LLMs that rely on static ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\\n\\n Prompt engineering is the process of structuring or crafting an instruction in order to produce the best possible output from a generative artificial ...File Content for https://en.wikipedia.org/wiki/RNA_therapeutics\\n\\n The main types of RNA therapeutics are those based on messenger RNA (mRNA), antisense RNA (asRNA), RNA interference (RNAi), RNA activation (RNAa) and RNA ...File Content for https://en.wikipedia.org/wiki/Aviation_Cadet_Training_Program_(USN)\\n\\n The US Navy had four programs (NavCad, NAP, AVMIDN, and MarCad) for the training of naval aviators.File Content for https://en.wikipedia.org/wiki/DataStax\\n\\n DataStax, Inc. is a real-time data for AI company based in Santa Clara, California. Its product Astra DB is a cloud database-as-a-service based on Apache ...', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'how RAG pipelines work'}, 'id': 'call_fIBCEMoLaUUDoJnZw137JVSP'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:38.455416', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'wiki_search', 'arguments': {'query': 'Retrieval-augmented generation RAG mechanism'}, 'id': 'call_3GRCPA5myd3uwqFhqbvXn1qk'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': 'File Content for https://en.wikipedia.org/wiki/Retrieval-augmented_generation\\n\\n Retrieval-augmented generation (RAG) is a technique that enables large language models (LLMs) to retrieve and incorporate new information. With RAG ...File Content for https://en.wikipedia.org/wiki/Prompt_engineering\\n\\n Retrieval-augmented generation (RAG) is a technique that enables generative artificial intelligence (Gen AI) models to retrieve and incorporate new information.File Content for https://en.wikipedia.org/wiki/Large_language_model\\n\\n Retrieval-augmented generation (RAG) is another approach that enhances LLMs by integrating them with document retrieval systems. Given a query, a document ...File Content for https://en.wikipedia.org/wiki/Generative_artificial_intelligence\\n\\n Generative artificial intelligence is a subfield of artificial intelligence that uses generative models to produce text, images, videos, or other forms of ...File Content for https://en.wikipedia.org/wiki/Confidential_computing\\n\\n Confidential computing is a security and privacy-enhancing computational technique focused on protecting data in use.', 'origin': {'tool_name': 'wiki_search', 'arguments': {'query': 'Retrieval-augmented generation RAG mechanism'}, 'id': 'call_3GRCPA5myd3uwqFhqbvXn1qk'}, 'error': False}}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'stop', 'completion_start_time': '2025-05-28T15:18:41.265652', 'usage': None}, 'name': None, 'content': [{'text': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here’s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}]}], 'last_message': {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'stop', 'completion_start_time': '2025-05-28T15:18:41.265652', 'usage': None}, 'name': None, 'content': [{'text': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here’s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}]}}\n", "\n", "\n", "\n", "[TOOL CALL]\n", "Tool: writer_tool \n", - "Arguments: {\"messages\":[{\"role\":\"user\",\"content\":[{\"text\":\"Summary of how RAG pipelines work:\\n\\nRetrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here\u2019s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.\"}]}]}\n", + "Arguments: {\"messages\":[{\"role\":\"user\",\"content\":[{\"text\":\"Summary of how RAG pipelines work:\\n\\nRetrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here’s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.\"}]}]}\n", "\n", "\n", "\n", "[TOOL CALL]\n", "Tool: notion_writer \n", - "Arguments: {\"title\":\"How RAG Pipelines Work\",\"content\":\"Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here\u2019s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.\"}\n", + "Arguments: {\"title\":\"How RAG Pipelines Work\",\"content\":\"Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here’s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.\"}\n", "\n", "\n", "\n", @@ -972,7 +1046,7 @@ "\n", "\n", "[TOOL RESULT]\n", - "{'messages': [{'role': 'system', 'meta': {}, 'name': None, 'content': [{'text': '\\n You are a writer agent that saves given information to different locations.\\n Do not change the provided content before saving.\\n Infer the title from the text if not provided. \\n When you need to save provided information to Notion, use notion_writer tool.\\n When you need to save provided information to document store, use doc_store_writer tool\\n If no location is mentioned, use notion_writer tool to save the information.\\n '}]}, {'role': 'user', 'meta': {}, 'name': None, 'content': [{'text': 'Summary of how RAG pipelines work:\\n\\nRetrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here\u2019s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:50.908456', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'notion_writer', 'arguments': {'title': 'How RAG Pipelines Work', 'content': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here\u2019s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}, 'id': 'call_t8V2bODfsxlOiTeCdVWWznir'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': \"{'success': True, 'status_code': 200}\", 'origin': {'tool_name': 'notion_writer', 'arguments': {'title': 'How RAG Pipelines Work', 'content': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here\u2019s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}, 'id': 'call_t8V2bODfsxlOiTeCdVWWznir'}, 'error': False}}]}], 'last_message': {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': \"{'success': True, 'status_code': 200}\", 'origin': {'tool_name': 'notion_writer', 'arguments': {'title': 'How RAG Pipelines Work', 'content': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here\u2019s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}, 'id': 'call_t8V2bODfsxlOiTeCdVWWznir'}, 'error': False}}]}}\n", + "{'messages': [{'role': 'system', 'meta': {}, 'name': None, 'content': [{'text': '\\n You are a writer agent that saves given information to different locations.\\n Do not change the provided content before saving.\\n Infer the title from the text if not provided. \\n When you need to save provided information to Notion, use notion_writer tool.\\n When you need to save provided information to document store, use doc_store_writer tool\\n If no location is mentioned, use notion_writer tool to save the information.\\n '}]}, {'role': 'user', 'meta': {}, 'name': None, 'content': [{'text': 'Summary of how RAG pipelines work:\\n\\nRetrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here’s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}]}, {'role': 'assistant', 'meta': {'model': 'gpt-4o-mini-2024-07-18', 'index': 0, 'finish_reason': 'tool_calls', 'completion_start_time': '2025-05-28T15:18:50.908456', 'usage': None}, 'name': None, 'content': [{'tool_call': {'tool_name': 'notion_writer', 'arguments': {'title': 'How RAG Pipelines Work', 'content': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here’s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}, 'id': 'call_t8V2bODfsxlOiTeCdVWWznir'}}]}, {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': \"{'success': True, 'status_code': 200}\", 'origin': {'tool_name': 'notion_writer', 'arguments': {'title': 'How RAG Pipelines Work', 'content': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here’s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}, 'id': 'call_t8V2bODfsxlOiTeCdVWWznir'}, 'error': False}}]}], 'last_message': {'role': 'tool', 'meta': {}, 'name': None, 'content': [{'tool_call_result': {'result': \"{'success': True, 'status_code': 200}\", 'origin': {'tool_name': 'notion_writer', 'arguments': {'title': 'How RAG Pipelines Work', 'content': 'Retrieval-Augmented Generation (RAG) is a method that enhances large language models (LLMs) by integrating the capability to retrieve external information before generating responses. Here’s a summary of how RAG pipelines work:\\n\\n1. **Information Retrieval**: The first step in a RAG pipeline involves querying an external document retrieval system. Given an input query, the system retrieves relevant documents or pieces of information from a larger corpus.\\n\\n2. **Response Generation**: After retrieving the relevant documents, the RAG leverages the LLM to generate a response. The LLM uses the external documents as context, allowing it to produce more accurate and informed outputs compared to traditional LLMs that rely purely on their pre-existing knowledge.\\n\\n3. **Integration of New Information**: By incorporating real-time data retrieved from documents, RAG systems can provide answers that are more relevant, up-to-date, and comprehensive. This bridging between retrieval systems and generative models allows for better-informed and nuanced responses.\\n\\nIn essence, RAG works by utilizing a two-step process, combining the strengths of information retrieval with the generative capabilities of LLMs, to enhance the quality of generated content.'}, 'id': 'call_t8V2bODfsxlOiTeCdVWWznir'}, 'error': False}}]}}\n", "\n", "The summary of how Retrieval-Augmented Generation (RAG) pipelines work has been successfully saved in Notion. If you need anything else, feel free to ask!\n", "\n" @@ -999,7 +1073,7 @@ "source": [ "## What's next\n", "\n", - "\ud83c\udf89 Congratulations! You've just built a multi-agent system with Haystack, where specialized agents work together to research and write, each with their own tools and responsibilities. You now have a flexible foundation for building more complex, modular agent workflows.\n", + "🎉 Congratulations! You've just built a multi-agent system with Haystack, where specialized agents work together to research and write, each with their own tools and responsibilities. You now have a flexible foundation for building more complex, modular agent workflows.\n", "\n", "Curious to keep exploring? Here are a few great next steps:\n", "\n", @@ -1017,13 +1091,23 @@ "provenance": [] }, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", + "language": "python", "name": "python3" }, "language_info": { - "name": "python" + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.12.11" } }, "nbformat": 4, - "nbformat_minor": 0 -} \ No newline at end of file + "nbformat_minor": 4 +}