Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
// Dependency Update Configuration
//
// See https://docs.renovatebot.com/configuration-options/
// See https://json5.org/ for JSON5 syntax
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base", // https://docs.renovatebot.com/presets-config/#configbase
":semanticCommits", // https://docs.renovatebot.com/presets-default/#semanticcommits
Expand All @@ -13,7 +8,7 @@
":prConcurrentLimitNone", // View complete backlog as PRs. https://docs.renovatebot.com/presets-default/#prconcurrentlimitnone
":prNotPending", // https://docs.renovatebot.com/presets-default/#prnotpending
":prHourlyLimitNone", // https://docs.renovatebot.com/presets-default/#prhourlylimitnone
"docker:enableMajor", // https://docs.renovatebot.com/presets-docker/#dockerenablemajor
":preserveSemverRanges",
],

// Synchronized with a 2 week sprint cycle and outside business hours.
Expand All @@ -35,25 +30,8 @@
"dependencyDashboardLabels": [
"type: process",
],

"constraints": {
"python": "3.11"
},

"pip_requirements": {
"fileMatch": ["requirements-test.txt"]
},
"packageRules": [

// Tooling & Runtime behaviors.
{
// Covers Dockerfiles, cloudbuild.yaml, and other docker-based tools.
"groupName": "Docker Runtimes",
"matchDatasources": ["docker"],
// TODO: Uncomment if your Dockerfiles are not included in samples.
// Increases build repeatability, image cache use, and supply chain security.
// "pinDigests": true,
},
{
"groupName": "GitHub Actions",
"matchManagers": ["github-actions"],
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ jobs:
if: "${{ (github.event.action != 'labeled' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) || github.event.label.name == 'tests: run' }}"

steps:
- name: Remove PR label
if: "${{ github.event.action == 'labeled' && github.event.label.name == 'tests: run' }}"
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
name: 'tests: run',
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number
});
} catch (e) {
console.log('Failed to remove label. Another job may have already removed it!');
}

- name: Checkout Repository
uses: actions/checkout@v3

Expand All @@ -43,6 +60,9 @@ jobs:
python-version: "3.11"

- name: Install requirements
run: pip install -r requirements.txt

- name: Install module (and test requirements)
run: pip install -e .[test]

- name: Run linters
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ docs.metadata
# Virtual environment
env/
venv/
.python-version

# Test logs
coverage.xml
Expand Down
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spanner for LangChain

*Description*
This package contains the [LangChain][langchain] integrations for Spanner.

> **🧪 Preview:** This feature is covered by the Pre-GA Offerings Terms of the Google Cloud Terms of Service. Please note that pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages)

Expand Down Expand Up @@ -33,12 +33,42 @@ source <your-env>/bin/activate
<your-env>/bin/pip install langchain-google-spanner
```

## Usage
## Document Loader Usage

Use a document loader to load data as LangChain `Document`s.

```python
from langchain_google_spanner import SpannerLoader


loader = SpannerLoader(
instance_id="my-instance",
database_id="my-database",
query="SELECT * from my_table_name"
)
docs = loader.lazy_load()
```

See the full [Document Loader][loader] tutorial.

## Chat Message History Usage

Use `ChatMessageHistory` to store messages and provide conversation history to LLMs.

```python
from langchain_google_spanner import SpannerVectorstore, SpannerLoader, SpannerChatMessageHistory
from langchain_google_spanner import SpannerChatMessageHistory


history = SpannerChatMessageHistory(
instance_id="my-instance",
database_id="my-database",
table_name="my_table_name",
session_id="my-session_id"
)
```

See the full [Chat Message History][history] tutorial.

## Contributing

Contributions to this library are always welcome and highly encouraged.
Expand All @@ -61,4 +91,7 @@ This is not an officially supported Google product.
[billing]: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
[api]: https://console.cloud.google.com/flows/enableapi?apiid=spanner.googleapis.com
[auth]: https://googleapis.dev/python/google-api-core/latest/auth.html
[venv]: https://virtualenv.pypa.io/en/latest/
[venv]: https://virtualenv.pypa.io/en/latest/
[loader]: ./docs/document_loader.ipynb
[history]: ./docs/chat_message_history.ipynb
[langchain]: https://github.com/langchain-ai/langchain
5 changes: 5 additions & 0 deletions integration.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

steps:
- id: Install dependencies
name: python:3.11
entrypoint: pip
args: ["install", "--user", "-r", "requirements.txt"]

- id: Install module (and test requirements)
name: python:3.11
entrypoint: pip
args: ["install", ".[test]", "--user"]
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ description = "LangChain integrations for Google Cloud Spanner"
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.8"
authors = [
{name = "Google LLC", email = "[email protected]"}
]
dependencies = [
"langchain==0.1.1",
"google-cloud-spanner==3.41.0"
"langchain-core>=0.1.25, <1.0.0",
"langchain-community>=0.0.18, <1.0.0",
"google-cloud-spanner>=3.41.0, <4.0.0"
]

[tool.setuptools.dynamic]
Expand Down
3 changes: 3 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
langchain-core==0.1.25
langchain-community==0.0.21
google-cloud-spanner==3.42.0
Empty file.