-
Notifications
You must be signed in to change notification settings - Fork 5
feat: add ai search in docs #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c07b94b
feat: add AI chat search interface with markdown rendering and UI com…
DarkPhoenix2704 0a0e55c
refactor: centralize analytics tracking with new useAnalytics hook an…
DarkPhoenix2704 7343b96
docs: add bar chart and line chart to dashboard widget types table
DarkPhoenix2704 0489139
feat: implement rate limiting for chat API with IP-based tracking and…
DarkPhoenix2704 7a317c8
feat: add error toast and configure OpenAI model via environment vari…
DarkPhoenix2704 e63a471
chore: resolve merge conflicts in pnpm-lock.yaml dependencies
DarkPhoenix2704 59a2919
refactor: redesign blog layout with new top navigation and card style
DarkPhoenix2704 f7832a0
feat: enhance blog page UI with gradient background and thumbnails fo…
DarkPhoenix2704 3114150
style: enhance blog layout with gradient background and improved typo…
DarkPhoenix2704 0582276
style: adjust blog post hero section padding for better spacing
DarkPhoenix2704 96c27d0
feat: update icon stroke color to currentColor and refine provideLink…
DarkPhoenix2704 2dba54c
refactor: redesign blog cards with grid layout and updated visual style
DarkPhoenix2704 672e9f8
feat: add support for multiple AI providers (OpenAI, Google, OpenRout…
DarkPhoenix2704 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# AI Model Configuration | ||
# Choose your provider: 'openai', 'google', or 'openrouter' | ||
AI_PROVIDER=openai | ||
|
||
# Specify the model ID for your chosen provider | ||
# Examples: | ||
# - OpenAI: gpt-4-turbo, gpt-4, gpt-3.5-turbo | ||
# - Google: gemini-1.5-pro, gemini-1.5-flash | ||
# - OpenRouter: openai/gpt-4-turbo, anthropic/claude-3.5-sonnet | ||
AI_MODEL=gpt-4.1-2025-04-14 | ||
|
||
# API Keys for each provider (only set the one you're using) | ||
OPENAI_API_KEY= | ||
GOOGLE_GENERATIVE_AI_API_KEY= | ||
OPENROUTER_API_KEY= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ProvideLinksToolSchema } from '@/lib/ai-tools/inkeep-qa-schema'; | ||
import { SearchDocsToolSchema, searchAndFetchDocs } from '@/lib/ai-tools/search-and-fetch'; | ||
import { convertToModelMessages, stepCountIs, streamText } from 'ai'; | ||
import { systemPrompt } from '@/lib/searchPrompt'; | ||
import { validateRateLimit } from '@/utils/rateLimit'; | ||
import { createModel } from '@/lib/ai-models'; | ||
|
||
|
||
export async function POST(req: Request) { | ||
const rateLimitError = validateRateLimit(req); | ||
if (rateLimitError) return rateLimitError; | ||
let reqJson; | ||
try { | ||
reqJson = await req.json(); | ||
} catch { | ||
return new Response('Invalid request', { status: 400 }); | ||
} | ||
|
||
const result = streamText({ | ||
model: createModel(), | ||
tools: { | ||
searchDocs: { | ||
description: 'Search the NocoDB documentation and retrieve full page content. After calling this, you MUST read the returned content and write a comprehensive answer for the user based on that content.', | ||
inputSchema: SearchDocsToolSchema, | ||
execute: async ({ query }: { query: string }) => { | ||
const { markdown, links } = await searchAndFetchDocs(query, 3); | ||
return { markdown, links }; | ||
}, | ||
}, | ||
provideLinks: { | ||
inputSchema: ProvideLinksToolSchema, | ||
}, | ||
}, | ||
system: systemPrompt, | ||
messages: convertToModelMessages(reqJson.messages, { | ||
ignoreIncompleteToolCalls: true, | ||
}), | ||
stopWhen: stepCountIs(10), | ||
}); | ||
|
||
return result.toUIMessageStreamResponse(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"aliases": { | ||
"uiDir": "./components/ui", | ||
"componentsDir": "./components", | ||
"blockDir": "./components", | ||
"cssDir": "./styles", | ||
"libDir": "./lib" | ||
}, | ||
"baseDir": "", | ||
"commands": {} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.