-
Notifications
You must be signed in to change notification settings - Fork 497
Chatbot frontend for Anserini API #2695
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3560f6c
docs: remove dropbox link
b8zhong b74a9dc
feat: initial anserini api chat
b8zhong 66f3741
Merge branch 'castorini:master' into vercel-frontend
b8zhong b5dcb2c
revert unecessary doc changes
b8zhong fa2bfbf
revert unecessary doc changes
b8zhong 59a9b8a
Update package.json and pnpm-lock.yaml, add .env.example
b8zhong 98b3044
docs: remove boilerplate
b8zhong e4ca3b8
feat: working instant refresh of IR chat, but non-working 4o/ai model…
b8zhong cfa7c0c
feat: seperate into two components for search and chat
b8zhong f751e1e
uhhh weird behaviour
b8zhong 96ce888
remove gpt-4o dependency on title
b8zhong 4aef89e
add note on non-dependencies on vercel variables
b8zhong 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
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,22 @@ | ||
{ | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"plugin:import/recommended", | ||
"plugin:import/typescript", | ||
"prettier", | ||
"plugin:tailwindcss/recommended" | ||
], | ||
"plugins": ["tailwindcss"], | ||
"rules": { | ||
"tailwindcss/no-custom-classname": "off", | ||
"tailwindcss/classnames-order": "off" | ||
}, | ||
"settings": { | ||
"import/resolver": { | ||
"typescript": { | ||
"alwaysTryTypes": true | ||
} | ||
} | ||
}, | ||
"ignorePatterns": ["**/components/ui/**"] | ||
} |
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,25 @@ | ||
name: Lint | ||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
node-version: [20] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v4 | ||
with: | ||
version: 9 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'pnpm' | ||
- name: Install dependencies | ||
run: pnpm install | ||
- name: Run lint | ||
run: pnpm lint |
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,38 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
.pnp | ||
.pnp.js | ||
|
||
# testing | ||
coverage | ||
|
||
# next.js | ||
.next/ | ||
out/ | ||
build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
# turbo | ||
.turbo | ||
|
||
.env | ||
.vercel | ||
.vscode | ||
.env*.local |
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,13 @@ | ||
Copyright 2024 Vercel, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
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,109 @@ | ||
# AI-Powered Search Interface | ||
|
||
A modern web application that provides a chat-like interface for interacting with various search indexes through Anserini's search API, built on top of Vercel's ([AI Chatbot Template](https://github.com/vercel/ai-chatbot)). | ||
|
||
## Features | ||
|
||
### Search Models | ||
- **MS MARCO Collection** | ||
- Base Indexes (V1/V2) | ||
- Neural Encodings: | ||
- SPLADE++ CoCondenser-EnsembleDistil | ||
- cos-DPR Distil (HNSW & quantized INT8) | ||
- BGE-base-en-v1.5 (HNSW & quantized INT8) | ||
- Cohere embed-english-v3.0 (HNSW & quantized INT8) | ||
- **BEIR Collections** | ||
- Multiple collections (TREC-COVID, BioASQ, etc.) | ||
- Index types: Flat, Multifield, SPLADE++, BGE | ||
- **CACM Collection** | ||
- Classic IR test collection | ||
|
||
### Chat Interface | ||
- Conversational interaction with search results | ||
- Real-time streaming responses | ||
- Support for both search and chat models | ||
- Message history and chat persistence | ||
|
||
## Architecture | ||
|
||
### Core Components | ||
- Next.js 13+ with App Router | ||
- TypeScript for type safety | ||
- Vercel AI SDK for streaming | ||
- Server-side API routes for search functionality | ||
|
||
### Search Integration | ||
- Direct integration with Anserini's Java backend APIs | ||
- Support for multiple index types: | ||
- Traditional Lucene indexes | ||
- Neural HNSW indexes | ||
- Quantized (INT8) indexes | ||
- Impact indexes (SPLADE++) | ||
|
||
### Data Flow | ||
1. User sends query through chat interface | ||
2. Query is processed by appropriate model | ||
3. For search models: | ||
- Query is sent to Anserini backend | ||
- Results are formatted and streamed back | ||
4. For chat models: | ||
- Interaction is handled by chat API | ||
- Responses are streamed in real-time | ||
|
||
## Running locally | ||
|
||
You will need to use the environment variables [defined in `.env.example`](.env.example) to run the application. It's recommended you use [Vercel Environment Variables](https://vercel.com/docs/projects/environment-variables) for this, but a `.env` file is all that is necessary. | ||
|
||
> Note: You should not commit your `.env` file or it will expose secrets that will allow others to control access to your various OpenAI and authentication provider accounts. | ||
|
||
1. Install Vercel CLI: `npm i -g vercel` | ||
2. Link local instance with Vercel and GitHub accounts (creates `.vercel` directory): `vercel link` | ||
3. Download your environment variables: `vercel env pull` | ||
|
||
Then install dependencies and start the development server: | ||
|
||
```bash | ||
pnpm install | ||
pnpm tsx lib/db/migrate.ts && pnpm run build | ||
pnpm dev | ||
``` | ||
|
||
Your app should now be running on [localhost:3000](http://localhost:3000/). | ||
|
||
## Configuration | ||
|
||
### Anserini Server | ||
The application expects an Anserini server running at the configured host/port with the following settings: | ||
```json | ||
{ | ||
"host": "localhost", | ||
"port": 8081, | ||
"apiVersion": "v1.0" | ||
} | ||
``` | ||
|
||
### Available Models | ||
Models are configured in `lib/ai/models.ts` and include: | ||
- Chat models for query assistance | ||
- Search models for different collections and encodings | ||
|
||
## Deploy Your Own | ||
|
||
You can deploy your own version of the application to Vercel with one click: | ||
|
||
[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fai-chatbot&env=AUTH_SECRET,OPENAI_API_KEY&envDescription=Learn%20more%20about%20how%20to%20get%20the%20API%20Keys%20for%20the%20application&envLink=https%3A%2F%2Fgithub.com%2Fvercel%2Fai-chatbot%2Fblob%2Fmain%2F.env.example&demo-title=AI%20Chatbot&demo-description=An%20Open-Source%20AI%20Chatbot%20Template%20Built%20With%20Next.js%20and%20the%20AI%20SDK%20by%20Vercel.&demo-url=https%3A%2F%2Fchat.vercel.ai&stores=[{%22type%22:%22postgres%22},{%22type%22:%22blob%22}]) | ||
|
||
## API Integration | ||
|
||
See `API_INTEGRATION.md` for detailed information about integrating with the Anserini backend and available endpoints. | ||
|
||
## Development | ||
|
||
The application uses a modern React stack with: | ||
- Next.js App Router for routing | ||
- Server Components for improved performance | ||
- Streaming for real-time updates | ||
- TypeScript for type safety | ||
- [shadcn/ui](https://ui.shadcn.com) with Tailwind CSS | ||
- [Vercel Postgres](https://vercel.com/storage/postgres) for data persistence | ||
- [NextAuth.js](https://github.com/nextauthjs/next-auth) for authentication |
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.