Content
# RAG API
This project is an API server based on FastAPI that implements a document-based question-answering system.
## Features
1. Document Upload and Vector Store Storage
- Supports PDF and CSV files
- Automatic document splitting and embedding
- Stored in Chroma vector store
2. Document Search
- Natural language query-based search
- Similarity-based document search
## Installation
1. Install the required packages:
```bash
pip install -r requirements.txt
```
2. Set environment variables:
```bash
export OPENAI_API_KEY="your-api-key"
```
## Running the Application
```bash
python main.py
```
The server will run at http://localhost:8000.
## API Endpoints
1. Document Upload
- POST /upload
- Upload files in multipart/form-data format
- Supported formats: PDF, CSV
- Parameters:
- `files`: List of files to upload (required)
- `vector_store_dir`: Directory path to save the vector store (optional, default: "vector_store")
2. Document Search
- POST /query
- Pass parameters in form-data format
- Parameters:
- `query`: Search query (required)
- `vector_store_dir`: Directory path of the vector store (optional, default: "vector_store")
- `k`: Number of documents to search for (optional, default: 2)
## API Documentation
The automatically generated documentation of FastAPI can be accessed at the following URLs:
- http://localhost:8000/docs
- http://localhost:8000/redoc
## Transferring Vector Store
To reuse files stored in the vector store in another project, follow these steps:
1. Copy the desired vector store directory to the same path in the other project.
2. The following packages must also be installed in the other project:
- langchain-chroma
- langchain-openai
- Other necessary dependency packages
3. The same embedding model (OpenAIEmbeddings) must be used.
4. Required environment variables (e.g., OpenAI API key) must be correctly set.
When transferring the vector store to another project, simply copying the directory is sufficient. This will preserve the embeddings and metadata of the documents, allowing them to be used in the new project as well.
## Using Multiple Vector Stores
This project is designed to support the simultaneous use of multiple vector stores. Each vector store is stored in a different directory, and you can specify the desired vector store through the `vector_store_dir` parameter in API calls.
For example, you can create and manage separate vector stores for different projects or document sets:
```
project1_docs -> vector_store_project1
project2_docs -> vector_store_project2
research_papers -> vector_store_research
```
This allows you to manage and search each document set independently.
You Might Also Like
MarkItDown MCP
markitdown-mcp is a lightweight MCP server for converting various URIs to Markdown.
Github
GitHub MCP Server connects AI tools to GitHub for code management and automation.

apisix
Apache APISIX is an API Gateway for managing APIs and microservices.
aws-lambda-mcp-cookbook
AWS Lambda MCP Cookbook provides Python examples for MCP server integration.
mcp-server-macos-use
MCP server in Swift for controlling macOS apps via accessibility APIs.
MonkeyMCP
MonkeyMCP is a .NET 9.0 server for Model Context Protocol facilitating...