Skip to content

Commit 7cca008

Browse files
Merge pull request #1 from bytecodeio/make-it-smarter-more-context-bytecode
Make it smarter more context bytecode
2 parents a2d83f8 + 0b7a5cc commit 7cca008

File tree

11 files changed

+255
-264
lines changed

11 files changed

+255
-264
lines changed

Diff for: .DS_Store

8 KB
Binary file not shown.

Diff for: explore-assistant-backend/README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ Here we list the reasons and tradeoffs of each deployment approach in an effort
2323
* The endpoint needs to be public for Looker to reach it (*To Note: the repo implements a signature on the request for security. Otherwise putting the endpoint behind a Load Balancer or API Proxy is recommended. Keep in mind that Looker Extensions however, when not embedded are only accessible by authenticated Looker users.*)
2424

2525
**For BigQuery**:
26+
* The BigQuery backend is a prototype backend. The cloud function backend will provide better performance
2627
* Generally speaking, this approach will be easier for users already familiar with Looker
27-
* Invoking the LLM with custom prompts is all done through SQL.
28+
* Invoking the LLM with custom prompts is all done through SQL
2829
* BigQuery's Service Account or User Oauth Authentication can be used
2930
* BigQuery however will serve as a pass through to the Vertex API
3031
* Looker & BigQuery query limits will apply to this approach
@@ -42,8 +43,8 @@ We are using terraform to setup the backend. By default, we will store the state
4243
To use the remote backend you can run `./init.sh remote` instead of `terraform init`. This will create the bucket in the project, and setup the terraform project to use it as a backend.
4344

4445
### Cloud Function Backend
45-
46-
First create a file that will contain the LOOKER_AUTH_TOKEN and place it at the root. This will be used by the cloud function locally, as well as the extension framework app. The value of this token will uploaded to the GCP project as secret to be used by the Cloud Function.
46+
* The Cloud Function backend is a production backend and will provide better performance
47+
* First create a file that will contain the LOOKER_AUTH_TOKEN and place it at the root. This will be used by the cloud function locally, as well as the extension framework app. The value of this token will uploaded to the GCP project as secret to be used by the Cloud Function.
4748

4849
If in the `/explore-assistant-backend` cd back to root (ie. `cd ..`) and run the following command:
4950
```bash
@@ -53,7 +54,7 @@ openssl rand -base64 32 > .vertex_cf_auth_token
5354

5455
From the `/explore-assistant-backend` directory run the following.
5556

56-
To deploy the Cloud Function backend:
57+
To deploy the Cloud Function backend (Production):
5758

5859
```bash
5960
cd terraform
@@ -68,7 +69,7 @@ terraform apply
6869

6970
### BigQuery Backend
7071

71-
To deploy the BigQuery backend:
72+
To deploy the BigQuery backend (Prototype):
7273

7374
```bash
7475
cd terraform

Diff for: explore-assistant-backend/terraform/bigquery/main.tf

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ resource "google_project_iam_member" "bigquery_connection_remote_model" {
2424
member = format("serviceAccount:%s", google_bigquery_connection.connection.cloud_resource[0].service_account_id)
2525
}
2626

27+
resource "time_sleep" "wait_after_iam_assignment" {
28+
depends_on = [ google_project_iam_member.bigquery_connection_remote_model ]
29+
create_duration = "120s"
30+
}
31+
2732
resource "google_bigquery_job" "create_bq_model_llm" {
2833
job_id = "create_looker_llm_model-${formatdate("YYYYMMDDhhmmss", timestamp())}"
2934
query {
@@ -42,7 +47,7 @@ EOF
4247
}
4348

4449
location = var.deployment_region
45-
50+
depends_on = [ google_project_iam_member.bigquery_connection_remote_model, time_sleep.wait_after_iam_assignment ]
4651
lifecycle {
4752
ignore_changes = [query, job_id]
4853
}

Diff for: explore-assistant-examples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The script accepts several command line arguments to specify the details require
3030
- `--project_id`: **Required.** The Google Cloud project ID where your BigQuery dataset resides.
3131
- `--dataset_id`: The ID of the BigQuery dataset. Defaults to `explore_assistant`.
3232
- `--table_id`: The ID of the BigQuery table where the data will be inserted. Defaults to `explore_assistant_examples`.
33-
- `--explore_id`: **Required.** A unique identifier for the dataset rows related to a specific use case or query (used in deletion and insertion).
33+
- `--explore_id`: **Required.** A unique identifier formatted as `{lookml_model_name}:{explore_name}` for the dataset rows related to a specific use case or query (used in deletion and insertion).
3434
- `--json_file`: The path to the JSON file containing the data to be loaded. Defaults to `examples.json`.
3535

3636
### Running the Script

Diff for: explore-assistant-extension/.DS_Store

8 KB
Binary file not shown.

Diff for: explore-assistant-extension/src/.DS_Store

8 KB
Binary file not shown.

Diff for: explore-assistant-extension/src/components/Chat/SummaryMessage.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const SummaryMessage = ({ message, onSummaryComplete }: SummaryMessageProps) =>
1919
const { summarizeExplore } = useSendVertexMessage()
2020

2121
useEffect(() => {
22+
let isMounted = true
23+
2224
if (message.summary) {
2325
setSummary(message.summary)
2426
setLoading(false)
@@ -44,10 +46,16 @@ const SummaryMessage = ({ message, onSummaryComplete }: SummaryMessageProps) =>
4446
// call the parent component to scroll to the bottom
4547
onSummaryComplete()
4648

47-
setLoading(false)
49+
if (isMounted) {
50+
setLoading(false)
51+
}
4852
}
4953

5054
fetchSummary()
55+
56+
return () => {
57+
isMounted = false
58+
}
5159
}, [message])
5260

5361
return (

Diff for: explore-assistant-extension/src/documents/looker_filter_doc.md

+19-21
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,27 @@ For the following examples:
3737
* {interval} is a time increment such as hours, days, weeks, or months. The phrasing you use determines whether the {interval} will include partial time periods or only complete time periods. For example, the expression 3 days includes the current, partial day as well as the prior two days. The expression 3 days ago for 3 days includes the previous three complete days and excludes the current, partial day. See the Relative Dates section for more information.
3838
* {time} can specify a time formatted as either YYYY-MM-DD HH:MM:SS or YYYY/MM/DD HH:MM:SS, or a date formatted as either YYYY-MM-DD or YYYY/MM/DD. When using the form YYYY-MM-DD, be sure to include both digits for the month and day, for example, 2016-01. Truncating a month or day to a single digit is interpreted as an offset, not a date. For example, 2016-1 is interpreted as 2016 minus one year, or 2015.
3939

40-
* Dates should always have two digit month and day of month, so 2024-01-01 is correct while 2024-1-1 is incorrect.
41-
4240
These are all the possible combinations of date filters:
4341

44-
| Combination | Example | Notes |
45-
|--------------------------------------|---------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
46-
| this {interval} | this month | You can use this week, this month, this quarter, or this year. Note that this day isn't supported. If you want to get data from the current day, you can use today. |
47-
| {n} {interval} | 3 days | |
48-
| {n} {interval} ago | 3 days ago | |
49-
| {n} {interval} ago for {n} {interval}| 3 months ago for 2 days | |
50-
| before {n} {interval} ago | before 3 days ago | |
51-
| before {time} | before 2018-01-01 12:00:00 | before is not inclusive of the time you specify. The expression before 2018-01-01 will return data from all dates before 2018-01-01, but it won't return data from 2018-01-01. |
52-
| after {time} | after 2018-10-05 | after is inclusive of the time you specify. So, the expression after 2018-10-05 will return data from 2018-10-05 and all dates later than 2018-10-05. |
53-
| {time} to {time} | 2018-05-18 12:00:00 to 2018-05-18 14:00:00 | The initial time value is inclusive but the latter time value is not. So the expression 2018-05-18 12:00:00 to 2018-05-18 14:00:00 will return data with the time "2018-05-18 12:00:00" through "2018-05-18 13:59:59". |
54-
| this {interval} to {interval} | this year to second | The beginning of each interval is used. For example, the expression this year to second returns data from the beginning of the year the query is run through to the beginning of the second the query is run. |
55-
| {time} for {n} {interval} | 2018-01-01 12:00:00 for 3 days | |
56-
| today | today | |
57-
| yesterday | yesterday | |
58-
| tomorrow | tomorrow | |
59-
| {day of week} | Monday | Specifying a day of week with a Dimension Group Date field returns the most recent date that matches the specified day of week. For example, the expression Dimension Group Date matches (advanced) Monday returns the most recent Monday. You can also use {day of week} with the before and after keywords in this context. For example, the expression Dimension Group Date matches (advanced) after Monday returns the most recent Monday and everything after the most recent Monday. The expression Dimension Group Date matches (advanced) before Monday returns every day before the most recent Monday, but it doesn't return the most recent Monday. Specifying a day of the week with a Dimension Group Day of Week field returns every day that matches the specified day of week. So the expression Dimension Group Day of Week matches (advanced) Monday returns every Monday. |
60-
| next {week, month, quarter, fiscal quarter, year, fiscal year} | next week | The next keyword is unique in that it requires one of the intervals listed previously and won't work with other intervals. |
61-
| {n} {interval} from now | 3 days from now | |
62-
| {n} {interval} from now for {n} {interval}| 3 days from now for 2 weeks | |
42+
| Combination | Example | Notes |
43+
|-----------------------------------------------------|----------------------------------------------------|--------------------------------------------------------------|
44+
| this {interval} | this month | You can use this week, this month, this quarter, or this year. Note that this day isn't supported. If you want to get data from the current day, you can use today. |
45+
| {n} {interval} | 3 days | You can use a number combined with days, weeks, months, quarters or years. This will return the last number of days, weeks, months, quarters or years you specify in the combination. |
46+
| {n} {interval} ago | 3 days ago | You can use a number combined with days, weeks, months, quarters or years ago. This will return the day you specify in the combination. 3 days ago will return the date 3 days prior to the current date. |
47+
| {n} {interval} ago for {n} {interval} | 3 months ago for 2 days | You can use a number combined with days, weeks, months, quarters or years ago for the duration of a number you and interval you specify. This will return date range you specify in the combination. 3 months ago for 2 days will return the date for a range of 2 days 3 months prior to the current date. |
48+
| before {n} {interval} ago | before 3 days ago | You can use this combination to specify a number combined with days, weeks, months, quarters or years in the desired range before ending the date range. Before 3 days ago will return all dates before 3 days of the current date. |
49+
| before {time} | before 2018-01-01 12:00:00 | Before is not inclusive of the time you specify. The expression before 2018-01-01 will return data from all dates before 2018-01-01, but it won't return data from 2018-01-01. |
50+
| after {time} | after 2018-10-05 | After is inclusive of the time you specify. So, the expression after 2018-10-05 will return data from 2018-10-05 and all dates later than 2018-10-05. |
51+
| {time} to {time} | 2018-05-18 12:00:00 to 2018-05-18 14:00:00 | The initial time value is inclusive but the latter time value is not. So the expression 2018-05-18 12:00:00 to 2018-05-18 14:00:00 will return data with the time "2018-05-18 12:00:00" through "2018-05-18 13:59:59". |
52+
| this {interval} to {interval} | this year to second | The beginning of each interval is used. For example, the expression this year to second returns data from the beginning of the year the query is run through to the beginning of the second the query is run. this week to day returns data from the beginning of the week the query is run through to the beginning of the day the query is run. |
53+
| {time} for {n} {interval} | 2018-01-01 12:00:00 for 3 days | The initial time value is inclusive but the latter number and interval values are not. So the expression 2018-05-18 12:00:00 for 3 days will return data with the time "2018-01-01 12:00:00" through "2018-01-04 12:00:00". |
54+
| today | today | Returns todays date |
55+
| yesterday | yesterday | Returns yesterdays date |
56+
| tomorrow | tomorrow | Returns tomorrows date |
57+
| {day of week} | Monday | Specifying a day of week with a Dimension Group Date field returns the most recent date that matches the specified day of week. For example, the expression Dimension Group Date matches (advanced) Monday returns the most recent Monday. You can also use {day of week} with the before and after keywords in this context. For example, the expression Dimension Group Date matches (advanced) after Monday returns the most recent Monday and everything after the most recent Monday. The expression Dimension Group Date matches (advanced) before Monday returns every day before the most recent Monday, but it doesn't return the most recent Monday. Specifying a day of the week with a Dimension Group Day of Week field returns every day that matches the specified day of week. So the expression Dimension Group Day of Week matches (advanced) Monday returns every Monday. |
58+
| next {week, month, quarter, fiscal quarter, year, fiscal year} | next week | The next keyword is unique in that it requires one of the intervals listed previously and won't work with other intervals. |
59+
| {n} {interval} from now | 3 days from now | You can use a number combined with days, weeks, months, quarters or years from now. This will return a future date the number of days, weeks, months, quarters or years you specify in the combination. |
60+
| {n} {interval} from now for {n} {interval} | 3 days from now for 2 weeks | You can use a number combined with days, weeks, months, quarters or years from now for the duration of a number you and interval you specify. This will return a date range in the future you specify in the combination. 3 days ago for 2 weeks will return the dates for a range of 3 days 2 weeks ahead of the current date. |
6361

6462

6563
Date filters can also be combined together:

0 commit comments

Comments
 (0)