diff --git a/samples/langchain_on_vertexai/create_embeddings.py b/samples/langchain_on_vertexai/create_embeddings.py index 105a86df..9fd5e241 100644 --- a/samples/langchain_on_vertexai/create_embeddings.py +++ b/samples/langchain_on_vertexai/create_embeddings.py @@ -33,6 +33,8 @@ async def create_databases(): + PostgresEngine._connector = None + engine = await PostgresEngine.afrom_instance( PROJECT_ID, REGION, @@ -49,6 +51,8 @@ async def create_databases(): async def create_vectorstore(): + PostgresEngine._connector = None + engine = await PostgresEngine.afrom_instance( PROJECT_ID, REGION, @@ -108,4 +112,16 @@ async def main(): await create_vectorstore() -asyncio.run(main()) +if __name__ == "__main__": + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + try: + loop.run_until_complete(main()) + finally: + try: + tasks = asyncio.all_tasks(loop) + for task in tasks: + task.cancel() + loop.run_until_complete(asyncio.gather(*tasks, return_exceptions=True)) + finally: + loop.close() diff --git a/samples/langchain_on_vertexai/requirements.txt b/samples/langchain_on_vertexai/requirements.txt index f841a4c3..064bf76a 100644 --- a/samples/langchain_on_vertexai/requirements.txt +++ b/samples/langchain_on_vertexai/requirements.txt @@ -1,4 +1,4 @@ -google-cloud-aiplatform[reasoningengine,langchain]==1.120.0 +google-cloud-aiplatform[reasoningengine,langchain]==1.121.0 google-cloud-resource-manager==1.14.2 langchain-community==0.3.31 langchain-google-cloud-sql-pg==0.14.1