mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
ed58eeb9c5
Moved the following modules to new package langchain-community in a backwards compatible fashion: ``` mv langchain/langchain/adapters community/langchain_community mv langchain/langchain/callbacks community/langchain_community/callbacks mv langchain/langchain/chat_loaders community/langchain_community mv langchain/langchain/chat_models community/langchain_community mv langchain/langchain/document_loaders community/langchain_community mv langchain/langchain/docstore community/langchain_community mv langchain/langchain/document_transformers community/langchain_community mv langchain/langchain/embeddings community/langchain_community mv langchain/langchain/graphs community/langchain_community mv langchain/langchain/llms community/langchain_community mv langchain/langchain/memory/chat_message_histories community/langchain_community mv langchain/langchain/retrievers community/langchain_community mv langchain/langchain/storage community/langchain_community mv langchain/langchain/tools community/langchain_community mv langchain/langchain/utilities community/langchain_community mv langchain/langchain/vectorstores community/langchain_community mv langchain/langchain/agents/agent_toolkits community/langchain_community mv langchain/langchain/cache.py community/langchain_community mv langchain/langchain/adapters community/langchain_community mv langchain/langchain/callbacks community/langchain_community/callbacks mv langchain/langchain/chat_loaders community/langchain_community mv langchain/langchain/chat_models community/langchain_community mv langchain/langchain/document_loaders community/langchain_community mv langchain/langchain/docstore community/langchain_community mv langchain/langchain/document_transformers community/langchain_community mv langchain/langchain/embeddings community/langchain_community mv langchain/langchain/graphs community/langchain_community mv langchain/langchain/llms community/langchain_community mv langchain/langchain/memory/chat_message_histories community/langchain_community mv langchain/langchain/retrievers community/langchain_community mv langchain/langchain/storage community/langchain_community mv langchain/langchain/tools community/langchain_community mv langchain/langchain/utilities community/langchain_community mv langchain/langchain/vectorstores community/langchain_community mv langchain/langchain/agents/agent_toolkits community/langchain_community mv langchain/langchain/cache.py community/langchain_community ``` Moved the following to core ``` mv langchain/langchain/utils/json_schema.py core/langchain_core/utils mv langchain/langchain/utils/html.py core/langchain_core/utils mv langchain/langchain/utils/strings.py core/langchain_core/utils cat langchain/langchain/utils/env.py >> core/langchain_core/utils/env.py rm langchain/langchain/utils/env.py ``` See .scripts/community_split/script_integrations.sh for all changes
62 lines
1.6 KiB
Python
62 lines
1.6 KiB
Python
import logging
|
|
import os
|
|
|
|
from langchain_core.documents import Document
|
|
|
|
from langchain_community.document_loaders import RocksetLoader
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def test_sql_query() -> None:
|
|
import rockset
|
|
|
|
assert os.environ.get("ROCKSET_API_KEY") is not None
|
|
assert os.environ.get("ROCKSET_REGION") is not None
|
|
|
|
api_key = os.environ.get("ROCKSET_API_KEY")
|
|
region = os.environ.get("ROCKSET_REGION")
|
|
if region == "use1a1":
|
|
host = rockset.Regions.use1a1
|
|
elif region == "usw2a1":
|
|
host = rockset.Regions.usw2a1
|
|
elif region == "euc1a1":
|
|
host = rockset.Regions.euc1a1
|
|
elif region == "dev":
|
|
host = rockset.DevRegions.usw2a1
|
|
else:
|
|
logger.warning(
|
|
"Using ROCKSET_REGION:%s as it is.. \
|
|
You should know what you're doing...",
|
|
region,
|
|
)
|
|
|
|
host = region
|
|
|
|
client = rockset.RocksetClient(host, api_key)
|
|
|
|
col_1 = "Rockset is a real-time analytics database"
|
|
col_2 = 2
|
|
col_3 = "e903e069-b0b5-4b80-95e2-86471b41f55f"
|
|
id = 7320132
|
|
|
|
"""Run a simple SQL query"""
|
|
loader = RocksetLoader(
|
|
client,
|
|
rockset.models.QueryRequestSql(
|
|
query=(
|
|
f"SELECT '{col_1}' AS col_1, {col_2} AS col_2, '{col_3}' AS col_3,"
|
|
f" {id} AS id"
|
|
)
|
|
),
|
|
["col_1"],
|
|
metadata_keys=["col_2", "col_3", "id"],
|
|
)
|
|
|
|
output = loader.load()
|
|
|
|
assert len(output) == 1
|
|
assert isinstance(output[0], Document)
|
|
assert output[0].page_content == col_1
|
|
assert output[0].metadata == {"col_2": col_2, "col_3": col_3, "id": id}
|