Skip to content

Commit af034be

Browse files
Merge pull request #40 from looker-open-source/feat-extension-revamp
feat: big rework; prompt additions, backend change
2 parents d3a30d0 + 96150d7 commit af034be

38 files changed

+1892
-1948
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ SLACK_CLIENT_SECRET=YOUR_SLACK_CLIENT_SECRET
33
GOOGLE_CLIENT_ID=YOUR_GOOGLE_CLIENT_ID
44
CHANNEL_ID=YOUR_SLACK_CHANNEL_ID
55
SPACE_ID=YOUR_GOOGLE_SPACE_ID
6-
WEBSOCKET_SERVICE=YOUR_CLOUD_RUN_URL
6+
RESTFUL_WEBSERVICE=YOUR_DASHBOARD_SUMMARY_BACKEND
7+
GENAI_CLIENT_SECRET=YOUR_CLIENT_SECRET_TO_SECURE_BACKEND

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Changelog
2+
## v2.0
3+
4+
### Added
5+
- Summary Styles; custom prompts with different styles for different personas like: executives, analysts, etc.
6+
- Ability to regenerate query summaries with different prompts
7+
- UI/UX modified with styled components
8+
9+
### Changed
10+
- Changed Websocket service to RESTful service, so that backend endpoints can be secured OR private backend can be implemented
11+
- Synchronous calls for tile summaries changed to async and run in parallel
12+
- Backend secured with Looker server (user attribute + Cloud Secret)
13+
14+
## v1.1
15+
###
16+
- Refine option for shortening dashboard summary
17+
18+
## v1.0
19+
20+
### Added
21+
- Dashboard summarization a la Vertex AI
22+
- Websocket backend hosted on Cloud Run
23+
- Export options to Slack and GChat

README.md

Lines changed: 29 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is an extension or plugin for Looker that integrates LLM's hosted on Vertex AI into a streaming dashboard summarization experience powered by Websockets.
44

5-
![explore assistant](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExbzRrZ200dnB3YWg1Y3AwazVjdm44ZWx3dWZjZ2NtcGVieWZuY3VmNiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/kIXodRHInpIds8KPvC/giphy.gif)
5+
![dashboard-summary](./src/assets/dashboard-summary-new.gif)
66

77
## Description
88

@@ -19,12 +19,10 @@ Additionally, the extension provides:
1919

2020
- Google Chat Export (*Oauth integration to export the summary to Google Chat*)
2121
- Slack Export (*Oauth integration to export the summary to Slack in rich text*)
22+
- Custom Summary Prompts (Ability to provide specific guidance for summary generation)
23+
- Summary Regeneration (Regenerate summaries with different styles or focuses)
24+
- Queries run with user context
2225

23-
Upcoming capabilities on the roadmap:
24-
25-
- Next Steps to Visualization
26-
- Google Slides Integration
27-
- Regenerate and Refine (*regenerate summary with custom input prompt*)
2826

2927
### Technologies Used
3028
#### Frontend
@@ -40,7 +38,6 @@ Upcoming capabilities on the roadmap:
4038
- [Google Cloud Platform](https://cloud.google.com/)
4139
- [Vertex AI](https://cloud.google.com/vertex-ai)
4240
- [Cloud Run](https://cloud.google.com/run?hl=en)
43-
- [Websockets](https://socket.io)
4441

4542
#### Export API's
4643
- [Slack](https://api.slack.com/authentication/oauth-v2)
@@ -49,11 +46,11 @@ Upcoming capabilities on the roadmap:
4946

5047
## Setup
5148

52-
![simple-architecture](./src/assets/dashboard-summarization-architecture.png)
49+
![simple-architecture](./src/assets/dashboard-summary-architecture.png)
5350

54-
### 1. Generative AI & Websocket Server
51+
### 1. REST API Server
5552

56-
This section describes how to set up the web server on Cloud Run powering the Generative AI and Websocket integrations
53+
This section describes how to set up the API server on Cloud Run powering the Generative AI integrations.
5754

5855
#### Getting Started for Local Development
5956

@@ -67,7 +64,7 @@ This section describes how to set up the web server on Cloud Run powering the Ge
6764
2. Navigate (`cd`) to the template directory on your system
6865

6966
```bash
70-
cd dashboard-summarization/websocket-service/src
67+
cd dashboard-summarization/restful-service/src
7168
```
7269

7370
3. Install the dependencies with [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
@@ -78,20 +75,7 @@ This section describes how to set up the web server on Cloud Run powering the Ge
7875

7976
> You may need to update your Node version or use a [Node version manager](https://github.com/nvm-sh/nvm) to change your Node version.
8077
81-
4. Update `looker-example.ini` to `looker.ini` and replace environment variables Admin API Credentials. **IMPORTANT** use a section header that matches the host of your Looker instance. Example below:
82-
83-
Ex: Looker instance -> https://mycompany.cloud.looker.com
84-
```
85-
[mycompany]
86-
base_url=<Your Looker instance URL>
87-
client_id=<From your looker user's api credentials>
88-
client_secret=<From your looker user's api credentials>
89-
verify_ssl=true
90-
```
91-
92-
This is configured to support deployment to multiple Looker instances reusing the same backend.
93-
94-
5. Start the development server
78+
4. Start the development server
9579

9680
```bash
9781
npm run start
@@ -107,47 +91,35 @@ This is configured to support deployment to multiple Looker instances reusing th
10791

10892
2. Navigate to template directory
10993
```bash
110-
cd dashboard-summarization/websocket-service/src
94+
cd dashboard-summarization/restful-service/src
11195
```
11296

113-
3. Update `looker-example.ini` to `looker.ini` and replace environment variables Admin API Credentials. **IMPORTANT** use a section header that matches the host of your Looker instance. Example below:
114-
115-
Ex: Looker instance -> https://mycompany.cloud.looker.com
116-
```
117-
[mycompany]
118-
base_url=<Your Looker instance URL>
119-
client_id=<From your looker user's api credentials>
120-
client_secret=<From your looker user's api credentials>
121-
verify_ssl=true
122-
```
123-
124-
This is configured to support deployment to multiple Looker instances reusing the same backend.
125-
126-
4. Update cloudbuild.yaml
97+
3. Update cloudbuild.yaml
12798
```
12899
<YOUR_REGION> = Your deployment region
129100
<YOUR_PROJECT_ID> = Your GCP project ID
130101
```
131102

132-
5. Build Docker File and Submit to Artifact Registry, replacing the `REGION` variable with your deployment region.
103+
4. Build Docker File and Submit to Artifact Registry, replacing the `REGION` variable with your deployment region.
133104
*Skip this step if you already have a deployed image.* Please see the [official docs](https://cloud.google.com/build/docs/configuring-builds/create-basic-configuration) for creating the yaml file.
134105
```bash
135106
gcloud auth login && gcloud auth application-default login && gcloud builds submit --region=REGION --config cloudbuild.yaml
136107
```
137108
Save the returned docker image url. You can also get the docker image url from the Artifact Registry
138109

139-
6. Navigate (`cd`) to the terraform directory on your system
110+
5. Navigate (`cd`) to the terraform directory on your system
140111
```bash
141112
cd .. && cd terraform
142113
```
143-
7. Replace defaults in the `variables.tf` file for project, region, docker url and service name.
114+
6. Replace defaults in the `variables.tf` file for project, region, docker url and service name.
144115
```
145116
project_id=<GCP project ID>
146117
deployment_region=<Your deployement region>
147118
docker_image=<The docker image url from step 5>
119+
genai_client_secret_value=<secret used to secure endpoints for public service>
148120
```
149121

150-
8. Deploy resources. [*Ensure Application Default Credentials for GCP for Exported in your Environment first.*](https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp)
122+
7. Deploy resources. [*Ensure Application Default Credentials for GCP for Exported in your Environment first.*](https://cloud.google.com/docs/authentication/provide-credentials-adc#google-idp)
151123

152124
```terraform
153125
terraform init
@@ -157,7 +129,7 @@ This is configured to support deployment to multiple Looker instances reusing th
157129
terraform apply
158130
```
159131

160-
9. Save Deployed Cloud Run URL Endpoint
132+
8. Save Deployed Cloud Run URL Endpoint
161133

162134
#### Optional: Setup Log Sink to BQ for LLM Cost Estimation and Request Logging
163135

@@ -166,7 +138,7 @@ estimate and monitor costs. Please see [Google Cloud's docs](https://cloud.googl
166138

167139
```
168140
resource.type = "cloud_run_revision"
169-
resource.labels.service_name = "websocket-service"
141+
resource.labels.service_name = "dashboard-summarization-service"
170142
resource.labels.location = "us-central1"
171143
severity>=DEFAULT
172144
jsonPayload.component="dashboard-summarization-logs"
@@ -188,13 +160,14 @@ jsonPayload.component="dashboard-summarization-logs"
188160
2. Navigate (`cd`) to the root directory in the cloned repo
189161

190162
3. Ensure All the Appropriate Environment Variables are set. Copy .env.example file and save as .env
191-
*See Export Integration Steps below for Slack and Gchat Variables. These are optional, except WEBSOCKET_SERVICE*
163+
*See Export Integration Steps below for Slack and Gchat Variables. These are optional, except RESTFUL_SERVICE & GENAI_CLIENT_SECRET*. To Note, the GenAI Client Secret will be used as an environment variable only in development. When you deploy the extension to production, you'll need to save it as a user attribute in Looker with a specific format. This is so that the secret is secured and not evaluated client side. More instructions on this in the `Deployment` instructions further down.
192164
```
193165
SLACK_CLIENT_ID=
194166
SLACK_CLIENT_SECRET=
195167
CHANNEL_ID=
196168
SPACE_ID=
197-
WEBSOCKET_SERVICE=<Required: Cloud run endpoint url>
169+
RESTFUL_SERVICE=<Required: Cloud run endpoint url>
170+
GENAI_CLIENT_SECRET=<same secret value used to secure Cloud Run service>
198171
```
199172

200173
4. Install the dependencies with [NPM](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
@@ -215,7 +188,7 @@ WEBSOCKET_SERVICE=<Required: Cloud run endpoint url>
215188
npm run develop
216189
```
217190

218-
Great! Your extension is now running and serving the JavaScript at http://localhost:8080/bundle.js.
191+
Great! Your extension is now running and serving the JavaScript at https://localhost:3000/dashboard_summarization.js.
219192

220193
6. Now log in to Looker and create a new project.
221194

@@ -233,8 +206,8 @@ WEBSOCKET_SERVICE=<Required: Cloud run endpoint url>
233206

234207
application: dashboard-summarization {
235208
label: "Dashboard Insights Powered by Vertex AI"
236-
# file: "bundle.js"
237-
url: "http://localhost:8080/bundle.js"
209+
# file: "dashboard_summarization.js"
210+
url: "https://localhost:3000/dashboard_summarization.js"
238211
mount_points: {
239212
dashboard_vis: yes
240213
dashboard_tile: yes
@@ -243,7 +216,7 @@ WEBSOCKET_SERVICE=<Required: Cloud run endpoint url>
243216
entitlements: {
244217
local_storage: yes
245218
use_form_submit: yes
246-
core_api_methods: ["run_inline_query","all_lookml_models","dashboard","dashboard_dashboard_elements"]
219+
core_api_methods: ["run_inline_query","run_query","all_lookml_models","dashboard","dashboard_dashboard_elements"]
247220
external_api_urls: [
248221
"YOUR CLOUD RUN URL","http://localhost:5000","http://localhost:3000","https://*.googleapis.com","https://slack.com/api/*","https://slack.com/*"
249222
]
@@ -259,6 +232,7 @@ WEBSOCKET_SERVICE=<Required: Cloud run endpoint url>
259232
"https://www.googleapis.com/auth/chat.messages.create",
260233
"https://slack.com/oauth/v2/authorize"
261234
]
235+
scoped_user_attributes:["genai_client_secret"]
262236
}
263237
}
264238

@@ -275,7 +249,7 @@ WEBSOCKET_SERVICE=<Required: Cloud run endpoint url>
275249
9. Commit your changes and deploy your them to production through the Project UI.
276250

277251
10. Reload the page and click the `Browse` dropdown menu. You should see your extension in the list.
278-
- The extension will load the JavaScript from the `url` provided in the `application` definition. By default, this is https://localhost:8080/bundle.js. If you change the port your server runs on in the package.json, you will need to also update it in the manifest.lkml.
252+
- The extension will load the JavaScript from the `url` provided in the `application` definition. By default, this is https://localhost:3000/dashboard_summarization.js. If you change the port your server runs on in the package.json, you will need to also update it in the manifest.lkml.
279253

280254
- Refreshing the extension page will bring in any new code changes from the extension template, although some changes will hot reload.
281255

@@ -286,7 +260,8 @@ The process above requires your local development server to be running to load t
286260

287261
1. In your extension project directory on your development machine, build the extension by running the command `npm run build`.
288262
2. Drag and drop the generated JavaScript file(bundle.js) contained in the `dist` directory into the Looker project interface.
289-
3. Modify your `manifest.lkml` to use `file` instead of `url` and point it at the `bundle.js` file.
263+
3. Modify your `manifest.lkml` to use `file` instead of `url` and point it at the `dashboard_summarization.js` file.
264+
4. [IMPORTANT] Create a User Attribute in Looker following this naming convention `<extension_id>_genai_client_secret`. Note any dash or :: in the extension_id name will need to be replaced with an underscore. Typically the extension id will be your lookml project name where the extension lives followed by the name of the extension ie. `dashboard-summarization`. See [the docs](https://cloud.google.com/looker/docs/extension-framework-react-and-js-code-examples#user_attributes) for more details
290265

291266
Note that the additional JavaScript files generated during the production build process do not have to be mentioned in the manifest. These files will be loaded dynamically by the extension as and when they are needed. Note that to utilize code splitting, the Looker server must be at version 7.21 or above.
292267

manifest.lkml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project_name: "dashboard-summarization"
33

44
application: dashboard-summarization {
55
label: "Dashboard Insights Powered by Vertex AI"
6-
url: "http://localhost:8080/bundle.js"
6+
url: "https://localhost:3000/dashboard_summarization.js"
77
mount_points: {
88
dashboard_vis: yes
99
dashboard_tile: yes
@@ -12,7 +12,7 @@ application: dashboard-summarization {
1212
entitlements: {
1313
local_storage: yes
1414
use_form_submit: yes
15-
core_api_methods: ["me","run_inline_query","all_lookml_models","dashboard","dashboard_dashboard_elements"]
15+
core_api_methods: ["me","run_inline_query","run_query","all_lookml_models","dashboard","dashboard_dashboard_elements"]
1616
external_api_urls: [
1717
"YOUR_CLOUD_RUN_URL","http://localhost:5000","http://localhost:3000","https://*.googleapis.com","https://slack.com/api/*","https://slack.com/*"
1818
]
@@ -28,7 +28,7 @@ application: dashboard-summarization {
2828
"https://www.googleapis.com/auth/chat.messages.create",
2929
"https://slack.com/oauth/v2/authorize"
3030
]
31-
scoped_user_attributes: []
31+
scoped_user_attributes: ["genai_client_secret"]
3232
global_user_attributes: []
3333
}
3434
}

0 commit comments

Comments
 (0)