From 7af186fddf75d60c2e17b1af7c639e69412da2fc Mon Sep 17 00:00:00 2001 From: Harrison Chase Date: Fri, 9 Jun 2023 09:15:53 -0700 Subject: [PATCH] fixes to docs (#5919) --- docs/modules/indexes/document_loaders.rst | 2 ++ .../document_loaders/examples/snowflake.ipynb | 13 +++++++++++-- langchain/document_loaders/__init__.py | 2 ++ langchain/document_loaders/snowflake_loader.py | 4 +--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/modules/indexes/document_loaders.rst b/docs/modules/indexes/document_loaders.rst index 8848463b..190abbef 100644 --- a/docs/modules/indexes/document_loaders.rst +++ b/docs/modules/indexes/document_loaders.rst @@ -116,6 +116,7 @@ We need access tokens and sometime other parameters to get access to these datas ./document_loaders/examples/discord_loader.ipynb ./document_loaders/examples/docugami.ipynb ./document_loaders/examples/duckdb.ipynb + ./document_loaders/examples/fauna.ipynb ./document_loaders/examples/figma.ipynb ./document_loaders/examples/gitbook.ipynb ./document_loaders/examples/git.ipynb @@ -137,6 +138,7 @@ We need access tokens and sometime other parameters to get access to these datas ./document_loaders/examples/reddit.ipynb ./document_loaders/examples/roam.ipynb ./document_loaders/examples/slack.ipynb + ./document_loaders/examples/snowflake.ipynb ./document_loaders/examples/spreedly.ipynb ./document_loaders/examples/stripe.ipynb ./document_loaders/examples/tomarkdown.ipynb diff --git a/docs/modules/indexes/document_loaders/examples/snowflake.ipynb b/docs/modules/indexes/document_loaders/examples/snowflake.ipynb index f84c2e54..7e6cfa04 100644 --- a/docs/modules/indexes/document_loaders/examples/snowflake.ipynb +++ b/docs/modules/indexes/document_loaders/examples/snowflake.ipynb @@ -1,5 +1,14 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Snowflake\n", + "\n", + "This notebooks goes over how to load documents from Snowflake" + ] + }, { "cell_type": "code", "execution_count": null, @@ -16,7 +25,7 @@ "outputs": [], "source": [ "import settings as s\n", - "from langchain.document_loaders.snowflake_loader import SnowflakeLoader" + "from langchain.document_loaders import SnowflakeLoader" ] }, { @@ -81,7 +90,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.9.1" } }, "nbformat": 4, diff --git a/langchain/document_loaders/__init__.py b/langchain/document_loaders/__init__.py index 84a82506..393062b7 100644 --- a/langchain/document_loaders/__init__.py +++ b/langchain/document_loaders/__init__.py @@ -90,6 +90,7 @@ from langchain.document_loaders.s3_directory import S3DirectoryLoader from langchain.document_loaders.s3_file import S3FileLoader from langchain.document_loaders.sitemap import SitemapLoader from langchain.document_loaders.slack_directory import SlackDirectoryLoader +from langchain.document_loaders.snowflake_loader import SnowflakeLoader from langchain.document_loaders.spreedly import SpreedlyLoader from langchain.document_loaders.srt import SRTLoader from langchain.document_loaders.stripe import StripeLoader @@ -244,4 +245,5 @@ __all__ = [ "WhatsAppChatLoader", "WikipediaLoader", "YoutubeLoader", + "SnowflakeLoader", ] diff --git a/langchain/document_loaders/snowflake_loader.py b/langchain/document_loaders/snowflake_loader.py index 30978fed..115f6e7b 100644 --- a/langchain/document_loaders/snowflake_loader.py +++ b/langchain/document_loaders/snowflake_loader.py @@ -2,8 +2,6 @@ from __future__ import annotations from typing import Any, Dict, Iterator, List, Optional, Tuple -from snowflake.connector import DictCursor - from langchain.docstore.document import Document from langchain.document_loaders.base import BaseLoader @@ -61,6 +59,7 @@ class SnowflakeLoader(BaseLoader): def _execute_query(self) -> List[Dict[str, Any]]: try: import snowflake.connector + from snowflake.connector import DictCursor except ImportError as ex: raise ValueError( "Could not import snowflake-connector-python package. " @@ -77,7 +76,6 @@ class SnowflakeLoader(BaseLoader): schema=self.schema, parameters=self.parameters, ) - query_result = [] try: cur = conn.cursor(DictCursor) cur.execute("USE DATABASE " + self.database)