From 20e3662acf46be6aed5d2d7b74b090d2a2ced258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Spilka?= Date: Tue, 11 Jun 2024 21:20:16 +0200 Subject: [PATCH] docs: Correct code examples in the Apify's notebooks (#22768) **Description:** Correct code examples in the Apify document load notebook and Apify Dataset notebook **Issue**: None **Dependencies**: None **Twitter handle**: None --- .../document_loaders/apify_dataset.ipynb | 12 +++++++----- docs/docs/integrations/tools/apify.ipynb | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/docs/docs/integrations/document_loaders/apify_dataset.ipynb b/docs/docs/integrations/document_loaders/apify_dataset.ipynb index 240fe420f9..b1eff27229 100644 --- a/docs/docs/integrations/document_loaders/apify_dataset.ipynb +++ b/docs/docs/integrations/document_loaders/apify_dataset.ipynb @@ -13,7 +13,7 @@ "\n", "## Prerequisites\n", "\n", - "You need to have an existing dataset on the Apify platform. If you don't have one, please first check out [this notebook](/docs/integrations/tools/apify) on how to use Apify to extract content from documentation, knowledge bases, help centers, or blogs." + "You need to have an existing dataset on the Apify platform. If you don't have one, please first check out [this notebook](/docs/integrations/tools/apify) on how to use Apify to extract content from documentation, knowledge bases, help centers, or blogs. This example shows how to load a dataset produced by the [Website Content Crawler](https://apify.com/apify/website-content-crawler)." ] }, { @@ -101,8 +101,10 @@ "outputs": [], "source": [ "from langchain.indexes import VectorstoreIndexCreator\n", - "from langchain_community.document_loaders import ApifyDatasetLoader\n", - "from langchain_core.documents import Document" + "from langchain_community.utilities import ApifyWrapper\n", + "from langchain_core.documents import Document\n", + "from langchain_openai import OpenAI\n", + "from langchain_openai.embeddings import OpenAIEmbeddings" ] }, { @@ -125,7 +127,7 @@ "metadata": {}, "outputs": [], "source": [ - "index = VectorstoreIndexCreator().from_loaders([loader])" + "index = VectorstoreIndexCreator(embedding=OpenAIEmbeddings()).from_loaders([loader])" ] }, { @@ -135,7 +137,7 @@ "outputs": [], "source": [ "query = \"What is Apify?\"\n", - "result = index.query_with_sources(query)" + "result = index.query_with_sources(query, llm=OpenAI())" ] }, { diff --git a/docs/docs/integrations/tools/apify.ipynb b/docs/docs/integrations/tools/apify.ipynb index 22a22a2fc2..1c9f6d2097 100644 --- a/docs/docs/integrations/tools/apify.ipynb +++ b/docs/docs/integrations/tools/apify.ipynb @@ -42,14 +42,16 @@ "source": [ "from langchain.indexes import VectorstoreIndexCreator\n", "from langchain_community.utilities import ApifyWrapper\n", - "from langchain_core.documents import Document" + "from langchain_core.documents import Document\n", + "from langchain_openai import OpenAI\n", + "from langchain_openai.embeddings import OpenAIEmbeddings" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Initialize it using your [Apify API token](https://console.apify.com/account/integrations) and for the purpose of this example, also with your OpenAI API key:" + "Initialize it using your [Apify API token](https://docs.apify.com/platform/integrations/api#api-token) and for the purpose of this example, also with your OpenAI API key:" ] }, { @@ -103,7 +105,7 @@ "metadata": {}, "outputs": [], "source": [ - "index = VectorstoreIndexCreator().from_loaders([loader])" + "index = VectorstoreIndexCreator(embedding=OpenAIEmbeddings()).from_loaders([loader])" ] }, { @@ -120,7 +122,7 @@ "outputs": [], "source": [ "query = \"What is LangChain?\"\n", - "result = index.query_with_sources(query)" + "result = index.query_with_sources(query, llm=OpenAI())" ] }, { @@ -160,7 +162,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.1" + "version": "3.11.3" } }, "nbformat": 4,