This project is a document chatbot that uses AI to answer user queries with information from the OceanBase documentation. It leverages the power of OpenAI's Embedding API to transform user questions and document articles into vector representations, and then uses cosine similarity to find the most relevant article to a user's question. The chatbot then uses this article to generate a contextually appropriate answer.
- Fetches OceanBase documentation from a GitHub repository
- Transforms document articles into vector representations
- Stores vectors in an OceanBase database
- Retrieves the most relevant article for a user's question
- Generates an answer using OpenAI's API
- Node.js
- OceanBase database
- OpenAI API key
- GitHub access token
- Clone the repository:
- Navigate into the project directory:
cd oceanbase-vector
- Install the dependencies:
npm install
- Create a
.env
file in the root directory and add your OpenAI API key, GitHub access token, and OceanBase database details:OPENAI_KEY=your-openai-key GITHUB_TOKEN=your-github-token
- Run the server:
node index.js
The project exposes two main endpoints: /train
and /ask
.
-
Training the model: Send a POST request to the
/train
endpoint with the GitHub repository details (repo
,path
,branch
, andlimit
) in the request body. This will fetch the documentation, transform it into vectors, and store these vectors in the database. -
Asking a question: Send a POST request to the
/ask
endpoint with the user's question in the request body. This will find the most relevant article and generate an answer using OpenAI's API.