Skip to content

Commit ee7a754

Browse files
Yuan325averikitsch
andauthored
chore: cleanup repo (#39)
* chore: cleanup repo * Update renovate.json5 * Update lint.yml * Update sync-repo-settings.yaml * Update pyproject.toml * Update requirements.txt --------- Co-authored-by: Averi Kitsch <akitsch@google.com>
1 parent 467cfa3 commit ee7a754

9 files changed

Lines changed: 99 additions & 30 deletions

File tree

.github/renovate.json5

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// Dependency Update Configuration
2-
//
3-
// See https://docs.renovatebot.com/configuration-options/
4-
// See https://json5.org/ for JSON5 syntax
51
{
6-
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
72
"extends": [
83
"config:base", // https://docs.renovatebot.com/presets-config/#configbase
94
":semanticCommits", // https://docs.renovatebot.com/presets-default/#semanticcommits
@@ -13,7 +8,7 @@
138
":prConcurrentLimitNone", // View complete backlog as PRs. https://docs.renovatebot.com/presets-default/#prconcurrentlimitnone
149
":prNotPending", // https://docs.renovatebot.com/presets-default/#prnotpending
1510
":prHourlyLimitNone", // https://docs.renovatebot.com/presets-default/#prhourlylimitnone
16-
"docker:enableMajor", // https://docs.renovatebot.com/presets-docker/#dockerenablemajor
11+
":preserveSemverRanges",
1712
],
1813

1914
// Synchronized with a 2 week sprint cycle and outside business hours.
@@ -35,25 +30,8 @@
3530
"dependencyDashboardLabels": [
3631
"type: process",
3732
],
38-
39-
"constraints": {
40-
"python": "3.11"
41-
},
42-
43-
"pip_requirements": {
44-
"fileMatch": ["requirements-test.txt"]
45-
},
4633
"packageRules": [
4734

48-
// Tooling & Runtime behaviors.
49-
{
50-
// Covers Dockerfiles, cloudbuild.yaml, and other docker-based tools.
51-
"groupName": "Docker Runtimes",
52-
"matchDatasources": ["docker"],
53-
// TODO: Uncomment if your Dockerfiles are not included in samples.
54-
// Increases build repeatability, image cache use, and supply chain security.
55-
// "pinDigests": true,
56-
},
5735
{
5836
"groupName": "GitHub Actions",
5937
"matchManagers": ["github-actions"],

.github/sync-repo-settings.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ branchProtectionRules:
2626
isAdminEnforced: true
2727
requiredStatusCheckContexts:
2828
- "cla/google"
29+
- "lint"
30+
- "integration-test-pr (langchain-redis-query-testing)"
31+
- "conventionalcommits.org"
32+
- "header-check"
2933
# - Add required status checks like presubmit tests
3034
requiredApprovingReviewCount: 1
3135
requiresCodeOwnerReviews: true

.github/workflows/lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,23 @@ jobs:
3434
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' }}"
3535

3636
steps:
37+
- name: Remove PR label
38+
if: "${{ github.event.action == 'labeled' && github.event.label.name == 'tests: run' }}"
39+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
40+
with:
41+
github-token: ${{ secrets.GITHUB_TOKEN }}
42+
script: |
43+
try {
44+
await github.rest.issues.removeLabel({
45+
name: 'tests: run',
46+
owner: context.repo.owner,
47+
repo: context.repo.repo,
48+
issue_number: context.payload.pull_request.number
49+
});
50+
} catch (e) {
51+
console.log('Failed to remove label. Another job may have already removed it!');
52+
}
53+
3754
- name: Checkout Repository
3855
uses: actions/checkout@v3
3956

@@ -43,11 +60,15 @@ jobs:
4360
python-version: "3.11"
4461

4562
- name: Install requirements
63+
run: pip install -r requirements.txt
64+
65+
- name: Install module (and test requirements)
4666
run: pip install -e .[test]
4767

4868
- name: Run linters
4969
run: |
5070
black --check .
5171
isort --check .
72+
5273
- name: Run type-check
5374
run: mypy --install-types --non-interactive .

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ docs.metadata
5151
# Virtual environment
5252
env/
5353
venv/
54+
.python-version
5455

5556
# Test logs
5657
coverage.xml

README.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Memorystore for Redis for LangChain
22

3-
*Description*
3+
This package contains the [LangChain][langchain] integrations for Memorystore for Redis.
44

55
> **🧪 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)
66
@@ -33,12 +33,61 @@ source <your-env>/bin/activate
3333
<your-env>/bin/pip install langchain-google-memorystore-redis
3434
```
3535

36-
## Usage
36+
## Vector Store Usage
37+
38+
Use a vector store to store embedded data and perform vector search.
39+
40+
```python
41+
from langchain_google_memorystore_redis import RedisVectorStore
42+
from langchain_community.embeddings.fake import FakeEmbeddings
43+
44+
embeddings = FakeEmbeddings(size=128)
45+
redis_client = redis.from_url("redis://127.0.0.1:6379")
46+
47+
embeddings_service = VertexAIEmbeddings()
48+
vectorstore = RedisVectorStore(
49+
client=redis_client,
50+
index_name="my_vector_index",
51+
embeddings=embeddings
52+
)
53+
```
54+
55+
See the full [Vector Store][vectorstore] tutorial.
56+
57+
## Document Loader Usage
58+
59+
Use a document loader to load data as LangChain `Document`s.
60+
61+
```python
62+
from langchain_google_memorystore_redis import MemorystoreDocumentLoader
63+
64+
65+
loader = MemorystoreDocumentLoader(
66+
client=redis_client,
67+
key_prefix="docs:",
68+
content_fields=set(["page_content"]),
69+
)
70+
docs = loader.lazy_load()
71+
```
72+
73+
See the full [Document Loader][loader] tutorial.
74+
75+
## Chat Message History Usage
76+
77+
Use `ChatMessageHistory` to store messages and provide conversation history to LLMs.
3778

3879
```python
39-
from langchain_google_memorystore_redis import RedisVectorStore, MemorystoreDocumentLoader, MemorystoreChatMessageHistory
80+
from langchain_google_memorystore_redis import MemorystoreChatMessageHistory
81+
82+
83+
history = MemorystoreChatMessageHistory(
84+
client=redis_client,
85+
session_id="my-session_id"
86+
)
4087
```
4188

89+
See the full [Chat Message History][history] tutorial.
90+
4291
## Contributing
4392

4493
Contributions to this library are always welcome and highly encouraged.
@@ -62,3 +111,7 @@ This is not an officially supported Google product.
62111
[api]: https://console.cloud.google.com/flows/enableapi?apiid=memorystore.googleapis.com
63112
[auth]: https://googleapis.dev/python/google-api-core/latest/auth.html
64113
[venv]: https://virtualenv.pypa.io/en/latest/
114+
[vectorstore]: ./docs/vector_store.ipynb
115+
[loader]: ./docs/document_loader.ipynb
116+
[history]: ./docs/chat_message_history.ipynb
117+
[langchain]: https://github.com/langchain-ai/langchain

integration.cloudbuild.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
steps:
1616
- id: Install dependencies
17+
name: python:3.11
18+
entrypoint: pip
19+
args: ["install", "--user", "-r", "requirements.txt"]
20+
21+
- id: Install module (and test requirements)
1722
name: python:3.11
1823
entrypoint: pip
1924
args: ["install", ".[test]", "--user"]

pyproject.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ description = "LangChain integrations for Google Cloud Memorystore"
55
readme = "README.md"
66
license = {file = "LICENSE"}
77
requires-python = ">=3.8"
8+
authors = [
9+
{name = "Google LLC", email = "googleapis-packages@google.com"}
10+
]
811
dependencies = [
9-
"langchain==0.1.1",
10-
"redis>=5.0.0",
11-
"numpy>=1.21.0",
12+
"langchain-core>=0.1.1, <1.0.0",
13+
"langchain-community>=0.0.18, <1.0.0",
14+
"redis>=5.0.0, <6.0.0",
15+
"numpy>=1.21.0, <2.0.0",
1216
]
1317

1418
[tool.setuptools.dynamic]
@@ -22,7 +26,6 @@ Changelog = "https://github.com/googleapis/langchain-google-memorystore-redis-py
2226

2327
[project.optional-dependencies]
2428
test = [
25-
"black==23.12.0",
2629
"black[jupyter]==23.12.0",
2730
"isort==5.13.2",
2831
"mypy==1.7.1",

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
langchain-core==0.1.25
2+
langchain-community==0.0.21
3+
redis==5.0.1
4+
numpy==1.26.4

src/langchain_google_memorystore_redis/py.typed

Whitespace-only changes.

0 commit comments

Comments
 (0)