Skip to content

Commit

Permalink
docs: add github links (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
averikitsch committed Mar 7, 2024
1 parent 6ef4542 commit f012074
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
11 changes: 8 additions & 3 deletions docs/chat_message_history.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Bigtable\n",
"# Google Bigtable\n",
"\n",
"> [Bigtable](https://cloud.google.com/bigtable) is a key-value and wide-column store, ideal for fast access to structured, semi-structured, or unstructured data. Extend your database application to build AI-powered experiences leveraging Bigtable's Langchain integrations.\n",
"\n",
"This notebook goes over how to use [Bigtable](https://cloud.google.com/bigtable) to store chat message history with the `BigtableChatMessageHistory` class.\n",
"\n",
"Learn more about the package on [GitHub](https://github.com/googleapis/langchain-google-bigtable-python/).\n",
"\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/googleapis/langchain-google-bigtable-python/blob/main/docs/chat_message_history.ipynb)\n"
]
},
Expand All @@ -20,7 +22,9 @@
"## Before You Begin\n",
"\n",
"To run this notebook, you will need to do the following:\n",
"\n",
"* [Create a Google Cloud Project](https://developers.google.com/workspace/guides/create-project)\n",
"* [Enable the Bigtable API](https://console.cloud.google.com/flows/enableapi?apiid=bigtable.googleapis.com)\n",
"* [Create a Bigtable instance](https://cloud.google.com/bigtable/docs/creating-instance)\n",
"* [Create a Bigtable table](https://cloud.google.com/bigtable/docs/managing-tables)\n",
"* [Create Bigtable access credentials](https://developers.google.com/workspace/guides/create-credentials)"
Expand Down Expand Up @@ -182,7 +186,8 @@
"execution_count": null,
"metadata": {},
"outputs": [],
"source": ["from langchain_google_bigtable import BigtableChatMessageHistory\n",
"source": [
"from langchain_google_bigtable import BigtableChatMessageHistory\n",
"\n",
"message_history = BigtableChatMessageHistory(\n",
" instance_id=INSTANCE_ID,\n",
Expand Down Expand Up @@ -278,7 +283,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down
42 changes: 25 additions & 17 deletions docs/document_loader.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Bigtable\n",
"# Google Bigtable\n",
"\n",
"> [Bigtable](https://cloud.google.com/bigtable) is a key-value and wide-column store, ideal for fast access to structured, semi-structured, or unstructured data. Extend your database application to build AI-powered experiences leveraging Bigtable's Langchain integrations.\n",
"\n",
"This notebook goes over how to use [Bigtable](https://cloud.google.com/bigtable) to [save, load and delete langchain documents](https://python.langchain.com/docs/modules/data_connection/document_loaders/) with `BigtableLoader` and `BigtableSaver`.\n",
"\n",
"Learn more about the package on [GitHub](https://github.com/googleapis/langchain-google-bigtable-python/).\n",
"\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/googleapis/langchain-google-bigtable-python/blob/main/docs/document_loader.ipynb)"
]
},
Expand All @@ -20,7 +22,9 @@
"## Before You Begin\n",
"\n",
"To run this notebook, you will need to do the following:\n",
"\n",
"* [Create a Google Cloud Project](https://developers.google.com/workspace/guides/create-project)\n",
"* [Enable the Bigtable API](https://console.cloud.google.com/flows/enableapi?apiid=bigtable.googleapis.com)\n",
"* [Create a Bigtable instance](https://cloud.google.com/bigtable/docs/creating-instance)\n",
"* [Create a Bigtable table](https://cloud.google.com/bigtable/docs/managing-tables)\n",
"* [Create Bigtable access credentials](https://developers.google.com/workspace/guides/create-credentials)\n",
Expand Down Expand Up @@ -142,6 +146,7 @@
"### Using the saver\n",
"\n",
"Save langchain documents with `BigtableSaver.add_documents(<documents>)`. To initialize `BigtableSaver` class you need to provide 2 things:\n",
"\n",
"1. `instance_id` - An instance of Bigtable.\n",
"1. `table_id` - The name of the table within the Bigtable to store langchain documents."
]
Expand All @@ -152,8 +157,8 @@
"metadata": {},
"outputs": [],
"source": [
"from langchain_google_bigtable import BigtableSaver\n",
"from langchain_core.documents import Document\n",
"from langchain_google_bigtable import BigtableSaver\n",
"\n",
"test_docs = [\n",
" Document(\n",
Expand Down Expand Up @@ -193,6 +198,7 @@
"#### Load documents from table\n",
"\n",
"Load langchain documents with `BigtableLoader.load()` or `BigtableLoader.lazy_load()`. `lazy_load` returns a generator that only queries database during the iteration. To initialize `BigtableLoader` class you need to provide:\n",
"\n",
"1. `instance_id` - An instance of Bigtable.\n",
"1. `table_id` - The name of the table within the Bigtable to store langchain documents."
]
Expand Down Expand Up @@ -253,6 +259,7 @@
"source": [
"### Limiting the returned rows\n",
"There are two ways to limit the returned rows:\n",
"\n",
"1. Using a [filter](https://cloud.google.com/python/docs/reference/bigtable/latest/row-filters)\n",
"2. Using a [row_set](https://cloud.google.com/python/docs/reference/bigtable/latest/row-set#google.cloud.bigtable.row_set.RowSet)"
]
Expand All @@ -266,7 +273,7 @@
"import google.cloud.bigtable.row_filters as row_filters\n",
"\n",
"filter_loader = BigtableLoader(\n",
" instance_id, table_id, filter=row_filters.ColumnQualifierRegexFilter(b\"os_build\")\n",
" INSTANCE_ID, TABLE_ID, filter=row_filters.ColumnQualifierRegexFilter(b\"os_build\")\n",
")\n",
"\n",
"\n",
Expand All @@ -278,8 +285,8 @@
")\n",
"\n",
"row_set_loader = BigtableLoader(\n",
" instance_id,\n",
" table_id,\n",
" INSTANCE_ID,\n",
" TABLE_ID,\n",
" row_set=row_set,\n",
")"
]
Expand All @@ -301,8 +308,8 @@
"from google.cloud import bigtable\n",
"\n",
"custom_client_loader = BigtableLoader(\n",
" instance_id,\n",
" table_id,\n",
" INSTANCE_ID,\n",
" TABLE_ID,\n",
" client=bigtable.Client(...),\n",
")"
]
Expand All @@ -324,8 +331,8 @@
"from langchain_google_bigtable import Encoding\n",
"\n",
"custom_content_loader = BigtableLoader(\n",
" instance_id,\n",
" table_id,\n",
" INSTANCE_ID,\n",
" TABLE_ID,\n",
" content_encoding=Encoding.ASCII,\n",
" content_column_family=\"my_content_family\",\n",
" content_column_name=\"my_content_column_name\",\n",
Expand All @@ -346,12 +353,13 @@
"metadata": {},
"outputs": [],
"source": [
"from langchain_google_bigtable import MetadataMapping\n",
"import json\n",
"\n",
"from langchain_google_bigtable import MetadataMapping\n",
"\n",
"metadata_mapping_loader = BigtableLoader(\n",
" instance_id,\n",
" table_id,\n",
" INSTANCE_ID,\n",
" TABLE_ID,\n",
" metadata_mappings=[\n",
" MetadataMapping(\n",
" column_family=\"my_int_family\",\n",
Expand Down Expand Up @@ -387,8 +395,8 @@
"outputs": [],
"source": [
"metadata_as_json_loader = BigtableLoader(\n",
" instance_id,\n",
" table_id,\n",
" INSTANCE_ID,\n",
" TABLE_ID,\n",
" metadata_as_json_encoding=Encoding.ASCII,\n",
" metadata_as_json_family=\"my_metadata_as_json_family\",\n",
" metadata_as_json_name=\"my_metadata_as_json_column_name\",\n",
Expand All @@ -411,8 +419,8 @@
"outputs": [],
"source": [
"saver = BigtableSaver(\n",
" instance_id,\n",
" table_id,\n",
" INSTANCE_ID,\n",
" TABLE_ID,\n",
" client=bigtable.Client(...),\n",
" content_encoding=Encoding.ASCII,\n",
" content_column_family=\"my_content_family\",\n",
Expand Down Expand Up @@ -456,7 +464,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.11.5"
}
},
"nbformat": 4,
Expand Down

0 comments on commit f012074

Please sign in to comment.