Skip to content

Commit d326da7

Browse files
egolsxlijin
andauthored
feat: implement ai assistant for docs (#2189)
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Implements an AI assistant for documentation with a chatbot and search interface, including backend query handling and frontend components. > > - **Backend**: > - Adds `query.ts` and `rag.ts` in `sage-backend` for handling AI queries and document retrieval. > - Implements middleware in `middleware.ts` for CORS handling. > - Configures Next.js with `next.config.ts` and sets up `package.json` dependencies. > - Adds `generate-sitemap.ts` for sitemap generation and `test-slugs.ts` for testing URL slugs. > - **Frontend**: > - Implements `ChatBot.tsx` and `AlgoliaSearch.tsx` in `sage-client` for AI chat and search interface. > - Configures Webpack in `webpack.config.js` for building the chatbot. > - Adds styling in `globals.css` and utility functions in `utils.ts`. > - Sets up `components.json` for component configuration. > - **Misc**: > - Removes `fern-check.yml` and `preview-docs.yml` workflows. > - Updates `publish-docs.yml` to include new build steps. > - Adds `postcss.config.mjs` for Tailwind CSS configuration. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for bc79e27. You can [customize](https://app.ellipsis.dev/BoundaryML/settings/summaries) this summary. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN --> --------- Co-authored-by: Sam Lijin <[email protected]>
1 parent 9633d1e commit d326da7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+10472
-604
lines changed

.github/workflows/fern-check.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/preview-docs.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/publish-docs.yml

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,106 @@
11
name: Publish Docs
22

3+
concurrency:
4+
# No suffix specified - in reusable workflows we need a statically-defined suffix
5+
# to prevent workflow_call workflows from triggering a concurrency deadlock
6+
group: ${{ github.workflow }}-${{ github.ref }}
7+
cancel-in-progress: true
8+
39
on:
10+
pull_request:
411
push:
512
branches:
613
- canary
714

815
jobs:
9-
run:
16+
docs:
1017
runs-on: ubuntu-latest
18+
permissions: write-all
1119
steps:
1220
- name: Checkout repository
1321
uses: actions/checkout@v4
1422

23+
- name: Setup Node.js and pnpm
24+
uses: ./.github/actions/setup-node
25+
with:
26+
install-dependencies: false
27+
1528
- name: Install Fern
1629
run: npm install -g fern-api
1730

18-
- name: Publish Docs
31+
- name: Install dependencies and build custom.js
32+
working-directory: ./typescript/apps/sage-client
33+
run: pnpm install && pnpm run build
34+
35+
- name: Generate preview URL
36+
id: generate-docs
1937
env:
2038
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
21-
run: fern generate --docs
39+
run: |
40+
fern check --strict-broken-links
41+
if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/canary" ]; then
42+
OUTPUT=$(fern generate --docs 2>&1) || true
43+
else
44+
OUTPUT=$(fern generate --docs --preview 2>&1) || true
45+
fi
46+
echo "$OUTPUT"
47+
URL=$(echo "$OUTPUT" | grep -oP 'Published docs to \K.*(?= \()')
48+
echo "🌿 Preview your docs: $URL" | tee preview_url.txt
49+
50+
- name: Comment URL in PR
51+
if: github.event_name == 'pull_request'
52+
uses: thollander/[email protected]
53+
with:
54+
file-path: preview_url.txt
55+
56+
backend:
57+
runs-on: ubuntu-latest
58+
permissions: write-all
59+
defaults:
60+
run:
61+
working-directory: ../sage-backend
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v4
65+
66+
- name: Setup Node.js and pnpm
67+
uses: ./.github/actions/setup-node
68+
with:
69+
install-dependencies: false
70+
71+
- name: Install Fern
72+
working-directory: .
73+
run: npm install -g fern-api
74+
75+
- name: Pull sage-backend out of monorepo
76+
working-directory: ./typescript
77+
run: pnpm --filter=sage-backend deploy ../sage-backend
78+
79+
- name: Install dependencies and build
80+
run: pnpm install && pnpm baml-cli generate
81+
82+
- name: Build Vercel project
83+
env:
84+
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
85+
run: |
86+
pnpm vercel pull --yes --token=${{ secrets.VERCEL_TOKEN_SAM }}
87+
pnpm vercel build --token=${{ secrets.VERCEL_TOKEN_SAM }}
88+
89+
- name: Deploy preview backend
90+
env:
91+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
92+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_SAGE_BACKEND }}
93+
run: |
94+
(
95+
if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/canary" ]; then
96+
pnpm vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN_SAM }}
97+
else
98+
pnpm vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN_SAM }}
99+
fi
100+
) | tee preview_url.txt
101+
102+
- name: Comment URL in PR
103+
if: github.event_name == 'pull_request'
104+
uses: thollander/[email protected]
105+
with:
106+
file-path: ../sage-backend/preview_url.txt

.github/workflows/release-cli.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Release BAML CLI
22

33
on:
44
release:
5-
types: [published, unpublished, created, edited, prereleased, drafted]
5+
types: [published, unpublished, created, edited, prereleased]
66

77
jobs:
88
build-cli:

fern/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
custom.js
2+
custom.js.LICENSE.txt

fern/8c8c5181a9e58d2e1e70.svg

Lines changed: 71 additions & 0 deletions
Loading

fern/assets/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ body#fern-docs #fern-header .md\:h-\(--header-height-real\) {
323323
body#fern-docs .fern-sidebar-link[data-state="active"] span {
324324
color: var(--accent-primary) !important;
325325
font-weight: 600 !important;
326+
font-family: var(--font-geist-sans);
326327
}
327328

328329
body#fern-docs #fern-sidebar {

0 commit comments

Comments
 (0)