langchain-postgres 0.0.14__tar.gz → 0.0.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- langchain_postgres-0.0.15/.github/actions/uv_setup/action.yml +18 -0
- langchain_postgres-0.0.15/.github/workflows/_lint.yml +43 -0
- langchain_postgres-0.0.15/.github/workflows/_release.yml +157 -0
- langchain_postgres-0.0.15/.github/workflows/_test.yml +96 -0
- langchain_postgres-0.0.15/.github/workflows/ci.yml +50 -0
- langchain_postgres-0.0.15/.gitignore +168 -0
- langchain_postgres-0.0.15/CONTRIBUTING.md +47 -0
- langchain_postgres-0.0.15/DEVELOPMENT.md +32 -0
- langchain_postgres-0.0.15/Makefile +58 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/PKG-INFO +22 -29
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/README.md +10 -8
- langchain_postgres-0.0.15/docker-compose.yml +27 -0
- langchain_postgres-0.0.15/docs/v2_design_overview.md +38 -0
- langchain_postgres-0.0.15/examples/migrate_pgvector_to_pgvectorstore.ipynb +330 -0
- langchain_postgres-0.0.15/examples/migrate_pgvector_to_pgvectorstore.md +174 -0
- langchain_postgres-0.0.15/examples/pg_vectorstore.ipynb +550 -0
- langchain_postgres-0.0.15/examples/pg_vectorstore_how_to.ipynb +734 -0
- langchain_postgres-0.0.15/examples/vectorstore.ipynb +463 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/chat_message_histories.py +1 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/v2/async_vectorstore.py +190 -47
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/v2/engine.py +63 -1
- langchain_postgres-0.0.15/langchain_postgres/v2/hybrid_search_config.py +149 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/v2/vectorstores.py +19 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/pyproject.toml +50 -46
- langchain_postgres-0.0.15/security.md +61 -0
- langchain_postgres-0.0.15/tests/__init__.py +0 -0
- langchain_postgres-0.0.15/tests/unit_tests/__init__.py +0 -0
- langchain_postgres-0.0.15/tests/unit_tests/fake_embeddings.py +29 -0
- langchain_postgres-0.0.15/tests/unit_tests/fixtures/__init__.py +0 -0
- langchain_postgres-0.0.15/tests/unit_tests/fixtures/filtering_test_cases.py +288 -0
- langchain_postgres-0.0.15/tests/unit_tests/fixtures/metadata_filtering_data.py +254 -0
- langchain_postgres-0.0.15/tests/unit_tests/query_constructors/__init__.py +0 -0
- langchain_postgres-0.0.15/tests/unit_tests/query_constructors/test_pgvector.py +87 -0
- langchain_postgres-0.0.15/tests/unit_tests/test_imports.py +17 -0
- langchain_postgres-0.0.15/tests/unit_tests/v1/__init__.py +0 -0
- langchain_postgres-0.0.15/tests/unit_tests/v1/test_chat_histories.py +123 -0
- langchain_postgres-0.0.15/tests/unit_tests/v1/test_vectorstore.py +1076 -0
- langchain_postgres-0.0.15/tests/unit_tests/v1/test_vectorstore_standard_tests.py +37 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/__init__.py +0 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_async_pg_vectorstore.py +338 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_async_pg_vectorstore_from_methods.py +187 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_async_pg_vectorstore_index.py +183 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_async_pg_vectorstore_search.py +728 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_engine.py +412 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_hybrid_search_config.py +229 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_indexes.py +63 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_pg_vectorstore.py +486 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_pg_vectorstore_from_methods.py +286 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_pg_vectorstore_index.py +181 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_pg_vectorstore_search.py +463 -0
- langchain_postgres-0.0.15/tests/unit_tests/v2/test_pg_vectorstore_standard_suite.py +92 -0
- langchain_postgres-0.0.15/tests/utils.py +56 -0
- langchain_postgres-0.0.15/uv.lock +1456 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/LICENSE +0 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/__init__.py +0 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/_utils.py +0 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/py.typed +0 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/translator.py +0 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/utils/pgvector_migrator.py +0 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/v2/__init__.py +0 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/v2/indexes.py +0 -0
- {langchain_postgres-0.0.14 → langchain_postgres-0.0.15}/langchain_postgres/vectorstores.py +0 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
# TODO: https://docs.astral.sh/uv/guides/integration/github/#caching
|
2
|
+
|
3
|
+
name: uv-install
|
4
|
+
description: Set up Python and uv
|
5
|
+
|
6
|
+
inputs:
|
7
|
+
python-version:
|
8
|
+
description: Python version, supporting MAJOR.MINOR only
|
9
|
+
required: true
|
10
|
+
|
11
|
+
runs:
|
12
|
+
using: composite
|
13
|
+
steps:
|
14
|
+
- name: Install uv and set the python version
|
15
|
+
uses: astral-sh/setup-uv@v5
|
16
|
+
with:
|
17
|
+
version: ${{ env.UV_VERSION }}
|
18
|
+
python-version: ${{ inputs.python-version }}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: lint
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_call:
|
5
|
+
inputs:
|
6
|
+
working-directory:
|
7
|
+
required: true
|
8
|
+
type: string
|
9
|
+
description: "From which folder this pipeline executes"
|
10
|
+
python-version:
|
11
|
+
required: true
|
12
|
+
type: string
|
13
|
+
description: "Python version to use"
|
14
|
+
|
15
|
+
env:
|
16
|
+
WORKDIR: ${{ inputs.working-directory == '' && '.' || inputs.working-directory }}
|
17
|
+
|
18
|
+
# This env var allows us to get inline annotations when ruff has complaints.
|
19
|
+
RUFF_OUTPUT_FORMAT: github
|
20
|
+
UV_FROZEN: "true"
|
21
|
+
|
22
|
+
jobs:
|
23
|
+
build:
|
24
|
+
name: "make lint #${{ inputs.python-version }}"
|
25
|
+
runs-on: ubuntu-latest
|
26
|
+
timeout-minutes: 20
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v4
|
29
|
+
|
30
|
+
- name: Set up Python ${{ inputs.python-version }} + uv
|
31
|
+
uses: "./.github/actions/uv_setup"
|
32
|
+
with:
|
33
|
+
python-version: ${{ inputs.python-version }}
|
34
|
+
|
35
|
+
- name: Install dependencies
|
36
|
+
working-directory: ${{ inputs.working-directory }}
|
37
|
+
run: |
|
38
|
+
uv sync --group test
|
39
|
+
|
40
|
+
- name: Analysing the code with our lint
|
41
|
+
working-directory: ${{ inputs.working-directory }}
|
42
|
+
run: |
|
43
|
+
make lint
|
@@ -0,0 +1,157 @@
|
|
1
|
+
name: release
|
2
|
+
run-name: Release ${{ inputs.working-directory }} by @${{ github.actor }}
|
3
|
+
on:
|
4
|
+
workflow_call:
|
5
|
+
inputs:
|
6
|
+
working-directory:
|
7
|
+
required: true
|
8
|
+
type: string
|
9
|
+
description: "From which folder this pipeline executes"
|
10
|
+
workflow_dispatch:
|
11
|
+
inputs:
|
12
|
+
working-directory:
|
13
|
+
description: "From which folder this pipeline executes"
|
14
|
+
default: "libs/server"
|
15
|
+
required: true
|
16
|
+
type: choice
|
17
|
+
options:
|
18
|
+
- "."
|
19
|
+
dangerous-nonmain-release:
|
20
|
+
required: false
|
21
|
+
type: boolean
|
22
|
+
default: false
|
23
|
+
description: "Release from a non-main branch (danger!)"
|
24
|
+
|
25
|
+
env:
|
26
|
+
PYTHON_VERSION: "3.11"
|
27
|
+
UV_FROZEN: "true"
|
28
|
+
UV_NO_SYNC: "true"
|
29
|
+
|
30
|
+
jobs:
|
31
|
+
build:
|
32
|
+
if: github.ref == 'refs/heads/main' || inputs.dangerous-nonmain-release
|
33
|
+
environment: Scheduled testing
|
34
|
+
runs-on: ubuntu-latest
|
35
|
+
|
36
|
+
outputs:
|
37
|
+
pkg-name: ${{ steps.check-version.outputs.pkg-name }}
|
38
|
+
version: ${{ steps.check-version.outputs.version }}
|
39
|
+
|
40
|
+
steps:
|
41
|
+
- uses: actions/checkout@v4
|
42
|
+
|
43
|
+
- name: Set up Python + uv
|
44
|
+
uses: "./.github/actions/uv_setup"
|
45
|
+
with:
|
46
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
47
|
+
|
48
|
+
# We want to keep this build stage *separate* from the release stage,
|
49
|
+
# so that there's no sharing of permissions between them.
|
50
|
+
# The release stage has trusted publishing and GitHub repo contents write access,
|
51
|
+
# and we want to keep the scope of that access limited just to the release job.
|
52
|
+
# Otherwise, a malicious `build` step (e.g. via a compromised dependency)
|
53
|
+
# could get access to our GitHub or PyPI credentials.
|
54
|
+
#
|
55
|
+
# Per the trusted publishing GitHub Action:
|
56
|
+
# > It is strongly advised to separate jobs for building [...]
|
57
|
+
# > from the publish job.
|
58
|
+
# https://github.com/pypa/gh-action-pypi-publish#non-goals
|
59
|
+
- name: Build project for distribution
|
60
|
+
run: uv build
|
61
|
+
working-directory: ${{ inputs.working-directory }}
|
62
|
+
- name: Upload build
|
63
|
+
uses: actions/upload-artifact@v4
|
64
|
+
with:
|
65
|
+
name: dist
|
66
|
+
path: ${{ inputs.working-directory }}/dist/
|
67
|
+
|
68
|
+
- name: Check Version
|
69
|
+
id: check-version
|
70
|
+
shell: python
|
71
|
+
working-directory: ${{ inputs.working-directory }}
|
72
|
+
run: |
|
73
|
+
import os
|
74
|
+
import tomllib
|
75
|
+
with open("pyproject.toml", "rb") as f:
|
76
|
+
data = tomllib.load(f)
|
77
|
+
pkg_name = data["project"]["name"]
|
78
|
+
version = data["project"]["version"]
|
79
|
+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
|
80
|
+
f.write(f"pkg-name={pkg_name}\n")
|
81
|
+
f.write(f"version={version}\n")
|
82
|
+
|
83
|
+
publish:
|
84
|
+
needs:
|
85
|
+
- build
|
86
|
+
runs-on: ubuntu-latest
|
87
|
+
permissions:
|
88
|
+
# This permission is used for trusted publishing:
|
89
|
+
# https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/
|
90
|
+
#
|
91
|
+
# Trusted publishing has to also be configured on PyPI for each package:
|
92
|
+
# https://docs.pypi.org/trusted-publishers/adding-a-publisher/
|
93
|
+
id-token: write
|
94
|
+
|
95
|
+
defaults:
|
96
|
+
run:
|
97
|
+
working-directory: ${{ inputs.working-directory }}
|
98
|
+
|
99
|
+
steps:
|
100
|
+
- uses: actions/checkout@v4
|
101
|
+
|
102
|
+
- name: Set up Python + uv
|
103
|
+
uses: "./.github/actions/uv_setup"
|
104
|
+
with:
|
105
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
106
|
+
|
107
|
+
- uses: actions/download-artifact@v4
|
108
|
+
with:
|
109
|
+
name: dist
|
110
|
+
path: ${{ inputs.working-directory }}/dist/
|
111
|
+
|
112
|
+
- name: Publish package distributions to PyPI
|
113
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
114
|
+
with:
|
115
|
+
packages-dir: ${{ inputs.working-directory }}/dist/
|
116
|
+
verbose: true
|
117
|
+
print-hash: true
|
118
|
+
# Temp workaround since attestations are on by default as of gh-action-pypi-publish v1.11.0
|
119
|
+
attestations: false
|
120
|
+
|
121
|
+
mark-release:
|
122
|
+
needs:
|
123
|
+
- build
|
124
|
+
- publish
|
125
|
+
runs-on: ubuntu-latest
|
126
|
+
permissions:
|
127
|
+
# This permission is needed by `ncipollo/release-action` to
|
128
|
+
# create the GitHub release.
|
129
|
+
contents: write
|
130
|
+
|
131
|
+
defaults:
|
132
|
+
run:
|
133
|
+
working-directory: ${{ inputs.working-directory }}
|
134
|
+
|
135
|
+
steps:
|
136
|
+
- uses: actions/checkout@v4
|
137
|
+
|
138
|
+
- name: Set up Python + uv
|
139
|
+
uses: "./.github/actions/uv_setup"
|
140
|
+
with:
|
141
|
+
python-version: ${{ env.PYTHON_VERSION }}
|
142
|
+
|
143
|
+
- uses: actions/download-artifact@v4
|
144
|
+
with:
|
145
|
+
name: dist
|
146
|
+
path: ${{ inputs.working-directory }}/dist/
|
147
|
+
|
148
|
+
- name: Create Tag
|
149
|
+
uses: ncipollo/release-action@v1
|
150
|
+
with:
|
151
|
+
artifacts: "dist/*"
|
152
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
153
|
+
generateReleaseNotes: true
|
154
|
+
tag: ${{needs.build.outputs.pkg-name}}==${{ needs.build.outputs.version }}
|
155
|
+
body: ${{ needs.release-notes.outputs.release-body }}
|
156
|
+
commit: main
|
157
|
+
makeLatest: true
|
@@ -0,0 +1,96 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_call:
|
5
|
+
inputs:
|
6
|
+
working-directory:
|
7
|
+
required: true
|
8
|
+
type: string
|
9
|
+
description: "From which folder this pipeline executes"
|
10
|
+
|
11
|
+
env:
|
12
|
+
UV_FROZEN: "true"
|
13
|
+
UV_NO_SYNC: "true"
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
build:
|
17
|
+
defaults:
|
18
|
+
run:
|
19
|
+
working-directory: ${{ inputs.working-directory }}
|
20
|
+
runs-on: ubuntu-latest
|
21
|
+
services:
|
22
|
+
postgres:
|
23
|
+
# ensure postgres version this stays in sync with prod database
|
24
|
+
# and with postgres version used in docker compose
|
25
|
+
# Testing with postgres that has the pg vector extension
|
26
|
+
image: ankane/pgvector
|
27
|
+
env:
|
28
|
+
# optional (defaults to `postgres`)
|
29
|
+
POSTGRES_DB: langchain_test
|
30
|
+
# required
|
31
|
+
POSTGRES_PASSWORD: langchain
|
32
|
+
# optional (defaults to `5432`)
|
33
|
+
POSTGRES_PORT: 5432
|
34
|
+
# optional (defaults to `postgres`)
|
35
|
+
POSTGRES_USER: langchain
|
36
|
+
ports:
|
37
|
+
# maps tcp port 5432 on service container to the host
|
38
|
+
- 5432:5432
|
39
|
+
# set health checks to wait until postgres has started
|
40
|
+
options: >-
|
41
|
+
--health-cmd pg_isready
|
42
|
+
--health-interval 3s
|
43
|
+
--health-timeout 5s
|
44
|
+
--health-retries 10
|
45
|
+
strategy:
|
46
|
+
matrix:
|
47
|
+
python-version:
|
48
|
+
# - "3.9"
|
49
|
+
# - "3.10"
|
50
|
+
# - "3.11"
|
51
|
+
- "3.12"
|
52
|
+
name: Python ${{ matrix.python-version }}
|
53
|
+
steps:
|
54
|
+
- uses: actions/checkout@v4
|
55
|
+
- name: Install postgresql-client
|
56
|
+
run: |
|
57
|
+
sudo apt-get update
|
58
|
+
sudo apt-get install -y postgresql-client
|
59
|
+
- name: Test database connection
|
60
|
+
run: |
|
61
|
+
# Test psql connection
|
62
|
+
psql -h localhost -p 5432 -U langchain -d langchain_test -c "SELECT 1;"
|
63
|
+
|
64
|
+
if [ $? -ne 0 ]; then
|
65
|
+
echo "Postgres connection failed"
|
66
|
+
exit 1
|
67
|
+
else
|
68
|
+
echo "Postgres connection successful"
|
69
|
+
fi
|
70
|
+
env:
|
71
|
+
# postgress password is required; alternatively, you can run:
|
72
|
+
# `PGPASSWORD=postgres_password psql ...`
|
73
|
+
PGPASSWORD: langchain
|
74
|
+
- name: Set up Python ${{ inputs.python-version }} + uv
|
75
|
+
uses: "./.github/actions/uv_setup"
|
76
|
+
id: setup-python
|
77
|
+
with:
|
78
|
+
python-version: ${{ inputs.python-version }}
|
79
|
+
- name: Install dependencies
|
80
|
+
shell: bash
|
81
|
+
run: uv sync --group test
|
82
|
+
- name: Run unit tests
|
83
|
+
shell: bash
|
84
|
+
run: |
|
85
|
+
make test
|
86
|
+
- name: Ensure the tests did not create any additional files
|
87
|
+
shell: bash
|
88
|
+
run: |
|
89
|
+
set -eu
|
90
|
+
|
91
|
+
STATUS="$(git status)"
|
92
|
+
echo "$STATUS"
|
93
|
+
|
94
|
+
# grep will exit non-zero if the target message isn't found,
|
95
|
+
# and `set -e` above will cause the step to fail.
|
96
|
+
echo "$STATUS" | grep 'nothing to commit, working tree clean'
|
@@ -0,0 +1,50 @@
|
|
1
|
+
---
|
2
|
+
name: Run CI Tests
|
3
|
+
|
4
|
+
on:
|
5
|
+
push:
|
6
|
+
branches: [ main ]
|
7
|
+
pull_request:
|
8
|
+
workflow_dispatch: # Allows to trigger the workflow manually in GitHub UI
|
9
|
+
|
10
|
+
# If another push to the same PR or branch happens while this workflow is still running,
|
11
|
+
# cancel the earlier run in favor of the next run.
|
12
|
+
#
|
13
|
+
# There's no point in testing an outdated version of the code. GitHub only allows
|
14
|
+
# a limited number of job runners to be active at the same time, so it's better to cancel
|
15
|
+
# pointless jobs early so that more useful jobs can run sooner.
|
16
|
+
concurrency:
|
17
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
18
|
+
cancel-in-progress: true
|
19
|
+
|
20
|
+
env:
|
21
|
+
UV_FROZEN: "true"
|
22
|
+
UV_NO_SYNC: "true"
|
23
|
+
UV_VERSION: "0.5.25"
|
24
|
+
WORKDIR: "."
|
25
|
+
|
26
|
+
jobs:
|
27
|
+
lint:
|
28
|
+
strategy:
|
29
|
+
matrix:
|
30
|
+
# Only lint on the min and max supported Python versions.
|
31
|
+
# It's extremely unlikely that there's a lint issue on any version in between
|
32
|
+
# that doesn't show up on the min or max versions.
|
33
|
+
#
|
34
|
+
# GitHub rate-limits how many jobs can be running at any one time.
|
35
|
+
# Starting new jobs is also relatively slow,
|
36
|
+
# so linting on fewer versions makes CI faster.
|
37
|
+
python-version:
|
38
|
+
- "3.12"
|
39
|
+
uses:
|
40
|
+
./.github/workflows/_lint.yml
|
41
|
+
with:
|
42
|
+
working-directory: "."
|
43
|
+
python-version: ${{ matrix.python-version }}
|
44
|
+
secrets: inherit
|
45
|
+
test:
|
46
|
+
uses:
|
47
|
+
./.github/workflows/_test.yml
|
48
|
+
with:
|
49
|
+
working-directory: "."
|
50
|
+
secrets: inherit
|
@@ -0,0 +1,168 @@
|
|
1
|
+
### Python template
|
2
|
+
# Byte-compiled / optimized / DLL files
|
3
|
+
__pycache__/
|
4
|
+
*.py[cod]
|
5
|
+
*$py.class
|
6
|
+
|
7
|
+
# C extensions
|
8
|
+
*.so
|
9
|
+
|
10
|
+
# Distribution / packaging
|
11
|
+
.Python
|
12
|
+
build/
|
13
|
+
develop-eggs/
|
14
|
+
dist/
|
15
|
+
downloads/
|
16
|
+
eggs/
|
17
|
+
.eggs/
|
18
|
+
lib/
|
19
|
+
lib64/
|
20
|
+
parts/
|
21
|
+
sdist/
|
22
|
+
var/
|
23
|
+
wheels/
|
24
|
+
share/python-wheels/
|
25
|
+
*.egg-info/
|
26
|
+
.installed.cfg
|
27
|
+
*.egg
|
28
|
+
MANIFEST
|
29
|
+
|
30
|
+
# PyInstaller
|
31
|
+
# Usually these files are written by a python script from a template
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
33
|
+
*.manifest
|
34
|
+
*.spec
|
35
|
+
|
36
|
+
# Installer logs
|
37
|
+
pip-log.txt
|
38
|
+
pip-delete-this-directory.txt
|
39
|
+
|
40
|
+
# Unit test / coverage reports
|
41
|
+
htmlcov/
|
42
|
+
.tox/
|
43
|
+
.nox/
|
44
|
+
.coverage
|
45
|
+
.coverage.*
|
46
|
+
.cache
|
47
|
+
nosetests.xml
|
48
|
+
coverage.xml
|
49
|
+
*.cover
|
50
|
+
*.py,cover
|
51
|
+
.hypothesis/
|
52
|
+
.pytest_cache/
|
53
|
+
cover/
|
54
|
+
|
55
|
+
# Translations
|
56
|
+
*.mo
|
57
|
+
*.pot
|
58
|
+
|
59
|
+
# Django stuff:
|
60
|
+
*.log
|
61
|
+
local_settings.py
|
62
|
+
db.sqlite3
|
63
|
+
db.sqlite3-journal
|
64
|
+
|
65
|
+
# Flask stuff:
|
66
|
+
instance/
|
67
|
+
.webassets-cache
|
68
|
+
|
69
|
+
# Scrapy stuff:
|
70
|
+
.scrapy
|
71
|
+
|
72
|
+
# Sphinx documentation
|
73
|
+
docs/_build/
|
74
|
+
|
75
|
+
# PyBuilder
|
76
|
+
.pybuilder/
|
77
|
+
target/
|
78
|
+
|
79
|
+
# Jupyter Notebook
|
80
|
+
.ipynb_checkpoints
|
81
|
+
|
82
|
+
# IPython
|
83
|
+
profile_default/
|
84
|
+
ipython_config.py
|
85
|
+
|
86
|
+
# pyenv
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
89
|
+
# .python-version
|
90
|
+
|
91
|
+
# pipenv
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
95
|
+
# install all needed dependencies.
|
96
|
+
#Pipfile.lock
|
97
|
+
|
98
|
+
# poetry
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
101
|
+
# commonly ignored for libraries.
|
102
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
103
|
+
#poetry.lock
|
104
|
+
|
105
|
+
# pdm
|
106
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
107
|
+
#pdm.lock
|
108
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
109
|
+
# in version control.
|
110
|
+
# https://pdm.fming.dev/#use-with-ide
|
111
|
+
.pdm.toml
|
112
|
+
|
113
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
114
|
+
__pypackages__/
|
115
|
+
|
116
|
+
# Celery stuff
|
117
|
+
celerybeat-schedule
|
118
|
+
celerybeat.pid
|
119
|
+
|
120
|
+
# SageMath parsed files
|
121
|
+
*.sage.py
|
122
|
+
|
123
|
+
# Environments
|
124
|
+
.env
|
125
|
+
.venv
|
126
|
+
env/
|
127
|
+
venv/
|
128
|
+
ENV/
|
129
|
+
env.bak/
|
130
|
+
venv.bak/
|
131
|
+
|
132
|
+
# Spyder project settings
|
133
|
+
.spyderproject
|
134
|
+
.spyproject
|
135
|
+
|
136
|
+
# Rope project settings
|
137
|
+
.ropeproject
|
138
|
+
|
139
|
+
# mkdocs documentation
|
140
|
+
/site
|
141
|
+
|
142
|
+
# mypy
|
143
|
+
.mypy_cache/
|
144
|
+
.dmypy.json
|
145
|
+
dmypy.json
|
146
|
+
|
147
|
+
# Pyre type checker
|
148
|
+
.pyre/
|
149
|
+
|
150
|
+
# pytype static type analyzer
|
151
|
+
.pytype/
|
152
|
+
|
153
|
+
# Cython debug symbols
|
154
|
+
cython_debug/
|
155
|
+
|
156
|
+
# PyCharm
|
157
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
158
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
159
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
160
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
161
|
+
#.idea/
|
162
|
+
.DS_Store
|
163
|
+
|
164
|
+
# Pycharm
|
165
|
+
.idea
|
166
|
+
|
167
|
+
# pyenv virtualenv
|
168
|
+
.python-version
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Contributing to langchain-postgres
|
2
|
+
|
3
|
+
This guide is intended to help you get started contributing to langchain-postgres.
|
4
|
+
As an open-source project in a rapidly developing field, we are extremely open
|
5
|
+
to contributions, whether it be in the form of a new feature, improved infra, or better documentation.
|
6
|
+
|
7
|
+
To contribute to this project, please follow the [fork and pull request](https://docs.github.com/en/get-started/quickstart/contributing-to-projects) workflow.
|
8
|
+
|
9
|
+
## Reporting bugs or suggesting improvements
|
10
|
+
|
11
|
+
Our [GitHub issues](https://github.com/langchain-ai/langchain-postgres/issues) page is kept up to date
|
12
|
+
with bugs, improvements, and feature requests. There is a taxonomy of labels to help
|
13
|
+
with sorting and discovery of issues of interest. [See this page](https://github.com/langchain-ai/langchain-postgres/labels) for an overview of
|
14
|
+
the system we use to tag our issues and pull requests.
|
15
|
+
|
16
|
+
If you're looking for help with your code, consider posting a question on the
|
17
|
+
[GitHub Discussions board](https://github.com/langchain-ai/langchain/discussions). Please
|
18
|
+
understand that we won't be able to provide individual support via email. We
|
19
|
+
also believe that help is much more valuable if it's **shared publicly**,
|
20
|
+
so that more people can benefit from it.
|
21
|
+
|
22
|
+
- **Describing your issue:** Try to provide as many details as possible. What
|
23
|
+
exactly goes wrong? _How_ is it failing? Is there an error?
|
24
|
+
"XY doesn't work" usually isn't that helpful for tracking down problems. Always
|
25
|
+
remember to include the code you ran and if possible, extract only the relevant
|
26
|
+
parts and don't just dump your entire script. This will make it easier for us to
|
27
|
+
reproduce the error.
|
28
|
+
|
29
|
+
- **Sharing long blocks of code or logs:** If you need to include long code,
|
30
|
+
logs or tracebacks, you can wrap them in `<details>` and `</details>`. This
|
31
|
+
[collapses the content](https://developer.mozilla.org/en/docs/Web/HTML/Element/details)
|
32
|
+
so it only becomes visible on click, making the issue easier to read and follow.
|
33
|
+
|
34
|
+
## Contributing code and documentation
|
35
|
+
|
36
|
+
You can develop langchain-postgres locally and contribute to the Project!
|
37
|
+
|
38
|
+
See [DEVELOPMENT.md](DEVELOPMENT.md) for instructions on setting up and using a development environment.
|
39
|
+
|
40
|
+
## Opening a pull request
|
41
|
+
|
42
|
+
Once you wrote and manually tested your change, you can start sending the patch to the main repository.
|
43
|
+
|
44
|
+
- Open a new GitHub pull request with the patch against the `main` branch.
|
45
|
+
- Ensure the PR title follows semantic commits conventions.
|
46
|
+
- For example, `feat: add new feature`, `fix: correct issue with X`.
|
47
|
+
- Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Setting up a Development Environment
|
2
|
+
|
3
|
+
This document details how to set up a local development environment that will
|
4
|
+
allow you to contribute changes to the project.
|
5
|
+
|
6
|
+
Acquire sources and create virtualenv.
|
7
|
+
```shell
|
8
|
+
git clone https://github.com/langchain-ai/langchain-postgres
|
9
|
+
cd langchain-postgres
|
10
|
+
uv venv --python=3.13
|
11
|
+
source .venv/bin/activate
|
12
|
+
```
|
13
|
+
|
14
|
+
Install package in editable mode.
|
15
|
+
```shell
|
16
|
+
poetry install --with dev,test,lint
|
17
|
+
```
|
18
|
+
|
19
|
+
Start PostgreSQL/PGVector.
|
20
|
+
```shell
|
21
|
+
docker run --rm -it --name pgvector-container \
|
22
|
+
-e POSTGRES_USER=langchain \
|
23
|
+
-e POSTGRES_PASSWORD=langchain \
|
24
|
+
-e POSTGRES_DB=langchain \
|
25
|
+
-p 6024:5432 pgvector/pgvector:pg16 \
|
26
|
+
postgres -c log_statement=all
|
27
|
+
```
|
28
|
+
|
29
|
+
Invoke test cases.
|
30
|
+
```shell
|
31
|
+
pytest -vvv
|
32
|
+
```
|
@@ -0,0 +1,58 @@
|
|
1
|
+
.PHONY: all lint format test help
|
2
|
+
|
3
|
+
# Default target executed when no arguments are given to make.
|
4
|
+
all: help
|
5
|
+
|
6
|
+
######################
|
7
|
+
# TESTING AND COVERAGE
|
8
|
+
######################
|
9
|
+
|
10
|
+
# Define a variable for the test file path.
|
11
|
+
TEST_FILE ?= tests/unit_tests/
|
12
|
+
|
13
|
+
test:
|
14
|
+
uv run pytest --disable-socket --allow-unix-socket $(TEST_FILE)
|
15
|
+
|
16
|
+
test_watch:
|
17
|
+
uv run ptw . -- $(TEST_FILE)
|
18
|
+
|
19
|
+
|
20
|
+
######################
|
21
|
+
# LINTING AND FORMATTING
|
22
|
+
######################
|
23
|
+
|
24
|
+
# Define a variable for Python and notebook files.
|
25
|
+
lint format: PYTHON_FILES=.
|
26
|
+
lint_diff format_diff: PYTHON_FILES=$(shell git diff --relative=. --name-only --diff-filter=d master | grep -E '\.py$$|\.ipynb$$')
|
27
|
+
|
28
|
+
lint lint_diff:
|
29
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run ruff format $(PYTHON_FILES) --diff
|
30
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run ruff check $(PYTHON_FILES) --diff
|
31
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run mypy $(PYTHON_FILES)
|
32
|
+
|
33
|
+
format format_diff:
|
34
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run ruff format $(PYTHON_FILES)
|
35
|
+
[ "$(PYTHON_FILES)" = "" ] || uv run ruff check --fix $(PYTHON_FILES)
|
36
|
+
|
37
|
+
spell_check:
|
38
|
+
uv run codespell --toml pyproject.toml
|
39
|
+
|
40
|
+
spell_fix:
|
41
|
+
uv run codespell --toml pyproject.toml -w
|
42
|
+
|
43
|
+
######################
|
44
|
+
# HELP
|
45
|
+
######################
|
46
|
+
|
47
|
+
help:
|
48
|
+
@echo '===================='
|
49
|
+
@echo '-- LINTING --'
|
50
|
+
@echo 'format - run code formatters'
|
51
|
+
@echo 'lint - run linters'
|
52
|
+
@echo 'spell_check - run codespell on the project'
|
53
|
+
@echo 'spell_fix - run codespell on the project and fix the errors'
|
54
|
+
@echo '-- TESTS --'
|
55
|
+
@echo 'coverage - run unit tests and generate coverage report'
|
56
|
+
@echo 'test - run unit tests'
|
57
|
+
@echo 'test TEST_FILE=<test_file> - run all tests in file'
|
58
|
+
@echo '-- DOCUMENTATION tasks are from the top-level Makefile --'
|