mirror of
https://github.com/hwchase17/langchain
synced 2024-10-29 17:07:25 +00:00
bf0887c486
Fixes linting issue from #2835 Adds a loader for Slack Exports which can be a very valuable source of knowledge to use for internal QA bots and other use cases. ```py # Export data from your Slack Workspace first. from langchain.document_loaders import SLackDirectoryLoader SLACK_WORKSPACE_URL = "https://awesome.slack.com" loader = ("Slack_Exports", SLACK_WORKSPACE_URL) docs = loader.load() ```
24 lines
812 B
Python
24 lines
812 B
Python
"""Tests for the Slack directory loader"""
|
|
from pathlib import Path
|
|
|
|
from langchain.document_loaders import SlackDirectoryLoader
|
|
|
|
|
|
def test_slack_directory_loader() -> None:
|
|
"""Test Slack directory loader."""
|
|
file_path = Path(__file__).parent.parent / "examples/slack_export.zip"
|
|
loader = SlackDirectoryLoader(str(file_path))
|
|
docs = loader.load()
|
|
|
|
assert len(docs) == 5
|
|
|
|
|
|
def test_slack_directory_loader_urls() -> None:
|
|
"""Test workspace URLS are passed through in the SlackDirectoryloader."""
|
|
file_path = Path(__file__).parent.parent / "examples/slack_export.zip"
|
|
workspace_url = "example_workspace.com"
|
|
loader = SlackDirectoryLoader(str(file_path), workspace_url)
|
|
docs = loader.load()
|
|
for doc in docs:
|
|
assert doc.metadata["source"].startswith(workspace_url)
|