Skip to content

Commit e373c3d

Browse files
authored
Update create_embeddings.py
1 parent 49e67d2 commit e373c3d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

samples/langchain_on_vertexai/create_embeddings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
from langchain_google_cloud_sql_pg import PostgresEngine, PostgresVectorStore
3333

34+
3435
async def run_on_background(engine: PostgresEngine, coro: Coroutine) -> Any:
3536
"""Runs a coroutine on the engine's background loop."""
3637
if engine._default_loop:
@@ -39,6 +40,7 @@ async def run_on_background(engine: PostgresEngine, coro: Coroutine) -> Any:
3940
)
4041
return await coro
4142

43+
4244
async def create_databases():
4345
engine = await PostgresEngine.afrom_instance(
4446
PROJECT_ID,
@@ -48,11 +50,13 @@ async def create_databases():
4850
user=USER,
4951
password=PASSWORD,
5052
)
53+
5154
async def _logic():
5255
async with engine._pool.connect() as conn:
5356
await conn.execute(text("COMMIT"))
5457
await conn.execute(text(f'DROP DATABASE IF EXISTS "{DATABASE}"'))
5558
await conn.execute(text(f'CREATE DATABASE "{DATABASE}"'))
59+
5660
await run_on_background(engine, _logic())
5761
await engine.close()
5862

0 commit comments

Comments
 (0)