From d4b9404fd69f53c60728b0d5c0f6535782aa6891 Mon Sep 17 00:00:00 2001 From: Amaan Date: Sat, 18 Jan 2025 05:32:28 +0530 Subject: [PATCH] docs: add langchain dappier tool integration notebook (#29265) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add tools to interact with Dappier APIs with an example notebook. For `DappierRealTimeSearchTool`, the tool can be invoked with: ```python from langchain_dappier import DappierRealTimeSearchTool tool = DappierRealTimeSearchTool() tool.invoke({"query": "What happened at the last wimbledon"}) ``` ``` At the last Wimbledon in 2024, Carlos Alcaraz won the title by defeating Novak Djokovic. This victory marked Alcaraz's fourth Grand Slam title at just 21 years old! ๐ŸŽ‰๐Ÿ†๐ŸŽพ ``` For DappierAIRecommendationTool the tool can be invoked with: ```python from langchain_dappier import DappierAIRecommendationTool tool = DappierAIRecommendationTool( data_model_id="dm_01j0pb465keqmatq9k83dthx34", similarity_top_k=3, ref="sportsnaut.com", num_articles_ref=2, search_algorithm="most_recent", ) ``` ``` [{"author": "Matt Weaver", "image_url": "https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34...", "pubdate": "Fri, 17 Jan 2025 08:04:03 +0000", "source_url": "https://sportsnaut.com/chili-bowl-thursday-bell-column/", "summary": "The article highlights the thrilling unpredictability... ", "title": "Thursday proves why every lap of Chili Bowl..."}, {"author": "Matt Higgins", "image_url": "https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34...", "pubdate": "Fri, 17 Jan 2025 02:48:42 +0000", "source_url": "https://sportsnaut.com/new-york-mets-news-pete-alonso...", "summary": "The New York Mets are likely parting ways with star...", "title": "MLB insiders reveal New York Metsโ€™ last-ditch..."}, {"author": "Jim Cerny", "image_url": "https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34...", "pubdate": "Fri, 17 Jan 2025 05:10:39 +0000", "source_url": "https://www.foreverblueshirts.com/new-york-rangers-news...", "summary": "The New York Rangers achieved a thrilling 5-3 comeback... ", "title": "Rangers score 3 times in 3rd period for stirring 5-3..."}] ``` The integration package can be found over here - https://github.com/DappierAI/langchain-dappier --- docs/docs/integrations/providers/dappier.mdx | 11 + .../integrations/retrievers/dappier.ipynb | 8 - docs/docs/integrations/tools/dappier.ipynb | 504 ++++++++++++++++++ 3 files changed, 515 insertions(+), 8 deletions(-) create mode 100644 docs/docs/integrations/tools/dappier.ipynb diff --git a/docs/docs/integrations/providers/dappier.mdx b/docs/docs/integrations/providers/dappier.mdx index 7e15d7b7289e9..2a1235984f106 100644 --- a/docs/docs/integrations/providers/dappier.mdx +++ b/docs/docs/integrations/providers/dappier.mdx @@ -46,3 +46,14 @@ See a [usage example](/docs/integrations/retrievers/dappier). ```python from langchain_dappier import DappierRetriever ``` + +## Tool + +See a [usage example](/docs/integrations/tools/dappier). + +```python +from langchain_dappier import ( + DappierRealTimeSearchTool, + DappierAIRecommendationTool +) +``` diff --git a/docs/docs/integrations/retrievers/dappier.ipynb b/docs/docs/integrations/retrievers/dappier.ipynb index 5ceeb25d0ab12..94cf86c8ca4ca 100644 --- a/docs/docs/integrations/retrievers/dappier.ipynb +++ b/docs/docs/integrations/retrievers/dappier.ipynb @@ -25,14 +25,6 @@ "\n", "This will help you getting started with the Dappier [retriever](https://python.langchain.com/docs/concepts/retrievers/). For detailed documentation of all DappierRetriever features and configurations head to the [API reference](https://python.langchain.com/en/latest/retrievers/langchain_dappier.retrievers.Dappier.DappierRetriever.html).\n", "\n", - "### Integration details\n", - "\n", - "Bring-your-own data (i.e., index and search a custom corpus of documents):\n", - "\n", - "| Retriever | Self-host | Cloud offering | Package |\n", - "| :--- | :--- | :---: | :---: |\n", - "[DappierRetriever](https://python.langchain.com/en/latest/retrievers/langchain_dappier.retrievers.Dappier.DappierRetriever.html) | โŒ | โŒ | langchain-dappier |\n", - "\n", "### Setup\n", "\n", "Install ``langchain-dappier`` and set environment variable ``DAPPIER_API_KEY``.\n", diff --git a/docs/docs/integrations/tools/dappier.ipynb b/docs/docs/integrations/tools/dappier.ipynb new file mode 100644 index 0000000000000..52ef3b5656783 --- /dev/null +++ b/docs/docs/integrations/tools/dappier.ipynb @@ -0,0 +1,504 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "BJB3NSYqUWl4" + }, + "source": [ + "# Dappier\n", + "\n", + "[Dappier](https://dappier.com) connects any LLM or your Agentic AI to real-time, rights-cleared, proprietary data from trusted sources, making your AI an expert in anything. Our specialized models include Real-Time Web Search, News, Sports, Financial Stock Market Data, Crypto Data, and exclusive content from premium publishers. Explore a wide range of data models in our marketplace at [marketplace.dappier.com](https://marketplace.dappier.com).\n", + "\n", + "[Dappier](https://dappier.com) delivers enriched, prompt-ready, and contextually relevant data strings, optimized for seamless integration with LangChain. Whether you're building conversational AI, recommendation engines, or intelligent search, Dappier's LLM-agnostic RAG models ensure your AI has access to verified, up-to-date dataโ€”without the complexity of building and managing your own retrieval pipeline." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "MAbkvI8pUb7R" + }, + "source": [ + "# Dappier Tool\n", + "\n", + "This will help you getting started with the Dappier [tool](https://python.langchain.com/docs/concepts/tools/). For detailed documentation of all DappierRetriever features and configurations head to the [API reference](https://python.langchain.com/en/latest/tools/langchain_dappier.tools.Dappier.DappierRealTimeSearchTool.html).\n", + "\n", + "## Overview\n", + "\n", + "The DappierRealTimeSearchTool and DappierAIRecommendationTool empower AI applications with real-time data and AI-driven insights. The former provides access to up-to-date information across news, weather, travel, and financial markets, while the latter supercharges applications with factual, premium content from diverse domains like News, Finance, and Sports, all powered by Dappier's pre-trained RAG models and natural language APIs." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ouA6p-E-aF34" + }, + "source": [ + "### Setup\n", + "\n", + "This tool lives in the `langchain-dappier` package." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "tNhKB0BUaneq" + }, + "outputs": [], + "source": [ + "%pip install -qU langchain-dappier" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "oBLVZpnoYshG" + }, + "source": [ + "### Credentials\n", + "\n", + "We also need to set our Dappier API credentials, which can be generated at the [Dappier site.](https://platform.dappier.com/profile/api-keys)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "UrmBR_JyY9I6" + }, + "outputs": [], + "source": [ + "import getpass\n", + "import os\n", + "\n", + "if not os.environ.get(\"DAPPIER_API_KEY\"):\n", + " os.environ[\"DAPPIER_API_KEY\"] = getpass.getpass(\"Dappier API key:\\n\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "x_3712yIXTGc" + }, + "source": [ + "If you want to get automated tracing from individual queries, you can also set your [LangSmith](https://docs.smith.langchain.com/) API key by uncommenting below:" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "id": "S1Tuwpq-XVaX" + }, + "outputs": [], + "source": [ + "# os.environ[\"LANGSMITH_API_KEY\"] = getpass.getpass(\"Enter your LangSmith API key: \")\n", + "# os.environ[\"LANGSMITH_TRACING\"] = \"true\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "IgPgQ12wcA4i" + }, + "source": [ + "## DappierRealTimeSearchTool\n", + "\n", + "Access real-time Google search results, including the latest news, weather, travel, and deals, along with up-to-date financial news, stock prices, and trades from polygon.io, all powered by AI insights to keep you informed." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "W8QBSmDvbL69" + }, + "source": [ + "### Instantiation\n", + "\n", + "- ai_model_id: str\n", + " The AI model ID to use for the query. The AI model ID always starts\n", + " with the prefix \"am_\".\n", + "\n", + " Defaults to \"am_01j06ytn18ejftedz6dyhz2b15\".\n", + "\n", + " Multiple AI model IDs are available, which can be found at:\n", + " https://marketplace.dappier.com/marketplace" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "id": "tw1edqrLbiJ4" + }, + "outputs": [], + "source": [ + "from langchain_dappier import DappierRealTimeSearchTool\n", + "\n", + "tool = DappierRealTimeSearchTool(\n", + " # ai_model_id=\"...\", # overwrite default ai_model_id\n", + " # name=\"...\", # overwrite default tool name\n", + " # description=\"...\", # overwrite default tool description\n", + " # args_schema=..., # overwrite default args_schema: BaseModel\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "nTatJ6F8b0sV" + }, + "source": [ + "### Invocation\n", + "\n", + "#### [Invoke directly with args](/docs/concepts/tools)\n", + "\n", + "The `DappierRealTimeSearchTool` takes a single \"query\" argument, which should be a natural language query:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 53 + }, + "id": "ASCcnvUCdIvz", + "outputId": "91538fac-f515-4a8e-adb6-0a7aa42f704c" + }, + "outputs": [ + { + "data": { + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "string" + }, + "text/plain": [ + "\"At the last Wimbledon in 2024, Carlos Alcaraz won the title by defeating Novak Djokovic. This victory marked Alcaraz's fourth Grand Slam title at just 21 years old! ๐ŸŽ‰๐Ÿ†๐ŸŽพ\"" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tool.invoke({\"query\": \"What happened at the last wimbledon\"})" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "Jcbi44TRdL3D" + }, + "source": [ + "### [Invoke with ToolCall](/docs/concepts/tools)\n", + "\n", + "We can also invoke the tool with a model-generated ToolCall, in which case a ToolMessage will be returned:" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "FCTpjujpdQst", + "outputId": "e184c25b-0089-4896-fbb4-1fbe09ea2f6b" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Euro 2024 is being hosted by Germany! ๐Ÿ‡ฉ๐Ÿ‡ช The tournament runs from June 14 to July 14, 2024, featuring 24 teams competing across various cities like Berlin and Munich. It's going to be an exciting summer of football! โšฝ๏ธ๐Ÿ†\n" + ] + } + ], + "source": [ + "# This is usually generated by a model, but we'll create a tool call directly for demo purposes.\n", + "model_generated_tool_call = {\n", + " \"args\": {\"query\": \"euro 2024 host nation\"},\n", + " \"id\": \"1\",\n", + " \"name\": \"dappier\",\n", + " \"type\": \"tool_call\",\n", + "}\n", + "tool_msg = tool.invoke(model_generated_tool_call)\n", + "\n", + "# The content is a JSON string of results\n", + "print(tool_msg.content[:400])" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "PTBiq_2JdfjK" + }, + "source": [ + "### Chaining\n", + "\n", + "We can use our tool in a chain by first binding it to a [tool-calling model](/docs/how_to/tool_calling/) and then calling it:\n", + "\n", + "import ChatModelTabs from \"@theme/ChatModelTabs\";\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "id": "_XImV9NtdoJq" + }, + "outputs": [], + "source": [ + "# | output: false\n", + "# | echo: false\n", + "\n", + "# !pip install -qU langchain langchain-openai\n", + "from langchain.chat_models import init_chat_model\n", + "\n", + "llm = init_chat_model(model=\"gpt-4o\", model_provider=\"openai\", temperature=0)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "i5P5DgJOdwPI", + "outputId": "70e14f71-637e-422d-80ac-62e93b3686a9" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "AIMessage(content=\"Barbora Krejฤรญkovรก won the women's singles title at Wimbledon 2024, defeating Jasmine Paolini in the final with a score of 6โ€“2, 2โ€“6, 6โ€“4. This victory marked her first Wimbledon singles title and her second major singles title overall! ๐ŸŽ‰๐Ÿ†๐ŸŽพ\", additional_kwargs={'refusal': None}, response_metadata={'token_usage': {'completion_tokens': 69, 'prompt_tokens': 222, 'total_tokens': 291, 'completion_tokens_details': {'accepted_prediction_tokens': 0, 'audio_tokens': 0, 'reasoning_tokens': 0, 'rejected_prediction_tokens': 0}, 'prompt_tokens_details': {'audio_tokens': 0, 'cached_tokens': 0}}, 'model_name': 'gpt-4o-2024-08-06', 'system_fingerprint': 'fp_4691090a87', 'finish_reason': 'stop', 'logprobs': None}, id='run-87a385dd-103b-4344-a3be-2d6fd1dcfdf5-0', usage_metadata={'input_tokens': 222, 'output_tokens': 69, 'total_tokens': 291, 'input_token_details': {'audio': 0, 'cache_read': 0}, 'output_token_details': {'audio': 0, 'reasoning': 0}})" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import datetime\n", + "\n", + "from langchain_core.prompts import ChatPromptTemplate\n", + "from langchain_core.runnables import RunnableConfig, chain\n", + "\n", + "today = datetime.datetime.today().strftime(\"%D\")\n", + "prompt = ChatPromptTemplate(\n", + " [\n", + " (\"system\", f\"You are a helpful assistant. The date today is {today}.\"),\n", + " (\"human\", \"{user_input}\"),\n", + " (\"placeholder\", \"{messages}\"),\n", + " ]\n", + ")\n", + "\n", + "# specifying tool_choice will force the model to call this tool.\n", + "llm_with_tools = llm.bind_tools([tool])\n", + "\n", + "llm_chain = prompt | llm_with_tools\n", + "\n", + "\n", + "@chain\n", + "def tool_chain(user_input: str, config: RunnableConfig):\n", + " input_ = {\"user_input\": user_input}\n", + " ai_msg = llm_chain.invoke(input_, config=config)\n", + " tool_msgs = tool.batch(ai_msg.tool_calls, config=config)\n", + " return llm_chain.invoke({**input_, \"messages\": [ai_msg, *tool_msgs]}, config=config)\n", + "\n", + "\n", + "tool_chain.invoke(\"who won the last womens singles wimbledon\")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "TycbUKZsfRQy" + }, + "source": [ + "## DappierAIRecommendationTool\n", + "\n", + "Supercharge your AI applications with Dappier's pre-trained RAG models and natural language APIs, delivering factual and up-to-date responses from premium content providers across verticals like News, Finance, Sports, Weather, and more." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "x1XfwHzHfvUN" + }, + "source": [ + "### Instantiation\n", + "\n", + "- data_model_id: str \n", + " The data model ID to use for recommendations. Data model IDs always start with the prefix \"dm_\". Defaults to \"dm_01j0pb465keqmatq9k83dthx34\". \n", + " Multiple data model IDs are available, which can be found at [Dappier marketplace](https://marketplace.dappier.com/marketplace). \n", + "\n", + "- similarity_top_k: int \n", + " The number of top documents to retrieve based on similarity. Defaults to \"9\". \n", + "\n", + "- ref: Optional[str]\n", + " The site domain where AI recommendations should be displayed. Defaults to \"None\". \n", + "\n", + "- num_articles_ref: int\n", + " The minimum number of articles to return from the specified reference domain (\"ref\"). The remaining articles will come from other sites in the RAG model. Defaults to \"0\". \n", + "\n", + "- search_algorithm: Literal[\"most_recent\", \"semantic\", \"most_recent_semantic\", \"trending\"]\n", + " The search algorithm to use for retrieving articles. Defaults to \"most_recent\". " + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "id": "-t9rS-TBhNss" + }, + "outputs": [], + "source": [ + "from langchain_dappier import DappierAIRecommendationTool\n", + "\n", + "tool = DappierAIRecommendationTool(\n", + " data_model_id=\"dm_01j0pb465keqmatq9k83dthx34\",\n", + " similarity_top_k=3,\n", + " ref=\"sportsnaut.com\",\n", + " num_articles_ref=2,\n", + " search_algorithm=\"most_recent\",\n", + " # name=\"...\", # overwrite default tool name\n", + " # description=\"...\", # overwrite default tool description\n", + " # args_schema=..., # overwrite default args_schema: BaseModel\n", + ")" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ad3anWusg9BI" + }, + "source": [ + "### Invocation\n", + "\n", + "#### [Invoke directly with args](/docs/concepts/tools)\n", + "\n", + "The `DappierAIRecommendationTool` takes a single \"query\" argument, which should be a natural language query:" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "UQ08UkTMhI17", + "outputId": "5fd145b8-a547-4caa-ba06-ab0bfac3b104" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'author': 'Matt Weaver',\n", + " 'image_url': 'https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/Screenshot_20250117_021643_Gallery_.jpg?width=428&height=321',\n", + " 'pubdate': 'Fri, 17 Jan 2025 08:04:03 +0000',\n", + " 'source_url': 'https://sportsnaut.com/chili-bowl-thursday-bell-column/',\n", + " 'summary': \"The article highlights the thrilling unpredictability of the Chili Bowl Midget Nationals, focusing on the dramatic shifts in fortune for drivers like Christopher Bell, Tanner Thorson, and Karter Sarff during Thursday's events. Key moments included Sarff's unfortunate pull-off and a last-lap crash that allowed Ryan Bernal to capitalize and improve his standing, showcasing the chaotic nature of the race and the importance of strategy and luck.\\n\\nAs the competition intensifies leading up to Championship Saturday, Bell faces the challenge of racing from a Last Chance Race, reflecting on the excitement and difficulties of the sport. The article emphasizes the emotional highs and lows experienced by racers, with insights from Bell and Bernal on the unpredictable nature of racing. Overall, it captures the camaraderie and passion that define the Chili Bowl, illustrating how each moment contributes to the event's narrative.\",\n", + " 'title': 'Thursday proves why every lap of Chili Bowl is so consequential'},\n", + " {'author': 'Matt Higgins',\n", + " 'image_url': 'https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/Pete-Alonso-24524027_.jpg?width=428&height=321',\n", + " 'pubdate': 'Fri, 17 Jan 2025 02:48:42 +0000',\n", + " 'source_url': 'https://sportsnaut.com/new-york-mets-news-pete-alonso-rejected-last-ditch-contract-offer/',\n", + " 'summary': \"The New York Mets are likely parting ways with star first baseman Pete Alonso after failing to finalize a contract agreement. Alonso rejected a last-minute three-year offer worth between $68 and $70 million, leading the Mets to redirect funds towards acquiring a top reliever. With Alonso's free-agent options dwindling, speculation arises about his potential signing with another team for the 2025 season, while the Mets plan to shift Mark Vientos to first base.\\n\\nIn a strategic move, the Mets are also considering a trade for Toronto Blue Jays' star first baseman Vladimir Guerrero Jr. This potential acquisition aims to enhance the Mets' competitiveness as they reshape their roster. Guerrero's impressive offensive stats make him a valuable target, and discussions are in the early stages. Fans and analysts are keenly watching the situation, as a trade involving such a prominent player could significantly impact both teams.\",\n", + " 'title': 'MLB insiders reveal New York Metsโ€™ last-ditch contract offer that Pete Alonso rejected'},\n", + " {'author': 'Jim Cerny',\n", + " 'image_url': 'https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/NHL-New-York-Rangers-at-Utah-25204492_.jpg?width=428&height=321',\n", + " 'pubdate': 'Fri, 17 Jan 2025 05:10:39 +0000',\n", + " 'source_url': 'https://www.foreverblueshirts.com/new-york-rangers-news/stirring-5-3-comeback-win-utah-close-road-trip/',\n", + " 'summary': \"The New York Rangers achieved a thrilling 5-3 comeback victory against the Utah Hockey Club, showcasing their resilience after a prior overtime loss. The Rangers scored three unanswered goals in the third period, with key contributions from Reilly Smith, Chris Kreider, and Artemi Panarin, who sealed the win with an empty-net goal. This victory marked their first win of the season when trailing after two periods and capped off a successful road trip, improving their record to 21-20-3.\\n\\nIgor Shesterkin's strong performance in goal, along with Arthur Kaliyev's first goal for the team, helped the Rangers overcome an early deficit. The game featured multiple lead changes, highlighting the competitive nature of both teams. As the Rangers prepare for their next game against the Columbus Blue Jackets, they aim to close the gap in the playoff race, with the Blue Jackets currently holding a five-point lead in the Eastern Conference standings.\",\n", + " 'title': 'Rangers score 3 times in 3rd period for stirring 5-3 comeback win against Utah to close road trip'}]" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tool.invoke({\"query\": \"latest sports news\"})" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "dzorKILbiOyy" + }, + "source": [ + "### [Invoke with ToolCall](/docs/concepts/tools)\n", + "\n", + "We can also invoke the tool with a model-generated ToolCall, in which case a ToolMessage will be returned:" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "wUu-awo0iP3P", + "outputId": "af1a9679-06ae-4432-a49f-769330c1e32f" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[{\"author\": \"Matt Johnson\", \"image_url\": \"https://images.dappier.com/dm_01j0pb465keqmatq9k83dthx34/MLB-New-York-Mets-at-Colorado-Rockies-23948644_.jpg?width=428&height=321\", \"pubdate\": \"Fri, 17 Jan 2025 13:31:02 +0000\", \"source_url\": \"https://sportsnaut.com/new-york-mets-rumors-vladimir-guerrero-jr-news/\", \"summary\": \"The New York Mets are refocusing their strategy after failing to extend a contra\n" + ] + } + ], + "source": [ + "# This is usually generated by a model, but we'll create a tool call directly for demo purposes.\n", + "model_generated_tool_call = {\n", + " \"args\": {\"query\": \"top 3 news articles\"},\n", + " \"id\": \"1\",\n", + " \"name\": \"dappier\",\n", + " \"type\": \"tool_call\",\n", + "}\n", + "tool_msg = tool.invoke(model_generated_tool_call)\n", + "\n", + "# The content is a JSON string of results\n", + "print(tool_msg.content[:400])" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "quFltDcDd2T8" + }, + "source": [ + "## API reference\n", + "\n", + "For detailed documentation of all DappierRealTimeSearchTool features and configurations head to the [API reference](https://python.langchain.com/api_reference/community/tools/langchain_dappier.tools.dappier.tool.DappierRealTimeSearchTool.html)" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}