Skip to content

Commit 4eac187

Browse files
authored
Merge branch 'main' into renovate/all-minor-patch
2 parents 162ac50 + bf1b119 commit 4eac187

File tree

7 files changed

+41
-15
lines changed

7 files changed

+41
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ test = [
4747
"pytest-asyncio==0.26.0",
4848
"pytest==8.4.2",
4949
"pytest-cov==7.0.0",
50-
"langchain-tests==0.3.22",
50+
"langchain-tests==1.1.0",
5151
"langgraph==0.6.10"
5252
]
5353

samples/langchain_on_vertexai/clean_up.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
import asyncio
1515
import os
16+
from typing import Any, Coroutine
1617

1718
from config import (
1819
CHAT_TABLE_NAME,
@@ -32,6 +33,15 @@
3233
TEST_NAME = os.getenv("DISPLAY_NAME")
3334

3435

36+
async def run_on_background(engine: PostgresEngine, coro: Coroutine) -> Any:
37+
"""Runs a coroutine on the engine's background loop."""
38+
if engine._default_loop:
39+
return await asyncio.wrap_future(
40+
asyncio.run_coroutine_threadsafe(coro, engine._default_loop)
41+
)
42+
return await coro
43+
44+
3545
async def delete_tables():
3646
engine = await PostgresEngine.afrom_instance(
3747
PROJECT_ID,
@@ -42,12 +52,14 @@ async def delete_tables():
4252
password=PASSWORD,
4353
)
4454

45-
async with engine._pool.connect() as conn:
46-
await conn.execute(text("COMMIT"))
47-
await conn.execute(text(f"DROP TABLE IF EXISTS {TABLE_NAME}"))
48-
await conn.execute(text(f"DROP TABLE IF EXISTS {CHAT_TABLE_NAME}"))
55+
async def _logic():
56+
async with engine._pool.connect() as conn:
57+
await conn.execute(text("COMMIT"))
58+
await conn.execute(text(f"DROP TABLE IF EXISTS {TABLE_NAME}"))
59+
await conn.execute(text(f"DROP TABLE IF EXISTS {CHAT_TABLE_NAME}"))
60+
61+
await run_on_background(engine, _logic())
4962
await engine.close()
50-
await engine._connector.close_async()
5163

5264

5365
def delete_engines():

samples/langchain_on_vertexai/create_embeddings.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414
import asyncio
1515
import uuid
16+
from typing import Any, Coroutine
1617

1718
from config import (
1819
CHAT_TABLE_NAME,
@@ -32,6 +33,15 @@
3233
from langchain_google_cloud_sql_pg import PostgresEngine, PostgresVectorStore
3334

3435

36+
async def run_on_background(engine: PostgresEngine, coro: Coroutine) -> Any:
37+
"""Runs a coroutine on the engine's background loop."""
38+
if engine._default_loop:
39+
return await asyncio.wrap_future(
40+
asyncio.run_coroutine_threadsafe(coro, engine._default_loop)
41+
)
42+
return await coro
43+
44+
3545
async def create_databases():
3646
engine = await PostgresEngine.afrom_instance(
3747
PROJECT_ID,
@@ -41,10 +51,14 @@ async def create_databases():
4151
user=USER,
4252
password=PASSWORD,
4353
)
44-
async with engine._pool.connect() as conn:
45-
await conn.execute(text("COMMIT"))
46-
await conn.execute(text(f'DROP DATABASE IF EXISTS "{DATABASE}"'))
47-
await conn.execute(text(f'CREATE DATABASE "{DATABASE}"'))
54+
55+
async def _logic():
56+
async with engine._pool.connect() as conn:
57+
await conn.execute(text("COMMIT"))
58+
await conn.execute(text(f'DROP DATABASE IF EXISTS "{DATABASE}"'))
59+
await conn.execute(text(f'CREATE DATABASE "{DATABASE}"'))
60+
61+
await run_on_background(engine, _logic())
4862
await engine.close()
4963

5064

@@ -95,7 +109,7 @@ async def grant_select(engine):
95109
engine,
96110
table_name=TABLE_NAME,
97111
embedding_service=VertexAIEmbeddings(
98-
model_name="textembedding-gecko@latest", project=PROJECT_ID
112+
model_name="text-embedding-005", project=PROJECT_ID
99113
),
100114
)
101115

samples/langchain_on_vertexai/prebuilt_langchain_agent_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def similarity_search(query: str) -> list[Document]:
6565
engine,
6666
table_name=TABLE_NAME,
6767
embedding_service=VertexAIEmbeddings(
68-
model_name="textembedding-gecko@latest", project=PROJECT_ID
68+
model_name="text-embedding-005", project=PROJECT_ID
6969
),
7070
)
7171
retriever = vector_store.as_retriever()

samples/langchain_on_vertexai/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
google-cloud-aiplatform[reasoningengine,langchain]==1.120.0
1+
google-cloud-aiplatform[reasoningengine,langchain]==1.121.0
22
google-cloud-resource-manager==1.14.2
33
langchain-community==0.3.31
44
langchain-google-cloud-sql-pg==0.14.1

samples/langchain_on_vertexai/retriever_agent_with_history_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def set_up(self):
9191
engine,
9292
table_name=self.table,
9393
embedding_service=VertexAIEmbeddings(
94-
model_name="textembedding-gecko@latest", project=self.project
94+
model_name="text-embedding-005", project=self.project
9595
),
9696
)
9797
retriever = vector_store.as_retriever()

samples/langchain_on_vertexai/retriever_chain_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def set_up(self):
9797
engine,
9898
table_name=self.table,
9999
embedding_service=VertexAIEmbeddings(
100-
model_name="textembedding-gecko@latest", project=self.project
100+
model_name="text-embedding-005", project=self.project
101101
),
102102
)
103103
retriever = vector_store.as_retriever()

0 commit comments

Comments
 (0)