|
13 | 13 | "Here is a list of packages that are used in this notebook.\n", |
14 | 14 | "\n", |
15 | 15 | "```\n", |
16 | | - "!pip list | grep -E -w \"sagemaker|ipython-sql|langchain|psycopg2|pgvector|numpy|sh\"\n", |
17 | | - "----------------------------------------------------------------------------------------\n", |
18 | | - "ipython-sql 0.5.0\n", |
19 | | - "langchain 0.1.0\n", |
20 | | - "langchain-community 0.0.20\n", |
21 | | - "langchain-core 0.1.52\n", |
22 | | - "langchain-text-splitters 0.0.1\n", |
23 | | - "numpy 1.24.3\n", |
24 | | - "pgvector 0.2.0\n", |
25 | | - "psycopg2-binary 2.9.6\n", |
26 | | - "sagemaker 2.155.0\n", |
27 | | - "sagemaker-studio-image-build 0.6.0\n", |
28 | | - "sh 2.0.4\n", |
| 16 | + "!pip list | grep -E -w \"sagemaker_studio_image_build|ipython-sql|langchain|psycopg|pgvector|numpy|sh\"\n", |
| 17 | + "-----------------------------------------------------------------------------------------------------\n", |
| 18 | + "ipython-sql 0.5.0\n", |
| 19 | + "langchain 0.2.5\n", |
| 20 | + "langchain-community 0.2.4\n", |
| 21 | + "langchain-core 0.2.43\n", |
| 22 | + "langchain-postgres 0.0.7\n", |
| 23 | + "langchain-text-splitters 0.2.4\n", |
| 24 | + "numpy 1.26.4\n", |
| 25 | + "pgvector 0.2.5\n", |
| 26 | + "psycopg 3.1.19\n", |
| 27 | + "psycopg-binary 3.1.19\n", |
| 28 | + "psycopg-pool 3.2.4\n", |
| 29 | + "sagemaker_studio_image_build 0.6.0\n", |
| 30 | + "sh 2.0.4\n", |
29 | 31 | "```" |
30 | 32 | ] |
31 | 33 | }, |
|
49 | 51 | "source": [ |
50 | 52 | "%%capture --no-stderr\n", |
51 | 53 | "\n", |
52 | | - "!pip install -U langchain==0.1.0\n", |
| 54 | + "!pip install -U langchain==0.2.5\n", |
| 55 | + "!pip install -U langchain-community==0.2.4\n", |
| 56 | + "!pip install -U langchain-postgres==0.0.7\n", |
| 57 | + "!pip install -U SQLAlchemy==2.0.28\n", |
| 58 | + "!pip install -U pgvector==0.2.5\n", |
| 59 | + "!pip install -U psycopg[binary]==3.1.19\n", |
53 | 60 | "!pip install -U ipython-sql==0.5.0\n", |
54 | | - "!pip install -U psycopg2-binary==2.9.6\n", |
55 | | - "!pip install -U pgvector==0.2.0\n", |
56 | 61 | "!pip install -U sh==2.0.4\n", |
57 | 62 | "!pip install -U sagemaker-studio-image-build==0.6.0" |
58 | 63 | ] |
|
66 | 71 | }, |
67 | 72 | "outputs": [], |
68 | 73 | "source": [ |
69 | | - "!pip list | grep -E -w \"sagemaker|ipython-sql|langchain|psycopg2|pgvector|numpy|sh\"" |
| 74 | + "!pip list | grep -E -w \"sagemaker_studio_image_build|ipython-sql|langchain|psycopg|pgvector|numpy|sh\"" |
70 | 75 | ] |
71 | 76 | }, |
72 | 77 | { |
|
277 | 282 | "db_port = secret['port']\n", |
278 | 283 | "db_host = secret['host']\n", |
279 | 284 | "\n", |
280 | | - "driver = 'psycopg2'\n", |
| 285 | + "driver = 'psycopg'\n", |
281 | 286 | "\n", |
282 | 287 | "connection_string = f\"postgresql+{driver}://{db_username}:{db_password}@{db_host}:{db_port}/\"\n", |
283 | 288 | "connection_string" |
|
566 | 571 | "metadata": {}, |
567 | 572 | "outputs": [], |
568 | 573 | "source": [ |
569 | | - "!pip install -Uq beautifulsoup4==4.12.3" |
| 574 | + "%%capture --no-stderr\n", |
| 575 | + "\n", |
| 576 | + "!pip install -U beautifulsoup4==4.12.3" |
570 | 577 | ] |
571 | 578 | }, |
572 | 579 | { |
|
633 | 640 | "outputs": [], |
634 | 641 | "source": [ |
635 | 642 | "import urllib\n", |
636 | | - "from langchain_community.vectorstores import PGVector\n", |
| 643 | + "from langchain_postgres import PGVector\n", |
637 | 644 | "from container.credentials import get_credentials\n", |
638 | 645 | "\n", |
639 | 646 | "\n", |
|
644 | 651 | "db_host = secret['host']\n", |
645 | 652 | "\n", |
646 | 653 | "CONNECTION_STRING = PGVector.connection_string_from_db_params(\n", |
647 | | - " driver='psycopg2',\n", |
| 654 | + " driver='psycopg',\n", |
648 | 655 | " user=db_username,\n", |
649 | 656 | " password=db_password,\n", |
650 | 657 | " host=db_host,\n", |
|
670 | 677 | "\n", |
671 | 678 | "vectordb = PGVector(\n", |
672 | 679 | " collection_name=pgvector_collection_name,\n", |
673 | | - " connection_string=CONNECTION_STRING,\n", |
674 | | - " embedding_function=embeddings\n", |
| 680 | + " connection=CONNECTION_STRING,\n", |
| 681 | + " embeddings=embeddings\n", |
675 | 682 | ")" |
676 | 683 | ] |
677 | 684 | }, |
|
711 | 718 | "source": [ |
712 | 719 | "import urllib\n", |
713 | 720 | "\n", |
714 | | - "from langchain.vectorstores import PGVector\n", |
| 721 | + "from langchain_postgres import PGVector\n", |
715 | 722 | "\n", |
716 | 723 | "from container.credentials import get_credentials\n", |
717 | 724 | "from container.sm_helper import create_sagemaker_embeddings_from_js_model\n", |
|
725 | 732 | "db_host = secret['host']\n", |
726 | 733 | "\n", |
727 | 734 | "connection_string = PGVector.connection_string_from_db_params(\n", |
728 | | - " driver='psycopg2',\n", |
| 735 | + " driver='psycopg',\n", |
729 | 736 | " user=db_username,\n", |
730 | 737 | " password=db_password,\n", |
731 | 738 | " host=db_host,\n", |
|
737 | 744 | " embedding=create_sagemaker_embeddings_from_js_model(embeddings_model_endpoint_name,\n", |
738 | 745 | " aws_region),\n", |
739 | 746 | " collection_name=pgvector_collection_name,\n", |
740 | | - " connection_string=connection_string)\n", |
| 747 | + " connection=connection_string)\n", |
741 | 748 | "\n", |
742 | 749 | "q = \"Which XGBoost versions does SageMaker support?\"\n", |
743 | 750 | "docs = docsearch.similarity_search(q, k=3)\n", |
|
0 commit comments