Skip to content

Commit

Permalink
Merge branch 'experiments' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
caugner committed Dec 13, 2023
2 parents 63094ce + ae1044d commit c91b2ee
Show file tree
Hide file tree
Showing 93 changed files with 4,319 additions and 852 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/prod-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ jobs:
if: ${{ ! vars.SKIP_BUILD }}
run: |-
gsutil -q -m -h "Cache-Control: public, max-age=3600" cp -r client/build/static gs://${{ vars.GCP_BUCKET_NAME }}/main/
gsutil -q -m -h "Cache-Control: public, max-age=3600" rsync -cdrj html,json,txt -y "^static/" client/build gs://${{ vars.GCP_BUCKET_NAME }}/main
gsutil -q -m -h "Cache-Control: public, max-age=3600" rsync -cdrj html,json,txt -y "^static/|/plain.html$" client/build gs://${{ vars.GCP_BUCKET_NAME }}/main
- name: Authenticate with GCP
if: ${{ ! vars.SKIP_FUNCTION }}
Expand Down Expand Up @@ -349,7 +349,7 @@ jobs:
--min-instances=10 \
--max-instances=1000 \
--memory=2GB \
--timeout=60s \
--timeout=120s \
--set-env-vars="ORIGIN_MAIN=developer.mozilla.org" \
--set-env-vars="ORIGIN_LIVE_SAMPLES=live.mdnplay.dev" \
--set-env-vars="ORIGIN_PLAY=mdnplay.dev" \
Expand Down Expand Up @@ -380,6 +380,13 @@ jobs:
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}

- name: Update AI Help index with macros
run: yarn ai-help-macros update-index
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}

- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@v2
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/stage-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ jobs:
if: ${{ ! vars.SKIP_BUILD }}
run: |-
gsutil -q -m -h "Cache-Control: public, max-age=3600" cp -r client/build/static gs://${{ vars.GCP_BUCKET_NAME }}/main/
gsutil -q -m -h "Cache-Control: public, max-age=3600" rsync -cdrj html,json,txt -y "^static/" client/build gs://${{ vars.GCP_BUCKET_NAME }}/main
gsutil -q -m -h "Cache-Control: public, max-age=3600" rsync -cdrj html,json,txt -y "^static/|/plain.html$" client/build gs://${{ vars.GCP_BUCKET_NAME }}/main
- name: Authenticate with GCP
if: ${{ ! vars.SKIP_FUNCTION }}
Expand Down Expand Up @@ -342,7 +342,7 @@ jobs:
--min-instances=1 \
--max-instances=100 \
--memory=2GB \
--timeout=60s \
--timeout=120s \
--set-env-vars="ORIGIN_MAIN=developer.allizom.org" \
--set-env-vars="ORIGIN_LIVE_SAMPLES=live.mdnyalp.dev" \
--set-env-vars="ORIGIN_PLAY=mdnyalp.dev" \
Expand Down Expand Up @@ -373,6 +373,13 @@ jobs:
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}

- name: Update AI Help index with macros
run: yarn ai-help-macros update-index
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}

- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/xyz-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ jobs:
--min-instances=1 \
--max-instances=100 \
--memory=2GB \
--timeout=60s \
--timeout=120s \
--set-env-vars="ORIGIN_MAIN=developer.allizom.xyz" \
--set-env-vars="ORIGIN_LIVE_SAMPLES=live-samples.developer.allizom.xyz" \
--set-env-vars="SOURCE_CONTENT=https://storage.googleapis.com/${{ vars.GCP_BUCKET_NAME }}/main/" \
Expand Down
12 changes: 10 additions & 2 deletions build/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ async function buildDocumentInteractive(
);
}

return { document, doc: await buildDocument(document), skip: false };
return {
document,
doc: await buildDocument(document, { plainHTML: true }),
skip: false,
};
} catch (e) {
if (!interactive) {
throw e;
Expand Down Expand Up @@ -208,7 +212,7 @@ async function buildDocuments(
}

const {
doc: { doc: builtDocument, liveSamples, fileAttachmentMap },
doc: { doc: builtDocument, liveSamples, fileAttachmentMap, plainHTML },
document,
} = result;

Expand All @@ -230,6 +234,10 @@ async function buildDocuments(
);
}

if (plainHTML) {
fs.writeFileSync(path.join(outPath, "plain.html"), plainHTML);
}

// This is exploiting the fact that renderHTML has the side-effect of
// mutating the built document which makes this not great and refactor-worthy.
const docString = JSON.stringify({ doc: builtDocument });
Expand Down
10 changes: 9 additions & 1 deletion build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@ export interface BuiltDocument {
source?: {
github_url: string;
};
plainHTML?: string;
}

interface DocumentOptions {
fixFlaws?: boolean;
fixFlawsDryRun?: boolean;
fixFlawsTypes?: Iterable<string>;
fixFlawsVerbose?: boolean;
plainHTML?: boolean;
}

export async function buildDocument(
Expand Down Expand Up @@ -445,6 +447,12 @@ export async function buildDocument(
throw error;
}

// Dump HTML for GPT context
let plainHTML;
if (documentOptions.plainHTML) {
plainHTML = $.html();
}

// Apply syntax highlighting all <pre> tags.
syntaxHighlight($, doc);

Expand Down Expand Up @@ -555,7 +563,7 @@ export async function buildDocument(
document.metadata.slug.startsWith("orphaned/") ||
document.metadata.slug.startsWith("conflicting/");

return { doc: doc as Doc, liveSamples, fileAttachmentMap };
return { doc: doc as Doc, liveSamples, fileAttachmentMap, plainHTML };
}

function addBaseline(doc: Partial<Doc>) {
Expand Down
4 changes: 2 additions & 2 deletions build/resolve-bcd.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import bcdUntyped from "@mdn/browser-compat-data/forLegacyNode";
import { CompatData } from "@mdn/browser-compat-data/types";
import { CompatData, Identifier } from "@mdn/browser-compat-data/types";

const bcd = bcdUntyped as CompatData;

export function packageBCD(query) {
const data = query.split(".").reduce((prev, curr) => {
const data: Identifier = query.split(".").reduce((prev, curr) => {
return prev && Object.prototype.hasOwnProperty.call(prev, curr)
? prev[curr]
: undefined;
Expand Down
2 changes: 1 addition & 1 deletion build/syntax-highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function syntaxHighlight($: cheerio.CheerioAPI, doc) {
$pre.wrapAll(`<div class='code-example'></div>`);
if (!$pre.hasClass("hidden")) {
$(
`<p class='example-header'><span class="language-name">${name}</span></p>`
`<div class='example-header'><span class="language-name">${name}</span></div>`
).insertBefore($pre);
}
const grammar = Prism.languages[name];
Expand Down
Binary file added client/public/assets/ai-help/ai-help_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/public/assets/ai-help/ai-help_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/public/assets/ai-help/context.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/public/assets/ai-help/gpt-4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/public/assets/ai-help/history.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions client/public/assets/ai-help/lightbulb-question.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed client/public/assets/plus-docs/ai-help/context.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed client/public/assets/plus-docs/ai-help/sources.png
Binary file not shown.
1 change: 1 addition & 0 deletions client/src/assets/icons/ai-help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions client/src/assets/icons/bell-ring.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions client/src/assets/icons/edit-filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions client/src/assets/icons/highlight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions client/src/assets/icons/history.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions client/src/assets/icons/message.svg
3 changes: 3 additions & 0 deletions client/src/assets/icons/new-topic.svg
Loading

0 comments on commit c91b2ee

Please sign in to comment.