Skip to content

Commit

Permalink
feat: added deploy section in readme and doc (#188)
Browse files Browse the repository at this point in the history
refer: #183
  • Loading branch information
Cheese authored Jul 25, 2024
1 parent 741e842 commit 2db9710
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 20 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.idea
.env
.env

redis-data
venv
54 changes: 49 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- markdownlint-disable MD033 MD041 -->

<div align="center">
<h1>TiDB.AI</h1>
<a href='https://tidb.cloud/?utm_source=github&utm_medium=tidb.ai'>
Expand All @@ -6,34 +8,76 @@
</div>

## Introduction

A conversational search tool based on GraphRAG (Knowledge Graph) that built on top of [TiDB Vector](https://tidb.cloud/ai) and [LlamaIndex](https://github.com/run-llama/llama_index) and [DSPy](https://github.com/stanfordnlp/dspy).

* **Live Demo**: [TiDB.AI](https://tidb.cloud/?utm_source=github&utm_medium=tidb.ai)
* **Documentation**: [Docs](https://tidb.ai/docs/?utm_source=github&utm_medium=tidb.ai)
- **Live Demo**: [TiDB.AI](https://tidb.cloud/?utm_source=github&utm_medium=tidb.ai)
- **Documentation**: [Docs](https://tidb.ai/docs/?utm_source=github&utm_medium=tidb.ai)

## Features

1. **Perplexity-style Conversational Search page**: Our platform features an advanced built-in website crawler, designed to elevate your browsing experience. This crawler effortlessly navigates official and documentation sites, ensuring comprehensive coverage and streamlined search processes through sitemap URL scraping.

![out-of-box-conversational-search](https://github.com/pingcap/tidb.ai/assets/1237528/9cc87d32-14ac-47c6-b664-efa7ec53e751 "Image Title")
![out-of-box-conversational-search](https://github.com/pingcap/tidb.ai/assets/1237528/9cc87d32-14ac-47c6-b664-efa7ec53e751 "Image Title")

You can even edit the Knowledge Graph to add more information or correct any inaccuracies. This feature is particularly useful for enhancing the search experience and ensuring that the information provided is accurate and up-to-date.
You can even edit the Knowledge Graph to add more information or correct any inaccuracies. This feature is particularly useful for enhancing the search experience and ensuring that the information provided is accurate and up-to-date.

![out-of-box-conversational-search](https://github.com/pingcap/tidb.ai/assets/1237528/7bc57b34-99b7-4c4b-a098-9ad33dd0dfdc "Image Title")
![out-of-box-conversational-search](https://github.com/pingcap/tidb.ai/assets/1237528/7bc57b34-99b7-4c4b-a098-9ad33dd0dfdc "Image Title")

2. **Embeddable JavaScript Snippet**: Integrate our conversational search window effortlessly into your website by copying and embedding a simple JavaScript code snippet. This widget, typically placed at the bottom right corner of your site, facilitates instant responses to product-related queries.

![embeddable-javascript-snippet](https://github.com/pingcap/tidb.ai/assets/1237528/5a445231-a27a-4ae6-8287-a4f8cf7b64d0 "Image Title")

## Deploy

> **Prerequisites:**
>
> 1. Set up a [TiDB Serverless cluster](https://docs.pingcap.com/tidbcloud/tidb-cloud-quickstart).
> 2. Install [Docker Compose](https://docs.docker.com/compose/install/).
> 3. Install [Python 3.11](https://www.python.org/downloads/release/python-3110/).
> 4. Install [Rye](https://rye.astral.sh/guide/installation/).
1. Clone the repository:

```bash
git clone https://github.com/pingcap/tidb.ai.git
cd tidb.ai
```

2. Copy and edit the `.env` file in the `backend` directory:

```bash
cp ./backend/.env.example ./backend/.env
vim ./backend/.env # or use another text editor to edit this file
```

3. Migrate the database schema:

```bash
cd backend
rye sync
make migrate
cd ..
```

4. Start the services using Docker Compose:

```bash
docker compose up
```

## Tech Stack

- [TiDB](https://pingcap.com/ai/?utm_source=github&utm_medium=tidb.ai) – Database to store chat history, vector, json, and analytic
- [LlamaIndex](https://www.llamaindex.ai/) - RAG framework
- [DSPy](https://github.com/stanfordnlp/dspy) - The framework for programming—not prompting—foundation models
- [Next.js](https://nextjs.org/) – Framework
- [shadcn/ui](https://ui.shadcn.com/) - Design

## Contect Us

You can post topics on our [TiDB Community](https://ask.pingcap.com/) page.

## License

TiDB.AI is open-source under the Apache License, Version 2.0. You can [find it here](/LICENSE.txt).
19 changes: 11 additions & 8 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
DEBUG=true

SECRET_KEY=********************************

TIDB_DATABASE=test
TIDB_HOST=gateway01.eu-central-1.prod.aws.tidbcloud.com
TIDB_USER=*****.root
TIDB_HOST='gateway**.**-****-*.prod.aws.tidbcloud.com'
TIDB_USER='*****.root'
TIDB_PASSWORD=*******

OPENAI_API_KEY=sk-********
GOOGLE_API_KEY=*******
OPENAI_API_KEY=sk-********************************
# Optional
GOOGLE_API_KEY=********************************

LANGFUSE_SECRET_KEY=sk-*****
LANGFUSE_PUBLIC_KEY=pk-lf-*****
LANGFUSE_SECRET_KEY=sk-lf-********************************
LANGFUSE_PUBLIC_KEY=pk-lf-********************************
LANGFUSE_HOST=https://us.cloud.langfuse.com

CELERY_BROKER_URL=redis://127.0.0.1:6379/0
CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0
CELERY_BROKER_URL=redis://redis:6379/0
CELERY_RESULT_BACKEND=redis://redis:6379/0
3 changes: 3 additions & 0 deletions backend/requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# all-features: false
# with-sources: false
# generate-hashes: false
# universal: false

aiohttp==3.9.5
# via datasets
Expand All @@ -33,6 +34,8 @@ anyio==4.4.0
# via watchfiles
appdirs==1.4.4
# via ragas
appnope==0.1.4
# via ipykernel
argon2-cffi==23.1.0
# via pwdlib
argon2-cffi-bindings==21.2.0
Expand Down
1 change: 1 addition & 0 deletions backend/requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# all-features: false
# with-sources: false
# generate-hashes: false
# universal: false

aiohttp==3.9.5
# via datasets
Expand Down
17 changes: 11 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
name: tidb-ai

services:
redis:
image: redis:6.0.16
restart: always
volumes:
- ./redis-data:/data

backend:
image: tidb.ai/backend:local
build:
context: ./backend
restart: always
depends_on:
- redis
ports:
- "5000:80"
env_file:
Expand All @@ -22,6 +30,8 @@ services:
context: .
dockerfile: frontend/Dockerfile
restart: always
depends_on:
- backend
ports:
- 3000:3000
environment:
Expand All @@ -32,19 +42,14 @@ services:
max-size: "50m"
max-file: "6"

redis:
image: redis:6.0.16
restart: always
volumes:
- ./redis-data:/data

background:
image: tidb.ai/backend:local
build:
context: ./backend
restart: always
depends_on:
- redis
- backend
ports:
- "5555:5555"
env_file:
Expand Down
1 change: 1 addition & 0 deletions frontend/app/src/pages/docs/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"title": "Deployment"
},
"requirements": "Requirements",
"quickstart": "Quick Start",
"deploy-with-docker": {
"title": "Deploy with Docker",
"display": "hidden"
Expand Down
43 changes: 43 additions & 0 deletions frontend/app/src/pages/docs/quickstart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Quick Start

This document provides instructions for deploying the entire RAG using Docker Compose.

## Prerequisites

1. Set up a [TiDB Serverless cluster](https://docs.pingcap.com/tidbcloud/tidb-cloud-quickstart).
2. Install [Docker Compose](https://docs.docker.com/compose/install/).
3. Install [Python 3.11](https://www.python.org/downloads/release/python-3110/).
4. Install [Rye](https://rye.astral.sh/guide/installation/).

## Deployment Steps

1. Clone the repository:

```bash
git clone https://github.com/pingcap/tidb.ai.git
cd tidb.ai
```

2. Copy and edit the `.env` file in the `backend` directory:

```bash
cp ./backend/.env.example ./backend/.env
vim ./backend/.env # or use another text editor to edit this file
```

3. Migrate the database schema:

```bash
cd backend
rye sync
make migrate
cd ..
```

4. Start the services using Docker Compose:

```bash
docker compose up
```

That's it! You can now use TiDB.AI locally. You can also go to https://tidb.ai to experience the live demo.

0 comments on commit 2db9710

Please sign in to comment.