You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+86-36
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,15 @@ The basic workflow is
17
17
18
18
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)
19
19
20
+
## Summary
21
+
22
+
- Clone repo
23
+
- Setup Google Cloud
24
+
- Setup Firebase
25
+
- Install Redis
26
+
- Pyserver Venv setup
27
+
-
28
+
20
29
## Setup
21
30
22
31
Clone the repo to your local computer:
@@ -56,31 +65,65 @@ Set up gcloud SDK on your machine
56
65
-`gcloud config set project your-project-name`
57
66
-`gcloud auth configure-docker`
58
67
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
+
59
94
### .env
60
95
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.
62
97
63
98
#### express-server/.env
64
99
65
100
Encode your google credentials using the service account key you downloaded earlier by running the command `base64 -i ./google-credentials.json`
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=
84
127
```
85
128
86
129
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,
89
132
90
133
### Local Instance
91
134
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.
93
136
94
-
If you want to run a local version of the app that's not publically accessible:
137
+
To launch a local instance:
95
138
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.
100
142
101
143
#### Using docker locally (not recommended)
102
144
@@ -141,12 +183,13 @@ You can generate your data and view your reports using the Next client.
141
183
To do so:
142
184
143
185
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.
146
188
4. Optionally: You can click on the advanced settings for further customization.
147
189
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.
148
190
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.
149
191
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
150
193
151
194
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.
152
195
@@ -155,28 +198,35 @@ Note: The backend Express app does not save your API keys on the server. The Nex
155
198
You can submit your data directly to the Express API using whatever method you're comfortable with.
156
199
Note: You must have the Next client running to view your report. Otherwise, it will just generate the JSON data.
157
200
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:
159
202
160
203
```
161
204
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
+
}]
176
226
};
177
227
```
178
228
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.
180
230
181
231
The data field must contain an array of objects of the following type:
0 commit comments