Skip to content

Commit af66705

Browse files
authored
Merge pull request #66 from AIObjectives/brandon_updated-readme
updates to readme
2 parents 0f3e501 + 32a1c61 commit af66705

File tree

1 file changed

+86
-36
lines changed

1 file changed

+86
-36
lines changed

README.md

+86-36
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ The basic workflow is
1717

1818
If you want to use Talk to the City without any setup, you can go to our website at TBD and follow the instructions on [how to use T3C](#usage)
1919

20+
## Summary
21+
22+
- Clone repo
23+
- Setup Google Cloud
24+
- Setup Firebase
25+
- Install Redis
26+
- Pyserver Venv setup
27+
-
28+
2029
## Setup
2130

2231
Clone the repo to your local computer:
@@ -56,31 +65,65 @@ Set up gcloud SDK on your machine
5665
- `gcloud config set project your-project-name`
5766
- `gcloud auth configure-docker`
5867

68+
### Firebase
69+
70+
To use T3C, you'll need to create a Firebase project.
71+
72+
- Go to [Firebase console](https://firebase.google.com/)
73+
- In the Firebase Console, click "Create a project" or "Add project"
74+
- Enter a project name
75+
- Click "Create project"
76+
- Once your project is created, you'll need to register your app. In the project overview:
77+
- Click on web
78+
- Register app with a nickname
79+
- Copy the provided Firebase configuration object
80+
- Optional: we suggest adding it to `/express-server/configuration`. This folder not tracked by git, and will make it easier to import later.
81+
- TODO setup Auth and Firestore
82+
83+
### Redis
84+
85+
For local development, you can install Redis by following [these instructions](https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/). Make sure to start the Redis server on your computer if you want to run it locally.
86+
87+
### Pyserver setup
88+
89+
- Go to `/pyserver` and run: `python -m venv venv`
90+
- Run `source ./.venv/bin/activate` to run the virtual environment
91+
- Install the project requirements by running `pip install -r requirements.txt`
92+
- You can test to see if it worked by running `fastapi dev main.py` and see if the server spins up.
93+
5994
### .env
6095

61-
You will need to add two .env files
96+
You will need to add two .env files. You can find example env files at the root of next-client and express-server.
6297

6398
#### express-server/.env
6499

65100
Encode your google credentials using the service account key you downloaded earlier by running the command `base64 -i ./google-credentials.json`
66101

67102
```
68-
export GCLOUD_STORAGE_BUCKET=some-bucket-name
69-
export GOOGLE_CREDENTIALS_ENCODED=some-alphanumeric-string-from-previous-step
70-
export CLIENT_BASE_URL=http://wherever-your-client-is
71-
72-
# either
73-
export OPENAI_API_KEY=sk-something-something
74-
export OPENAI_API_KEY_PASSWORD=some-password
75-
# or
76-
export ANTHROPIC_API_KEY=sk-something-something
77-
export ANTHROPIC_API_KEY_PASSWORD=some-password
103+
export OPENAI_API_KEY=
104+
export GCLOUD_STORAGE_BUCKET= name of your bucket
105+
export CLIENT_BASE_URL= for dev: http://localhost:3000
106+
export GOOGLE_CREDENTIALS_ENCODED= base 64 encoding of your credentials
107+
export PYSERVER_URL= for dev: http://localhost:8000
108+
export FIREBASE_DATABASE_URL= found in your firebase project
109+
export REDIS_HOST= for dev: localhost
110+
export REDIS_PORT= for dev: 6379
111+
export GOOGLE_APPLICATION_CREDENTIALS= path to your credentials. Suggest using ./credentials
112+
export NODE_ENV= dev | prod
78113
```
79114

80115
#### next-client/.env
81116

82117
```
83-
export PIPELINE_EXPRESS_URL=http://wherever-youre-hosting-backend/generate
118+
119+
PIPELINE_EXPRESS_URL= # This is by default localhost:8080 on dev
120+
# Firebase keys below should be found on your firebase project. These are not sensitive and can be shared with the client.
121+
NEXT_PUBLIC_FIREBASE_API_KEY=
122+
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=
123+
NEXT_PUBLIC_FIREBASE_PROJECT_ID=
124+
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=
125+
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=
126+
NEXT_PUBLIC_FIREBASE_APP_ID=
84127
```
85128

86129
Copy this file to .env.local in the same directory if you plan to run the dev server (`npm run dev`).
@@ -89,14 +132,13 @@ You can add different types of .env files based on your needs for testing, dev,
89132

90133
### Local Instance
91134

92-
(see [this](./contributing.md) to run in dev mode instead of prod)
135+
Note: Before doing anything, there is a bug that prevents `/common` from being built correctly. For your first time, go to `/common` before anything else and run `npm i && npm run build`. After this, you should be able to follow the other steps. If the project fails to start in dev, try rebuilding common first.
93136

94-
If you want to run a local version of the app that's not publically accessible:
137+
To launch a local instance:
95138

96-
1. Open up your terminal and navigate to the repo folder (e.g. `/Desktop/tttc-light-js`)
97-
2. If this is your first time, build the repo: `cd commmon && npm run build`.
98-
3. Run `npm run dev` to start the dev server. This will run three servers in new terminal windows: the `next-client` frontend on `localhost:3000`, the `express-server` backend on `localhost:8080`, and the `pyserver` Python FastAPI server for the LLM calls on `localhost:8000`. A fourth terminal window will show a listener for `/common` that rebuilds the JS files when changes are made.
99-
4. This build will be optimized for production.
139+
- Make sure you have completed the setup steps
140+
- At `/`, run `npm run dev`.
141+
- This will run three servers: the `next-client` frontend on localhost:3000, the `express-server` backend on localhost:8080, and the `pyserver` Python FastAPI server for the LLM calls on localhost:8000. Additionally, a watcher will spawn that rebuilds common when changes are made to it.
100142

101143
#### Using docker locally (not recommended)
102144

@@ -141,12 +183,13 @@ You can generate your data and view your reports using the Next client.
141183
To do so:
142184

143185
1. Navigate to wherever your Next client is being hosted.
144-
2. On the homepage you should see a form to submit your data.
145-
3. Enter the title, your [api key](#api-key), and add the csv file.
186+
2. On the [hosting location]/create, you should see a form to submit your data.
187+
3. Enter the title, description, your [api key](#api-key), and add the csv file.
146188
4. Optionally: You can click on the advanced settings for further customization.
147189
5. Click submit. It should soon after give you the url for where your JSON data will be stored and the url to view the report.
148190
6. Depending on how large your file was, it should take anywhere from 30 seconds to 15 minutes to finish. So bookmark the link and check on it periodically.
149191
7. Once the JSON data has been uploaded to Google Cloud, you can view the report by going to` http://[client url]/report/[encoded uri for your stored JSON object]`. You can then save the report from your browser or add it to your webpage using an iframe.
192+
8. Additionally, if you are signed in, it will save a link to your report at /myReports
150193

151194
Note: The backend Express app does not save your API keys on the server. The Next app will save your API keys (and other inputs) in your browser's session storage, which should be secure, and will delete when you close your browser tab.
152195

@@ -155,28 +198,35 @@ Note: The backend Express app does not save your API keys on the server. The Nex
155198
You can submit your data directly to the Express API using whatever method you're comfortable with.
156199
Note: You must have the Next client running to view your report. Otherwise, it will just generate the JSON data.
157200

158-
The enpoint to generate reports is `POST /generate` and it expects a JSON body of the following type:
201+
The enpoint to generate reports is `POST /create` and it expects a JSON body of the following type:
159202

160203
```
161204
export type Options = {
162-
model?: optional;
163-
apiKey: string; // a valid OpenAI key with gpt-4 access (or a password to use the server's key)
164-
data: SourceRow[]; // input data in JSON format, see next section for SourceRow definition
165-
title: string; // title for the report, defaults to ""
166-
question: string; // the question asked to participants, defaults to ""
167-
pieCharts?: {title:string, items: {label:string, count:number}[]}[]; // optional array if you want pie charts in your report
168-
description: string; // intro or abstract to include at the start of the report, defaults to ""
169-
batchSize?: number; // max number of parrallel calls for gpt-4, defaults to 5
170-
filename?: string; // where to store the report on gcloud (it generate a name if none is provided)
171-
systemInstructions?: string; // optional additional instructions for system prompt
172-
clusteringInstructions?: string; // optional additional instructions for clustering step
173-
extractionInstructions?: string; // optional additional instructions for extraction step
174-
dedupInstructions?: string; // optional additional instructions for deduplication step
175-
googleSheet?: {url: string, pieChartColumns?:string[], filterEmails?: string[], onSubmissionPerEmail: boolean} // optional data input using google sheets
205+
userConfig: {
206+
apiKey: string,
207+
title: string,
208+
description: string,
209+
systemInstructions: string,
210+
clusteringInstructions: string,
211+
extractionInstructions: string,
212+
dedupInstructions: string,
213+
},
214+
data: ['csv', {
215+
comment: string,
216+
id: string,
217+
interview: string | undefined,
218+
video: string | undefined,
219+
timestamp: string | undefined,
220+
}[]] | ['googlesheet', {
221+
url: string,
222+
pieChartColumns: string[],
223+
filterEmails: string[],
224+
oneSubmissionPerEmail: boolean,
225+
}]
176226
};
177227
```
178228

179-
The enpoint is implemented in `express-pipeline/src/server.ts`. You can see an example of it being used in `next-client/src/features/actions/SubmitAction.ts` and in the `examples/` folder.
229+
The enpoint is implemented in `express-server/src/server.ts`. You can see an example of it being used in `next-client/src/features/actions/SubmitAction.ts` and in the `examples/` folder.
180230

181231
The data field must contain an array of objects of the following type:
182232

0 commit comments

Comments
 (0)