From 703ff79ee355462c76aa9a82e3e5563fc0f8dd08 Mon Sep 17 00:00:00 2001
From: Lawson Taylor <lawson.j.taylor@gmail.com>
Date: Mon, 10 Jun 2024 15:42:33 +0800
Subject: [PATCH] [DOCS] add docker image for postgres

---
 compose.yaml                                | 20 -----------
 docs/indexes/postgres/postgres.compose.yaml |  0
 docs/indexes/{ => postgres}/postgres.ipynb  | 39 +++++++++++++++++----
 3 files changed, 33 insertions(+), 26 deletions(-)
 delete mode 100644 compose.yaml
 create mode 100644 docs/indexes/postgres/postgres.compose.yaml
 rename docs/indexes/{ => postgres}/postgres.ipynb (78%)

diff --git a/compose.yaml b/compose.yaml
deleted file mode 100644
index 707851a2..00000000
--- a/compose.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-services:
-  postgres:
-    container_name: pgvector
-    image: ankane/pgvector
-    restart: always
-    shm_size: 128mb
-    ports:
-      - "5432:5432"
-    environment:
-      POSTGRES_USER: user
-      POSTGRES_PASSWORD: password
-      POSTGRES_DB: semantic_router
-    volumes:
-      - postgres_data:/var/lib/pgvector/data
-
-volumes:
-  postgres_data:
-    driver: local
-
-  
\ No newline at end of file
diff --git a/docs/indexes/postgres/postgres.compose.yaml b/docs/indexes/postgres/postgres.compose.yaml
new file mode 100644
index 00000000..e69de29b
diff --git a/docs/indexes/postgres.ipynb b/docs/indexes/postgres/postgres.ipynb
similarity index 78%
rename from docs/indexes/postgres.ipynb
rename to docs/indexes/postgres/postgres.ipynb
index 401cb37f..c0de3ddf 100644
--- a/docs/indexes/postgres.ipynb
+++ b/docs/indexes/postgres/postgres.ipynb
@@ -1,11 +1,36 @@
 {
  "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Postgres pgvector index example\n",
+    "\n",
+    "**Note**: You'll require docker to be installed locally, or a remote instance of Postgres with the pgvector extension installed."
+   ]
+  },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 11,
    "metadata": {},
-   "outputs": [],
-   "source": []
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "/Users/frankjames/Projects/semantic-router/docs/indexes/postgres\n",
+      "\u001b[1A\u001b[1B\u001b[0G\u001b[?25l[+] Running 0/0\n",
+      " \u001b[33m⠋\u001b[0m Container pgvector  Starting                                            \u001b[34m0.1s \u001b[0m\n",
+      "\u001b[?25h\u001b[1A\u001b[1A\u001b[0G\u001b[?25l\u001b[34m[+] Running 1/1\u001b[0m\n",
+      " \u001b[32m✔\u001b[0m Container pgvector  \u001b[32mStarted\u001b[0m                                             \u001b[34m0.1s \u001b[0m\n",
+      "\u001b[?25h"
+     ]
+    }
+   ],
+   "source": [
+    "!echo \"Running docker compose to start postgres instance with pgvector extension\"\n",
+    "!docker compose -f ./postgres.compose.yaml up --detach"
+   ]
   },
   {
    "cell_type": "code",
@@ -67,11 +92,13 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "from semantic_router.index.postgres import PostgresIndex    \n",
+    "from semantic_router.index.postgres import PostgresIndex\n",
     "import os\n",
     "\n",
-    "os.environ[\"POSTGRES_CONNECTION_STRING\"] = \"postgresql://user:password@localhost:5432/semantic_router\"\n",
-    "postgres_index = PostgresIndex()\n"
+    "os.environ[\"POSTGRES_CONNECTION_STRING\"] = (\n",
+    "    \"postgresql://user:password@localhost:5432/semantic_router\"\n",
+    ")\n",
+    "postgres_index = PostgresIndex()"
    ]
   },
   {
-- 
GitLab