Skip to content

Commit

Permalink
feat: add API reference docs (#104)
Browse files Browse the repository at this point in the history
* feat: add API reference docs

* fix typo

* udpate tools
  • Loading branch information
averikitsch committed Apr 2, 2024
1 parent 64796dc commit 43a9815
Show file tree
Hide file tree
Showing 20 changed files with 841 additions and 132 deletions.
1 change: 0 additions & 1 deletion .github/header-checker-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ sourceFileExtensions:
- "proto"
- "Dockerfile"
- "py"
- "html"
- "text"
ignoreFiles:
- ".github/release-please.yml"
Expand Down
24 changes: 23 additions & 1 deletion DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,27 @@ Use `gcloud builds triggers import --source=trigger.yaml` create triggers via th

To run Cloud Build tests on GitHub from external contributors, ie RenovateBot, comment: `/gcbrun`.

## Documentation

[triggers]: https://console.cloud.google.com/cloud-build/triggers?e=13802955&project=langchain-cloud-sql-testing
### LangChain Integration Docs

Google hosts documentation on LangChain's site via the [Google Provider][provider] page and individual integration pages:
[Vector Stores][vs], [Document Loaders][loaders], and [Memory][memory].

Currently, manual PRs are made to the [Langchain GitHub repo](https://github.com/langchain-ai/langchain).

### API Reference

API docs are templated in the `docs/` directory. See `.kokoro/` for the release pipeline.

To test locally, run: `nox -s`


[provider]: https://python.langchain.com/docs/integrations/platforms/google
[vs]: https://python.langchain.com/docs/integrations/vectorstores
[memory]: https://python.langchain.com/docs/integrations/memory
[loaders]: https://python.langchain.com/docs/integrations/document_loaders
[triggers]: https://console.cloud.google.com/cloud-build/triggers?e=13802955&project=langchain-cloud-sql-testing
[vectorstore]: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/docs/vector_store.ipynb
[loader]: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/docs/document_loader.ipynb
[history]: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/docs/chat_message_history.ipynb
122 changes: 0 additions & 122 deletions README.md

This file was deleted.

172 changes: 172 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
Cloud SQL for PostgreSQL for LangChain
===================================================================

|preview| |pypi| |versions|

- `Client Library Documentation`_
- `How-to Guides`_
- `Product Documentation`_

.. |preview| image:: https://img.shields.io/badge/support-preview-orange.svg
:target: https://github.com/googleapis/google-cloud-python/blob/main/README.rst#stability-levels
.. |pypi| image:: https://img.shields.io/pypi/v/langchain-google-cloud-sql-pg.svg
:target: https://pypi.org/project/langchain-google-cloud-sql-pg/
.. |versions| image:: https://img.shields.io/pypi/pyversions/langchain-google-cloud-sql-pg.svg
:target: https://pypi.org/project/langchain-google-cloud-sql-pg/
.. _Client Library Documentation: https://github.com/googleapis/langchain-google-cloud-sql-pg-python
.. _How-to Guides: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/samples
.. _Product Documentation: https://cloud.google.com/sql/docs

Quick Start
-----------

In order to use this library, you first need to go through the following steps:

1. `Select or create a Cloud Platform project.`_
2. `Enable billing for your project.`_
3. `Enable the Cloud SQL Admin API.`_
4. `Setup Authentication.`_

.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
.. _Enable the Cloud SQL Admin API.:
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html

Installation
~~~~~~~~~~~~

Install this library in a virtual environment using `venv`_. `venv`_ is a tool that
creates isolated Python environments. These isolated environments can have separate
versions of Python packages, which allows you to isolate one project's dependencies
from the dependencies of other projects.

With `venv`_, it's possible to install this library without needing system
install permissions, and without clashing with the installed system
dependencies.

.. _`venv`: https://docs.python.org/3/library/venv.html


Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^

Python >= 3.8

Mac/Linux
^^^^^^^^^

.. code-block:: console
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-bigquery
Windows
^^^^^^^

.. code-block:: console
pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-bigquery
Example Usage
-------------

Code samples and snippets live in the `samples/`_ folder.

.. _samples/: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/samples


Vector Store Usage
~~~~~~~~~~~~~~~~~~~

Use a Vector Store to store embedded data and perform vector search.

.. code:: python
from langchain_google_cloud_sql_pg import PostgresVectorstore, PostgresEngine
from langchain.embeddings import VertexAIEmbeddings
engine = PostgresEngine.from_instance("project-id", "region", "my-instance", "my-database")
engine.init_vectorstore_table(
table_name="my-table",
vector_size=768, # Vector size for `VertexAIEmbeddings()`
)
embeddings_service = VertexAIEmbeddings()
vectorstore = PostgresVectorStore.create_sync(
engine,
table_name="my-table",
embeddings=embedding_service
)
See the full `Vector Store`_ tutorial.

.. _`Vector Store`: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/samples/vector_store.ipynb

Document Loader Usage
~~~~~~~~~~~~~~~~~~~~~

Use a document loader to load data as Documents.

.. code:: python
from langchain_google_cloud_sql_pg import PostgresEngine, PostgresLoader
engine = PostgresEngine.from_instance("project-id", "region", "my-instance", "my-database")
loader = PostgresSQLLoader.create_sync(
engine,
table_name="my-table-name"
)
docs = loader.lazy_load()
See the full `Document Loader`_ tutorial.

.. _`Document Loader`: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/samples/document_loader.ipynb

Chat Message History Usage
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Use Chat Message History to store messages and provide conversation history to LLMs.

.. code:: python
from langchain_google_cloud_sql_pg import PostgresChatMessageHistory, PostgresEngine
engine = PostgresEngine.from_instance("project-id", "region", "my-instance", "my-database")
engine.init_chat_history_table(table_name="my-message-store")
history = PostgresChatMessageHistory.create_sync(
engine,
table_name="my-message-store",
session_id="my-session_id"
)
See the full `Chat Message History`_ tutorial.

.. _`Chat Message History`: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/samples/chat_message_history.ipynb

Contributing
~~~~~~~~~~~~

Contributions to this library are always welcome and highly encouraged.

See `CONTRIBUTING`_ for more information how to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in
this project you agree to abide by its terms. See `Code of Conduct`_ for more
information.

.. _`CONTRIBUTING`: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/CONTRIBUTING.md
.. _`Code of Conduct`: https://github.com/googleapis/langchain-google-cloud-sql-pg-python/tree/main/CODE_OF_CONDUCT.md

Disclaimer
~~~~~~~~~~~

This is not an officially supported Google product.
1 change: 1 addition & 0 deletions docs/README.rst
20 changes: 20 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
div#python2-eol {
border-color: red;
border-width: medium;
}

/* Ensure minimum width for 'Parameters' / 'Returns' column */
dl.field-list > dt {
min-width: 100px
}

/* Insert space between methods for readability */
dl.method {
padding-top: 10px;
padding-bottom: 10px
}

/* Insert empty space between classes */
dl.class {
padding-bottom: 50px
}
Loading

0 comments on commit 43a9815

Please sign in to comment.