mirror of
https://github.com/hwchase17/langchain
synced 2024-10-31 15:20:26 +00:00
117 lines
2.3 KiB
Plaintext
117 lines
2.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "a634365e",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Tencent COS Directory\n",
|
|
"\n",
|
|
"This covers how to load document objects from a `Tencent COS Directory`."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "85e97267",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#! pip install cos-python-sdk-v5"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "2f0cd6a5",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from langchain.document_loaders import TencentCOSDirectoryLoader\n",
|
|
"from qcloud_cos import CosConfig"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "321cc7f1",
|
|
"metadata": {
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"conf = CosConfig(\n",
|
|
" Region=\"your cos region\",\n",
|
|
" SecretId=\"your cos secret_id\",\n",
|
|
" SecretKey=\"your cos secret_key\",\n",
|
|
")\n",
|
|
"loader = TencentCOSDirectoryLoader(conf=conf, bucket=\"you_cos_bucket\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4c50d2c7",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"loader.load()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "0690c40a",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Specifying a prefix\n",
|
|
"You can also specify a prefix for more finegrained control over what files to load."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "72d44781",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"loader = TencentCOSDirectoryLoader(conf=conf, bucket=\"you_cos_bucket\", prefix=\"fake\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "2d3c32db",
|
|
"metadata": {
|
|
"scrolled": true
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"loader.load()"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.9.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|