Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into AI/clean-names
Browse files Browse the repository at this point in the history
  • Loading branch information
ayyubibrahimi committed Oct 17, 2023
2 parents 4d7e6bc + ab94d32 commit ffa9f4f
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 6 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 10 additions & 0 deletions docs/seq.md
Original file line number Diff line number Diff line change
@@ -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
}
67 changes: 67 additions & 0 deletions docs/seq.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions packages/googlecloud/functions/getanswer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ python3.10 getanswer
```

## Running locally

[Docs](https://cloud.google.com/functions/docs/running/function-frameworks)

```
Expand Down Expand Up @@ -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'
Expand All @@ -58,4 +58,4 @@ import openai
import os
key = os.environ.get("OPENAI_API_KEY").replace("'", "")
openai.api_key = key
```
```
16 changes: 14 additions & 2 deletions packages/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

0 comments on commit ffa9f4f

Please sign in to comment.