Nexai AI Semantic Search

Github Repository ->

Nexai AI Semantic Search is the fastest in browser semantic search available today.

The AI Semantic Search is available as a React Component based on ShadCN (Tailwind UI Components) that is fully customizable.

It searches your document knowledgebase with search phrases, keywords, important points, summaries, chat simulations and question/answer pairs generated by the Nexai AI. It then links each fulltext search to semantic information in the relevant webpage or document.

AI Search

Quick -> What is AI semantic search?

Semantic search performs searches on the meaning of the query
Fulltext search which performs searches on matching keywords.

For example

With the semantic search query: Where are the instructions to use this?

Will return the following results:

  • How to create an account on Nexai
  • How to embed the Nexai Chatbot onto my website
  • How can I install Nexai Chat Bubble
  • Quick Start - Get Started

etc...

Since the meaning (semantic distance) are close.

It will return no results for a fulltext search based on keywords since none of the keywords exist in the results.

Quick -> How it works

Nexai AI search performs search operations in the browser! This ensures the fastest (live search) while you type.

To achieve this we use FlexSearch which is the fastest full text search available.

I thought this was AI semantic search, not old school fulltext search?

We achieve semantic search on top of fulltext search by predicting fulltext search phrases and linking them to semantic queries. So a fulltext search will query semantic searches which then link to relevant documents. With a large enough corpus of fulltext search keywords we effectively produce semantic results ahead of time.

The size of this fulltext index on top of semantic queries is rather small compared to the size of the documents while retaining approximately 80% of semantic context maps.

Semantic search with an AI predicted fulltext index achieves relevant semantic results immediately (under 50ms) close to 80% of the time. The other 20% of the time will forward to the AI which will improve the semantic cache.

Our approach is the fastest semantic search available in the browser today.

Get your Nexai Project API Key

Login, create a project and get your api key for that project.

https://nexai.site/dashboard/projects

Each project has a unique API Key. This key can be visible on your website and is not a secret.

AI Search React Component Installation

For existing projects install the nexai.js library

npm install --save nexai.js
# optional - install if you do not have react, mobx and tailwind
npm install --save react react-dom mobx mobx-react-lite tailwindcss

For new projects or full customization

You can clone the Nexai.js git repository to fully customize the component.

The AI Search React Component UI is built with the Command Component from ShadCN UI.

AISearchShadowDom and AISearch are equivalent. With AISearchShadowDom all dependencies are included but it is not configurable. If you use AISearch directly and do not have ShadCN installed follow the install docs at ShadCN Installation

AI Search Basic Usage

typescript
copy code
"use client"
// use AISearch if you use tailwind
// AISearchShadowDom embeds AISearch and tailwind into a shadow dom
import { AISearchShadowDom, type NavItem } from 'nexai.js/ai-search'
export const NexaiSearch = () => {
// replace with your API Key
const nexaiApiKey = String(process.env.NEXT_PUBLIC_NEXAI_API_KEY)
const onMenuItemReadMore = (menuItem: NavItem, group: NavItem) => {
if (typeof window !== 'undefined') {
window.location.href = String(group.href)
}
}
return (
<AISearchShadowDom
nexaiApiKey={nexaiApiKey}
onMenuItemReadMore={onMenuItemReadMore}
className='h-15'
placeholder='AI Search... '
style={{
width: 250
}}
/>
)
}

Ensure the domain of the project matches the domain you embed the AI Search into.

UI customization

Clone Nexai.js git repository.

git clone https://github.com/nexai-cloud/nexai.js
cd nexai.js
npm i

This installs the Nexai.js library which includes nexai.js/ai-search.

Look at src/App.ts which imports nexai.js/ai-search. Then look at src/components/ui/command-menu.tsx which is the full UI of the AI Search React Component. Copy src/components/ui/command-menu.tsx to your App and customize.

You will need tailwindcss, react, react-dom, mobx and mobx-react-lite in your app.

For ShadCN install follow the install docs at ShadCN Installation

You are good to go!

For customization you the Nexai AI Chat Assistant React Library