diff --git a/.coveragerc b/.coveragerc index 1f19666..b3d3d91 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,4 +5,4 @@ omit = [report] show_missing = true -fail_under = 89 \ No newline at end of file +fail_under = 85 diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index e2c1a6e..b827043 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -27,7 +27,6 @@ branchProtectionRules: requiredStatusCheckContexts: - "cla/google" - "lint" - - "mysql-integration-test-pr-py38 (langchain-cloud-sql-testing)" - "mysql-integration-test-pr-py39 (langchain-cloud-sql-testing)" - "mysql-integration-test-pr-py310 (langchain-cloud-sql-testing)" - "mysql-integration-test-pr-py311 (langchain-cloud-sql-testing)" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ada322c..2833fe9 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - python-version: "3.9" + python-version: "3.10" - name: Install nox run: | python -m pip install --upgrade setuptools pip wheel @@ -35,4 +35,4 @@ jobs: python -m pip install nox - name: Run docfx run: | - nox -s docfx \ No newline at end of file + nox -s docfx diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2352d4b..cd8cab7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,12 +19,6 @@ on: - "*.md" - ".kokoro/**" - ".github/**" - pull_request_target: - types: [labeled] - paths-ignore: - - "*.md" - - ".kokoro/**" - - ".github/**" jobs: lint: @@ -34,33 +28,10 @@ jobs: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - # run job on proper workflow event triggers (skip job for pull_request event from forks and only run pull_request_target for "tests: run" label) - 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 - with: - ref: ${{ github.event.pull_request.head.sha }} - repository: ${{ github.event.pull_request.head.repo.full_name }} - token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Python uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 diff --git a/.kokoro/release.sh b/.kokoro/release.sh index c1628a3..e24441a 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -23,7 +23,7 @@ python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source / export PYTHONUNBUFFERED=1 # Move into the package, build the distribution and upload. -TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1") +TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-3") cd github/langchain-google-cloud-sql-mysql-python python3 -m build --wheel twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 4f3d373..c557815 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -28,7 +28,7 @@ before_action { fetch_keystore { keystore_resource { keystore_config_id: 73713 - keyname: "google-cloud-pypi-token-keystore-1" + keyname: "google-cloud-pypi-token-keystore-3" } } } diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt index 7d69372..4b06960 100644 --- a/.kokoro/requirements.txt +++ b/.kokoro/requirements.txt @@ -20,9 +20,9 @@ cachetools==4.2.4 \ --hash=sha256:89ea6f1b638d5a73a4f9226be57ac5e4f399d22770b92355f92dcb0f7f001693 \ --hash=sha256:92971d3cb7d2a97efff7c7bb1657f21a8f5fb309a37530537c71b1774189f2d1 # via google-auth -certifi==2023.11.17 \ - --hash=sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1 \ - --hash=sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474 +certifi==2024.7.4 \ + --hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \ + --hash=sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90 # via requests cffi==1.16.0 \ --hash=sha256:0c9ef6ff37e974b73c25eecc13952c55bceed9112be2d9d938ded8e856138bcc \ @@ -276,9 +276,9 @@ jeepney==0.8.0 \ # via # keyring # secretstorage -jinja2==3.1.4 \ - --hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \ - --hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d +jinja2==3.1.5 \ + --hash=sha256:8fefff8dc3034e27bb80d67c671eb8a9bc424c0ef4c0826edbff304cceff43bb \ + --hash=sha256:aba0f4dc9ed8013c424088f68a5c226f7d6097ed89b246d7749c2ec4175c6adb # via gcp-releasetool keyring==23.13.1 \ --hash=sha256:771ed2a91909389ed6148631de678f82ddc73737d85a927f382a8a1b157898cd \ @@ -516,9 +516,9 @@ wheel==0.43.0 \ --hash=sha256:465ef92c69fa5c5da2d1cf8ac40559a8c940886afcef87dcf14b9470862f1d85 \ --hash=sha256:55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81 # via -r requirements.in -zipp==3.18.1 \ - --hash=sha256:206f5a15f2af3dbaee80769fb7dc6f249695e940acca08dfb2a4769fe61e538b \ - --hash=sha256:2884ed22e7d8961de1c9a05142eb69a247f120291bc0206a00a7642f09b5b715 +zipp==3.19.1 \ + --hash=sha256:2828e64edb5386ea6a52e7ba7cdb17bb30a73a858f5eb6eb93d8d36f5ea26091 \ + --hash=sha256:35427f6d5594f4acf82d25541438348c26736fa9b3afa2754bcd63cdb99d8e8f # via importlib-metadata # WARNING: The following packages were not pinned, but pip requires them to be diff --git a/CHANGELOG.md b/CHANGELOG.md index dff5020..d9d7007 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [0.3.0](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/compare/v0.2.3...v0.3.0) (2025-01-06) + + +### Features + +* Remove support for Python 3.8 ([#97](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/issues/97)) ([ba02bf5](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/commit/ba02bf528830dafb599afae43bd1bf3b2ac7c493)) + + +### Documentation + +* Update README to reflect supported maintenance version ([#104](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/issues/104)) ([3ac0aab](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/commit/3ac0aabe6b242b6131f1fe0eb3c368ffbcc04a97)) + ## [0.2.3](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/compare/v0.2.2...v0.2.3) (2024-07-03) diff --git a/DEVELOPER.md b/DEVELOPER.md index f8b9caa..d255836 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -34,11 +34,11 @@ These tests are registered as required tests in `.github/sync-repo-settings.yaml #### Trigger Setup -Cloud Build triggers (for Python versions 3.8 to 3.11) were created with the following specs: +Cloud Build triggers (for Python versions 3.9 to 3.11) were created with the following specs: ```YAML -name: mysql-integration-test-pr-py38 -description: Run integration tests on PR for Python 3.8 +name: mysql-integration-test-pr-py39 +description: Run integration tests on PR for Python 3.9 filename: integration.cloudbuild.yaml github: name: langchain-google-cloud-sql-mysql-python @@ -55,7 +55,7 @@ substitutions: _INSTANCE_ID: _DB_NAME: _REGION: us-central1 - _VERSION: "3.8" + _VERSION: "3.9" ``` Use `gcloud builds triggers import --source=trigger.yaml` to create triggers via the command line diff --git a/README.rst b/README.rst index 9013f03..b46d280 100644 --- a/README.rst +++ b/README.rst @@ -31,6 +31,11 @@ steps: .. _Enable the Google Cloud SQL Admin API.: https://console.cloud.google.com/flows/enableapi?apiid=sqladmin.googleapis.com .. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html +Supported Cloud SQL Maintenance Versions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This LangChain integration is only supported for Cloud SQL maintenance versions between **MYSQL_8_0_36.R20240401.03_00** and **MYSQL_8_0_36.R20241208.01_00** + Installation ~~~~~~~~~~~~ @@ -44,7 +49,7 @@ With `virtualenv`_, it’s possible to install this library without needing syst Supported Python Versions ^^^^^^^^^^^^^^^^^^^^^^^^^ -Python >= 3.8 +Python >= 3.9 Mac/Linux ^^^^^^^^^ @@ -112,7 +117,7 @@ See the full `Document Loader`_ tutorial. .. _`Document Loader`: https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/blob/main/docs/document_loader.ipynb Chat Message History Usage --------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~ Use ``ChatMessageHistory`` to store messages and provide conversation history to LLMs. diff --git a/docs/vector_store.ipynb b/docs/vector_store.ipynb index 58fa822..a6aff77 100644 --- a/docs/vector_store.ipynb +++ b/docs/vector_store.ipynb @@ -29,7 +29,9 @@ "\n", " * [Create a Google Cloud Project](https://developers.google.com/workspace/guides/create-project)\n", " * [Enable the Cloud SQL Admin API.](https://console.cloud.google.com/flows/enableapi?apiid=sqladmin.googleapis.com)\n", - " * [Create a Cloud SQL instance.](https://cloud.google.com/sql/docs/mysql/connect-instance-auth-proxy#create-instance) (version must be >= **8.0.36** with **cloudsql_vector** database flag configured to \"On\")\n", + " * [Create a Cloud SQL instance.](https://cloud.google.com/sql/docs/mysql/connect-instance-auth-proxy#create-instance) \n", + " * Database version must be >= **8.0.36** with **cloudsql_vector** database flag configured to \"On\"\n", + " * Cloud SQL maintenance version must be between **MYSQL_8_0_36.R20240401.03_00** and **MYSQL_8_0_36.R20241208.01_00**\n", " * [Create a Cloud SQL database.](https://cloud.google.com/sql/docs/mysql/create-manage-databases)\n", " * [Add a User to the database.](https://cloud.google.com/sql/docs/mysql/create-manage-users)" ] @@ -379,16 +381,16 @@ "cell_type": "code", "execution_count": 17, "metadata": { - "id": "fpqeZgUeLL54", "colab": { "base_uri": "https://localhost:8080/" }, + "id": "fpqeZgUeLL54", "outputId": "f674a3af-452c-4d58-bb62-cbf514a9e1e3" }, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "Pineapple\n" ] @@ -415,16 +417,16 @@ "cell_type": "code", "execution_count": null, "metadata": { - "id": "N-NC5jgGLL55", "colab": { "base_uri": "https://localhost:8080/" }, + "id": "N-NC5jgGLL55", "outputId": "69a1f9de-a830-450d-8a5e-118b36815a46" }, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "[Document(page_content='Pineapple', metadata={'len': 9}), Document(page_content='Banana', metadata={'len': 6})]\n" ] @@ -490,12 +492,12 @@ }, { "cell_type": "markdown", - "source": [ - "## Advanced Usage" - ], "metadata": { "id": "K8XAZZTDqwIp" - } + }, + "source": [ + "## Advanced Usage" + ] }, { "cell_type": "markdown", @@ -560,16 +562,16 @@ "cell_type": "code", "execution_count": null, "metadata": { - "id": "Sqfgk6EOLL5-", "colab": { "base_uri": "https://localhost:8080/" }, + "id": "Sqfgk6EOLL5-", "outputId": "a10c74e2-fe48-4cf9-ba2f-85aecb2490d0" }, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "[Document(page_content='Pineapple', metadata={'len': 9}), Document(page_content='Banana', metadata={'len': 6}), Document(page_content='Apples and oranges', metadata={'len': 18}), Document(page_content='Cars and airplanes', metadata={'len': 18})]\n" ] @@ -593,6 +595,7 @@ }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Example Workflow\n", "\n", @@ -601,11 +604,13 @@ "Load the document, split it into chunks, embed each chunk and load it into the vector store.\n", "\n", "You can download the `state_of_the_union.txt` file [here](https://github.com/langchain-ai/langchain/blob/master/docs/docs/modules/state_of_the_union.txt).\n" - ], - "metadata": {} + ] }, { "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "from langchain_community.document_loaders import TextLoader\n", "from langchain_google_vertexai import VertexAIEmbeddings\n", @@ -623,13 +628,13 @@ "embeddings = VertexAIEmbeddings(\n", " model_name=\"textembedding-gecko@003\", project=PROJECT_ID\n", ")" - ], - "metadata": {}, - "execution_count": null, - "outputs": [] + ] }, { "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "import uuid\n", "\n", @@ -653,30 +658,22 @@ "\n", "ids = [str(uuid.uuid4()) for _ in documents]\n", "db = MySQLVectorStore.from_documents(documents, embeddings, engine, table_name, ids)" - ], - "metadata": {}, - "execution_count": null, - "outputs": [] + ] }, { "cell_type": "code", - "source": [ - "query = \"What did the president say about Ketanji Brown Jackson\"\n", - "docs = db.similarity_search(query)\n", - "print(docs[0].page_content)" - ], + "execution_count": null, "metadata": { - "id": "EUp4DpizYy2N", - "outputId": "18d0c336-6fea-4bba-9ba4-6fcc60fb5194", "colab": { "base_uri": "https://localhost:8080/" - } + }, + "id": "EUp4DpizYy2N", + "outputId": "18d0c336-6fea-4bba-9ba4-6fcc60fb5194" }, - "execution_count": null, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n", "\n", @@ -687,6 +684,11 @@ "And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.\n" ] } + ], + "source": [ + "query = \"What did the president say about Ketanji Brown Jackson\"\n", + "docs = db.similarity_search(query)\n", + "print(docs[0].page_content)" ] } ], @@ -714,4 +716,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} diff --git a/integration.cloudbuild.yaml b/integration.cloudbuild.yaml index cd6e9d2..3024a3b 100644 --- a/integration.cloudbuild.yaml +++ b/integration.cloudbuild.yaml @@ -26,7 +26,14 @@ steps: - id: Run integration tests name: python:${_VERSION} entrypoint: python - args: ["-m", "pytest", "--cov=langchain_google_cloud_sql_mysql", "--cov-config=.coveragerc", "tests/"] + args: + [ + "-m", + "pytest", + "--cov=langchain_google_cloud_sql_mysql", + "--cov-config=.coveragerc", + "tests/", + ] env: - "PROJECT_ID=$PROJECT_ID" - "INSTANCE_ID=$_INSTANCE_ID" @@ -46,7 +53,7 @@ substitutions: _INSTANCE_ID: test-instance _REGION: us-central1 _DB_NAME: test - _VERSION: "3.8" + _VERSION: "3.9" options: dynamicSubstitutions: true diff --git a/pyproject.toml b/pyproject.toml index 8811816..4e1d48c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ dynamic = ["version"] description = "LangChain integrations for Google Cloud SQL for MySQL" readme = "README.rst" license = {file = "LICENSE"} -requires-python = ">=3.8" +requires-python = ">=3.9" authors = [ {name = "Google LLC", email = "googleapis-packages@google.com"} ] @@ -21,7 +21,6 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -39,11 +38,11 @@ Changelog = "https://github.com/googleapis/langchain-google-cloud-sql-mysql-pyth [project.optional-dependencies] test = [ - "black[jupyter]==24.4.2", + "black[jupyter]==24.10.0", "isort==5.13.2", - "mypy==1.10.0", - "pytest-asyncio==0.23.7", - "pytest==8.2.2", + "mypy==1.13.0", + "pytest-asyncio==0.24.0", + "pytest==8.3.3", "pytest-cov==5.0.0" ] @@ -55,7 +54,7 @@ build-backend = "setuptools.build_meta" profile = "black" [tool.mypy] -python_version = "3.8" +python_version = "3.9" warn_unused_configs = true exclude = [ diff --git a/requirements.txt b/requirements.txt index d7f23de..d29d620 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ -langchain==0.2.5 -langchain-community==0.2.5 -numpy===1.24.4; python_version <= "3.8" -numpy==1.26.4; python_version > "3.8" -SQLAlchemy==2.0.31 -cloud-sql-python-connector[pymysql]==1.10.0 +langchain==0.3.4 +langchain-community==0.3.3 +numpy==1.26.4 +SQLAlchemy==2.0.36 +cloud-sql-python-connector[pymysql]==1.13.0 diff --git a/samples/langchain_quick_start.ipynb b/samples/langchain_quick_start.ipynb index 96daea5..441b060 100644 --- a/samples/langchain_quick_start.ipynb +++ b/samples/langchain_quick_start.ipynb @@ -271,9 +271,9 @@ "\n", "A database named `langchain_db` will be created and used for the rest of the quickstart.\n", "\n", - "**Note:** MySQL vector support is only available on MySQL instances with version **>= 8.0.36**.\n", + "**Note:** MySQL vector support is only available on MySQL instances with version **>= 8.0.36**. This LangChain integration is only supported for maintenance versions between **MYSQL_8_0_36.R20240401.03_00** and **MYSQL_8_0_36.R20241208.01_00**\n", "\n", - "> For existing instances, you may need to perform a [self-service maintenance update](https://cloud.google.com/sql/docs/mysql/self-service-maintenance) to update your maintenance version to **MYSQL_8_0_36.R20240401.03_00** or greater. Once updated, [configure your database flags](https://cloud.google.com/sql/docs/mysql/flags) to have thew new **cloudsql_vector** flag to \"On\".\n", + "> On the instance, [configure your database flags](https://cloud.google.com/sql/docs/mysql/flags) to have thew new **cloudsql_vector** flag to \"On\".\n", "\n", "> ⏳ - Creating a Cloud SQL instance may take a few minutes." ] diff --git a/src/langchain_google_cloud_sql_mysql/version.py b/src/langchain_google_cloud_sql_mysql/version.py index f6bd330..2b5d97a 100644 --- a/src/langchain_google_cloud_sql_mysql/version.py +++ b/src/langchain_google_cloud_sql_mysql/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.2.3" +__version__ = "0.3.0"