diff --git a/.github/workflows/update-trieve.yml b/.github/workflows/update-trieve.yml new file mode 100644 index 000000000..f9483b1fd --- /dev/null +++ b/.github/workflows/update-trieve.yml @@ -0,0 +1,28 @@ +name: Update Trieve + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref }} + cancel-in-progress: true + +on: + push: + branches: + - main + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Trieve Fern Adapter + run: npm install -g trieve-fern-adapter + + - name: Update Trieve Chunks + env: + TRIEVE_API_HOST: ${{ secrets.TRIEVE_API_HOST }} + TRIEVE_API_KEY: ${{ secrets.TRIEVE_API_KEY }} + TRIEVE_ORGANIZATION_ID: ${{ secrets.TRIEVE_ORGANIZATION_ID }} + TRIEVE_DATASET_TRACKING_ID: ${{ secrets.TRIEVE_DATASET_TRACKING_ID }} + run: trieve-fern-adapter --file fern/docs.yml -s https://api.vapi.ai/api-json -r https://docs.vapi.ai -a api-reference diff --git a/.gitignore b/.gitignore index fe38d4938..4ef4bd851 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ **/.definition **/.preview/** +.env diff --git a/fern/assets/trieve-user-script.js b/fern/assets/trieve-user-script.js new file mode 100644 index 000000000..568ec8c5b --- /dev/null +++ b/fern/assets/trieve-user-script.js @@ -0,0 +1,94 @@ +// ==UserScript== +// @name Vapi +// @namespace http://tampermonkey.net/ +// @version 2025-01-16 +// @description try to take over the world! +// @author You +// @match https://docs.vapi.ai/* +// @icon https://www.google.com/s2/favicons?sz=64&domain=vapi.ai +// @grant none +// ==/UserScript== + +const removeAllClickListeners = (element) => { + const newElement = element.cloneNode(true); + element.parentNode.replaceChild(newElement, element); + return newElement; +}; + +const makeDefaultSearchTrieve = async () => { + let defaultSearchBar = null; + let retries = 0; + while (!defaultSearchBar && retries < 10) { + for (const el of document.querySelectorAll("*")) { + if (el.querySelector('[aria-label="Search"]')) { + defaultSearchBar = el.querySelector('[aria-label="Search"]'); + break; + } + } + retries++; + await new Promise((resolve) => setTimeout(resolve, 10)); + } + defaultSearchBar = removeAllClickListeners(defaultSearchBar); + + defaultSearchBar.onclick = () => { + const event = new CustomEvent("trieve-open-with-text", { + detail: { text: "" }, + }); + window.dispatchEvent(event); + }; +}; +await makeDefaultSearchTrieve(); +setTimeout(makeDefaultSearchTrieve, 50); +setTimeout(makeDefaultSearchTrieve, 100); +setTimeout(makeDefaultSearchTrieve, 250); +setTimeout(makeDefaultSearchTrieve, 500); +setTimeout(makeDefaultSearchTrieve, 1000); +setTimeout(makeDefaultSearchTrieve, 2000); +setTimeout(makeDefaultSearchTrieve, 3000); + +(async function () { + "use strict"; + const link = document.createElement("link"); + link.rel = "stylesheet"; + link.href = "https://cdn.trieve.ai/beta/search-component/index.css"; + document.head.appendChild(link); + + import("https://cdn.trieve.ai/beta/search-component/vanilla/index.js").then( + async (module) => { + const { renderToDiv } = module; + const root = document.createElement("div"); + root.classList.add("trigger"); + document.body.appendChild(root); + const colorScheme = document.documentElement?.style?.colorScheme; + const brandColor = colorScheme === "dark" ? "#47ffb6d5" : "#00551dcd"; + + renderToDiv(root, { + apiKey: "tr-hZMKSsTf3ML9hJbAAqPO8K91p9IVe9Oc", + datasetId: "d3493dc0-2b5c-4c6e-a8ee-b18feeed5b06", + baseUrl: "https://api.trieve.ai", + type: "docs", + analytics: true, + theme: colorScheme === "dark" ? "dark" : null, + brandLogoImgSrcUrl: + "https://storage.googleapis.com/organization-image-assets/vapi-botAvatarDarkSrcUrl-1709929110474.png", + brandName: "Vapi", + brandColor: brandColor, + placeholder: "How can I help?", + defaultSearchQueries: ["quickstart", "assistant", "tools"], + defaultAiQuestions: [ + "What voices are supported?", + "What languages are supported?", + "How do I connect a custom LLM?", + "How do I fetch the prompt dynamically?", + ], + defaultSearchMode: "search", + showFloatingButton: "true", + cssRelease: "none", + hideOpenButton: true, + }); + }, + (error) => { + console.error("Failed to load module:", error); + } + ); +})(); diff --git a/fern/docs.yml b/fern/docs.yml index 1db9d0f24..70f8fa37e 100644 --- a/fern/docs.yml +++ b/fern/docs.yml @@ -38,6 +38,7 @@ landing-page: css: assets/styles.css js: - path: ./assets/close-playground.js + - path: ./assets/trieve-user-script.js strategy: lazyOnload navbar-links: - type: minimal