From fe14a2dfb88fcd8468fe0ac13aa53ed1a381962e Mon Sep 17 00:00:00 2001 From: Marvin Arnold Date: Wed, 11 Oct 2023 10:21:25 -0500 Subject: [PATCH 1/2] docs: first time run --- README.md | 8 ++++++++ .../googlecloud/functions/getanswer/README.md | 8 ++++---- packages/web/README.md | 16 ++++++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e7b3ab91..47689661 100644 --- a/README.md +++ b/README.md @@ -29,5 +29,13 @@ curl -XPOST http://localhost:8080 -v -H "Content-Type: application/json" \ ## Project structure - `packages/backend`: Preprocessor, only needs to be run once + - [Embeddings creation](https://github.com/eye-on-surveillance/sawt/blob/3f9a17bdd6ee3f0ffe1a454a332f9d4d6f28086e/packages/backend/src/preprocessor.py#L21) + - [Sample tuning params](https://github.com/eye-on-surveillance/sawt/blob/3f9a17bdd6ee3f0ffe1a454a332f9d4d6f28086e/packages/backend/src/preprocessor.py#L77) - `packages/googlecloud`: Google Cloud Function invoked for every query + - [Entry point](https://github.com/eye-on-surveillance/sawt/blob/3f9a17bdd6ee3f0ffe1a454a332f9d4d6f28086e/packages/googlecloud/functions/getanswer/main.py#L20) + - [K gets set](https://github.com/eye-on-surveillance/sawt/blob/3f9a17bdd6ee3f0ffe1a454a332f9d4d6f28086e/packages/googlecloud/functions/getanswer/inquirer.py#L188) + - [Construct response, all stored to DB](https://github.com/eye-on-surveillance/sawt/blob/3f9a17bdd6ee3f0ffe1a454a332f9d4d6f28086e/packages/googlecloud/functions/getanswer/inquirer.py#L108) + - [Deployment logic](https://github.com/eye-on-surveillance/sawt/blob/3f9a17bdd6ee3f0ffe1a454a332f9d4d6f28086e/.github/workflows/main.yml) - `packages/web`: NextJS web site + - [DB migrations](https://github.com/eye-on-surveillance/sawt/tree/3f9a17bdd6ee3f0ffe1a454a332f9d4d6f28086e/packages/web/supabase/migrations) + - [Homepage](https://github.com/eye-on-surveillance/sawt/blob/3f9a17bdd6ee3f0ffe1a454a332f9d4d6f28086e/packages/web/app/page.tsx) diff --git a/packages/googlecloud/functions/getanswer/README.md b/packages/googlecloud/functions/getanswer/README.md index 754df9fb..c8695cd5 100644 --- a/packages/googlecloud/functions/getanswer/README.md +++ b/packages/googlecloud/functions/getanswer/README.md @@ -7,6 +7,7 @@ python3.10 getanswer ``` ## Running locally + [Docs](https://cloud.google.com/functions/docs/running/function-frameworks) ``` @@ -43,9 +44,8 @@ gcloud functions deploy getanswer-staging \ gcloud functions describe highlight-to-nft --gen2 --region us-east1 --format="value(serviceConfig.uri)" -curl -XPOST hhttps://getanswer-q5odwl64qa-ue.a.run.app \ - -H "Content-Type: application/json" \ - -d '{"question":"Outline concerns raised during the meeting? What were the responses to those concerns?","response_type":"general"}' +curl -XPOST https://us-east1-the-great-inquirer.cloudfunctions.net/getanswer-staging -v -H "Content-Type: application/json" \ + -d '{"query":"Is councilmember Green effective?","response_type":"in_depth"}' ``` response_types = 'general' or 'in_depth' @@ -58,4 +58,4 @@ import openai import os key = os.environ.get("OPENAI_API_KEY").replace("'", "") openai.api_key = key -``` \ No newline at end of file +``` diff --git a/packages/web/README.md b/packages/web/README.md index 5b0a83e5..a5ddc54e 100644 --- a/packages/web/README.md +++ b/packages/web/README.md @@ -8,8 +8,8 @@ Create a `.env.local` like this: # If running functions locally NEXT_PUBLIC_TGI_API_ENDPOINT=http://localhost:8080 -# Run against production -NEXT_PUBLIC_TGI_API_ENDPOINT=https://getanswer-q5odwl64qa-ue.a.run.app +# Run against staging +NEXT_PUBLIC_TGI_API_ENDPOINT=https://us-east1-the-great-inquirer.cloudfunctions.net/getanswer-staging # All environments NEXT_PUBLIC_SUPABASE_URL=your-supabase-url @@ -25,3 +25,15 @@ yarn dev # or pnpm dev ``` + +### Supabase migrations + +The first time you setup a new Supabase project, migrations must be applied. + +``` +supabase login +supabase link --project-ref $PROJECT_ID +supabase db push +``` + +To make changes to the schema moving forward, you can update the DB directly from Supabase DB. When ready, run `supabase db remote commit`. You will need to have Docker running locally for this to succeed. When complete, there will be a new file in `supabase/migrations` with a name like `20230821153353_remote_commit.sql`. Commit this file to source control and it will automatically be applied to the DB when merged. From ddfd02e68c0ba83552c4e22a49d0632da8b23e86 Mon Sep 17 00:00:00 2001 From: Marvin Arnold Date: Wed, 11 Oct 2023 15:03:02 -0500 Subject: [PATCH 2/2] docs: add seq diagram --- docs/seq.md | 10 ++++++++ docs/seq.svg | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 docs/seq.md create mode 100644 docs/seq.svg diff --git a/docs/seq.md b/docs/seq.md new file mode 100644 index 00000000..9c68fe72 --- /dev/null +++ b/docs/seq.md @@ -0,0 +1,10 @@ +seqdiag { +User-Browser -> Vercel-NextJS [label = "GET SITE JS"]; +User-Browser <-- Vercel-NextJS +User-Browser -> Supabase [label = "GET CARD DATA"]; +User-Browser <-- Supabase +User-Browser -> Google-Cloud-Function [label = "SUBMIT QUESTION"] +User-Browser <-- Google-Cloud-Function +User-Browser -> Supabase [label = "SUBMIT NEW CARD"]; +User-Browser <-- Supabase +} diff --git a/docs/seq.svg b/docs/seq.svg new file mode 100644 index 00000000..85c0ce41 --- /dev/null +++ b/docs/seq.svg @@ -0,0 +1,67 @@ + + + + + + + + + blockdiag + seqdiag { + User-Browser -> Vercel-NextJS [label = "GET REACT SITE"]; + User-Browser <-- Vercel-NextJS + User-Browser -> Supabase [label = "GET CARD DATA"]; + User-Browser <-- Supabase + User-Browser -> Google-Cloud-Function [label = "ASK QUESTION"] + User-Browser <-- Google-Cloud-Function + User-Browser -> Supabase [label = "SAVE NEW CARD"]; + User-Browser <-- Supabase +} + + + + + + + + + + + + + + + + + + + + User-Browser + + Vercel-NextJS + + Supabase + + Google-Cloud-Functio + n + + + + + + + + + + + + + + + + + GET REACT SITE + GET CARD DATA + ASK QUESTION + SAVE NEW CARD +