Skip to content

Commit ebdbd7c

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

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-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: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
while (!defaultSearchBar) {
21+
for (const el of document.querySelectorAll('*')) {
22+
if (el.querySelector('[aria-label="Search"]')) {
23+
defaultSearchBar = el.querySelector('[aria-label="Search"]');
24+
break;
25+
}
26+
};
27+
await new Promise((resolve) => setTimeout(resolve, 10));
28+
}
29+
defaultSearchBar = removeAllClickListeners(defaultSearchBar);
30+
31+
defaultSearchBar.onclick = () => {
32+
const event = new CustomEvent("trieve-open-with-text", { detail: { text: "" } });
33+
window.dispatchEvent(event);
34+
}
35+
};
36+
makeDefaultSearchTrieve();
37+
setTimeout(makeDefaultSearchTrieve, 50);
38+
setTimeout(makeDefaultSearchTrieve, 100);
39+
setTimeout(makeDefaultSearchTrieve, 200);
40+
setTimeout(makeDefaultSearchTrieve, 400);
41+
setTimeout(makeDefaultSearchTrieve, 900);
42+
setTimeout(makeDefaultSearchTrieve, 1800);
43+
44+
(async function () {
45+
"use strict";
46+
const link = document.createElement("link");
47+
link.rel = "stylesheet";
48+
link.href = "https://cdn.trieve.ai/beta/search-component/index.css";
49+
document.head.appendChild(link);
50+
51+
import("https://cdn.trieve.ai/beta/search-component/vanilla/index.js").then(
52+
async (module) => {
53+
const { renderToDiv } = module;
54+
const root = document.createElement("div");
55+
root.classList.add("trigger");
56+
document.body.appendChild(root);
57+
58+
renderToDiv(root, {
59+
apiKey: "tr-hZMKSsTf3ML9hJbAAqPO8K91p9IVe9Oc",
60+
datasetId: "d3493dc0-2b5c-4c6e-a8ee-b18feeed5b06",
61+
baseUrl: "https://api.trieve.ai",
62+
type: "docs",
63+
analytics: true,
64+
theme: "dark",
65+
brandLogoImgSrcUrl: "https://storage.googleapis.com/organization-image-assets/vapi-botAvatarDarkSrcUrl-1709929110474.png",
66+
brandName: "Vapi",
67+
brandColor: "#94ffd2",
68+
placeholder: "How can I help?",
69+
defaultSearchQueries: ["quickstart", "assistant", "tools"],
70+
defaultAiQuestions: ["What voices are supported?", "What languages are supported?", "How do I connect a custom LLM?", "How do I fetch the prompt dynamically?"],
71+
defaultSearchMode: "search",
72+
showFloatingButton: "true",
73+
cssRelease: "none",
74+
hideOpenButton: true,
75+
});
76+
},
77+
(error) => {
78+
console.error("Failed to load module:", error);
79+
}
80+
);
81+
})();

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)