Skip to content

Commit 09180f8

Browse files
zobeirhamidskeptrunedev
authored andcommitted
feat(discovery): add Trieve search and ask AI
1 parent 7d35300 commit 09180f8

File tree

4 files changed

+124
-0
lines changed

4 files changed

+124
-0
lines changed

.github/workflows/update-trieve.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Update Trieve
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.head_ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches:
10+
- main
11+
12+
jobs:
13+
run:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Install Trieve Fern Adapter
20+
run: npm install -g trieve-fern-adapter
21+
22+
- name: Update Trieve Chunks
23+
env:
24+
TRIEVE_API_HOST: ${{ secrets.TRIEVE_API_HOST }}
25+
TRIEVE_API_KEY: ${{ secrets.TRIEVE_API_KEY }}
26+
TRIEVE_ORGANIZATION_ID: ${{ secrets.TRIEVE_ORGANIZATION_ID }}
27+
TRIEVE_DATASET_TRACKING_ID: ${{ secrets.TRIEVE_DATASET_TRACKING_ID }}
28+
run: trieve-fern-adapter --file fern/docs.yml -s https://api.vapi.ai/api-json -r https://docs.vapi.ai -a api-reference

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
**/.definition
22
**/.preview/**
3+
.env

fern/assets/trieve-user-script.js

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// ==UserScript==
2+
// @name Vapi
3+
// @namespace http://tampermonkey.net/
4+
// @version 2025-01-16
5+
// @description try to take over the world!
6+
// @author You
7+
// @match https://docs.vapi.ai/*
8+
// @icon https://www.google.com/s2/favicons?sz=64&domain=vapi.ai
9+
// @grant none
10+
// ==/UserScript==
11+
12+
const removeAllClickListeners = (element) => {
13+
const newElement = element.cloneNode(true);
14+
element.parentNode.replaceChild(newElement, element);
15+
return newElement;
16+
};
17+
18+
const makeDefaultSearchTrieve = async () => {
19+
let defaultSearchBar = null;
20+
let retries = 0;
21+
while (!defaultSearchBar && retries < 10) {
22+
for (const el of document.querySelectorAll("*")) {
23+
if (el.querySelector('[aria-label="Search"]')) {
24+
defaultSearchBar = el.querySelector('[aria-label="Search"]');
25+
break;
26+
}
27+
}
28+
retries++;
29+
await new Promise((resolve) => setTimeout(resolve, 10));
30+
}
31+
defaultSearchBar = removeAllClickListeners(defaultSearchBar);
32+
33+
defaultSearchBar.onclick = () => {
34+
const event = new CustomEvent("trieve-open-with-text", {
35+
detail: { text: "" },
36+
});
37+
window.dispatchEvent(event);
38+
};
39+
};
40+
await makeDefaultSearchTrieve();
41+
setTimeout(makeDefaultSearchTrieve, 50);
42+
setTimeout(makeDefaultSearchTrieve, 100);
43+
setTimeout(makeDefaultSearchTrieve, 250);
44+
setTimeout(makeDefaultSearchTrieve, 500);
45+
setTimeout(makeDefaultSearchTrieve, 1000);
46+
setTimeout(makeDefaultSearchTrieve, 2000);
47+
setTimeout(makeDefaultSearchTrieve, 3000);
48+
49+
(async function () {
50+
"use strict";
51+
const link = document.createElement("link");
52+
link.rel = "stylesheet";
53+
link.href = "https://cdn.trieve.ai/beta/search-component/index.css";
54+
document.head.appendChild(link);
55+
56+
import("https://cdn.trieve.ai/beta/search-component/vanilla/index.js").then(
57+
async (module) => {
58+
const { renderToDiv } = module;
59+
const root = document.createElement("div");
60+
root.classList.add("trigger");
61+
document.body.appendChild(root);
62+
const colorScheme = document.documentElement?.style?.colorScheme;
63+
const brandColor = colorScheme === "dark" ? "#47ffb6d5" : "#00551dcd";
64+
65+
renderToDiv(root, {
66+
apiKey: "tr-hZMKSsTf3ML9hJbAAqPO8K91p9IVe9Oc",
67+
datasetId: "d3493dc0-2b5c-4c6e-a8ee-b18feeed5b06",
68+
baseUrl: "https://api.trieve.ai",
69+
type: "docs",
70+
analytics: true,
71+
theme: colorScheme === "dark" ? "dark" : null,
72+
brandLogoImgSrcUrl:
73+
"https://storage.googleapis.com/organization-image-assets/vapi-botAvatarDarkSrcUrl-1709929110474.png",
74+
brandName: "Vapi",
75+
brandColor: brandColor,
76+
placeholder: "How can I help?",
77+
defaultSearchQueries: ["quickstart", "assistant", "tools"],
78+
defaultAiQuestions: [
79+
"What voices are supported?",
80+
"What languages are supported?",
81+
"How do I connect a custom LLM?",
82+
"How do I fetch the prompt dynamically?",
83+
],
84+
defaultSearchMode: "search",
85+
showFloatingButton: "true",
86+
cssRelease: "none",
87+
hideOpenButton: true,
88+
});
89+
},
90+
(error) => {
91+
console.error("Failed to load module:", error);
92+
}
93+
);
94+
})();

fern/docs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ landing-page:
3838
css: assets/styles.css
3939
js:
4040
- path: ./assets/close-playground.js
41+
- path: ./assets/trieve-user-script.js
4142
strategy: lazyOnload
4243
navbar-links:
4344
- type: minimal

0 commit comments

Comments
 (0)