mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
fa5d49f2c1
ran ```bash g grep -l "langchain.vectorstores" | xargs -L 1 sed -i '' "s/langchain\.vectorstores/langchain_community.vectorstores/g" g grep -l "langchain.document_loaders" | xargs -L 1 sed -i '' "s/langchain\.document_loaders/langchain_community.document_loaders/g" g grep -l "langchain.chat_loaders" | xargs -L 1 sed -i '' "s/langchain\.chat_loaders/langchain_community.chat_loaders/g" g grep -l "langchain.document_transformers" | xargs -L 1 sed -i '' "s/langchain\.document_transformers/langchain_community.document_transformers/g" g grep -l "langchain\.graphs" | xargs -L 1 sed -i '' "s/langchain\.graphs/langchain_community.graphs/g" g grep -l "langchain\.memory\.chat_message_histories" | xargs -L 1 sed -i '' "s/langchain\.memory\.chat_message_histories/langchain_community.chat_message_histories/g" gco master libs/langchain/tests/unit_tests/*/test_imports.py gco master libs/langchain/tests/unit_tests/**/test_public_api.py ```
107 lines
2.9 KiB
Plaintext
107 lines
2.9 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"attachments": {},
|
|
"cell_type": "markdown",
|
|
"id": "33205b12",
|
|
"metadata": {},
|
|
"source": [
|
|
"# LarkSuite (FeiShu)\n",
|
|
"\n",
|
|
">[LarkSuite](https://www.larksuite.com/) is an enterprise collaboration platform developed by ByteDance.\n",
|
|
"\n",
|
|
"This notebook covers how to load data from the `LarkSuite` REST API into a format that can be ingested into LangChain, along with example usage for text summarization.\n",
|
|
"\n",
|
|
"The LarkSuite API requires an access token (tenant_access_token or user_access_token), checkout [LarkSuite open platform document](https://open.larksuite.com/document) for API details."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "90b69c94",
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2023-06-19T10:05:03.645161Z",
|
|
"start_time": "2023-06-19T10:04:49.541968Z"
|
|
},
|
|
"tags": []
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"from getpass import getpass\n",
|
|
"\n",
|
|
"from langchain_community.document_loaders.larksuite import LarkSuiteDocLoader\n",
|
|
"\n",
|
|
"DOMAIN = input(\"larksuite domain\")\n",
|
|
"ACCESS_TOKEN = getpass(\"larksuite tenant_access_token or user_access_token\")\n",
|
|
"DOCUMENT_ID = input(\"larksuite document id\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "13deb0f5",
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2023-06-19T10:05:36.016495Z",
|
|
"start_time": "2023-06-19T10:05:35.360884Z"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"[Document(page_content='Test Doc\\nThis is a Test Doc\\n\\n1\\n2\\n3\\n\\n', metadata={'document_id': 'V76kdbd2HoBbYJxdiNNccajunPf', 'revision_id': 11, 'title': 'Test Doc'})]\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"from pprint import pprint\n",
|
|
"\n",
|
|
"larksuite_loader = LarkSuiteDocLoader(DOMAIN, ACCESS_TOKEN, DOCUMENT_ID)\n",
|
|
"docs = larksuite_loader.load()\n",
|
|
"\n",
|
|
"pprint(docs)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "9ccc1e2f",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# see https://python.langchain.com/docs/use_cases/summarization for more details\n",
|
|
"from langchain.chains.summarize import load_summarize_chain\n",
|
|
"from langchain_community.llms.fake import FakeListLLM\n",
|
|
"\n",
|
|
"llm = FakeListLLM()\n",
|
|
"chain = load_summarize_chain(llm, chain_type=\"map_reduce\")\n",
|
|
"chain.run(docs)"
|
|
]
|
|
}
|
|
],
|
|
"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.10.12"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|