Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codewithrajdeep/fastapi_server
https://github.com/codewithrajdeep/fastapi_server
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codewithrajdeep/fastapi_server
- Owner: CodewithRajDeep
- Created: 2024-11-07T01:37:59.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-16T11:02:16.000Z (about 2 months ago)
- Last Synced: 2024-11-16T12:17:37.362Z (about 2 months ago)
- Language: Python
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Title: FastAPI RAG Server
## Description
A lightweight FastAPI server implementing Retrieval-Augmented Generation (RAG) capabilities, utilizing ChromaDB for document storage and querying,
with sentence-transformers for embedding generation. The server supports document ingestion and query functionalities with non-blocking API endpoints
and efficient concurrency handling.
## π Table of Contents
1. π€ [Introduction](#description)
2. βοΈ [Tech Stack](#tech-stack)
3. π [Features](#features)
4. π€Έ [Quick Start](#quick-start)
5. πΈοΈ [Setup .env variables](#snippet)
6. π¦[Work Demonstration](#work-demonstration)- FastAPI
- ChromaDB
- Sentence-Transformers
- Uvicorn
- Pytest
-
## π Featuresπ **Document Ingestion:** Upload PDF, DOC, DOCX, or TXT files and store document embeddings in ChromaDB.
π **Querying:** Retrieve documents based on semantic similarity to a query.
π **Concurrency:** Non-blocking endpoints with concurrent document handling.## π€Έ Getting Started
1. Clone the repository
bash
Copy code
```git clone https://github.com/yourusername/fastapi-rag-server.git
cd fastapi-rag-server
```
2. Set up a virtual environment
bash
```
Copy code
python3 -m venv env
source env/bin/activate # On Windows, use `env\Scripts\activate`
```
4. Install dependencies
bash
```
Copy code
pip install -r requirements.txt
```
Requirements
The requirements.txt should contain:
```
plaintext
Copy code
fastapi
uvicorn
chromadb
sentence-transformers
pypdf
python-docx
textract
```
Running the Server
1. Start the FastAPI server
Use Uvicorn to run the FastAPI server.bash
```
Copy code
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
The server will be available at http://localhost:8000.
```
2. API Endpoints
Ingest Document
Endpoint: POST /ingest/
Description: Uploads a document (PDF, DOC, DOCX, TXT) and stores it in ChromaDB.
Parameters: file (UploadFile) - The document file to be ingested.
Example:
bash
Copy code
```
curl -X 'POST' \
'http://localhost:8000/ingest/' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@path_to_your_file.pdf'
```
Query Documents
Endpoint: GET /query/
Description: Queries documents based on semantic similarity to the provided text.
Parameters: query (str) - The query text.bash
Copy code
```
curl -X 'GET' \
'http://localhost:8000/query/?query=your_query_text' \
-H 'accept: application/py'
```
4. Testing
Access the interactive API docs at http://localhost:8000/docs or the redoc documentation at http://localhost:8000/redoc.Contributing
Fork the repository
Create a new branch for your feature or bug fix:
bash
Copy code
git checkout -b feature-name
Commit your changes:
bash
Copy code
git commit -m "Add new feature"
Push to the branch:
bash
Copy code
git push origin feature-name
Create a pull request## Contribution Guidelines:
Guidelines for contributing to the project.**Reporting Issues:**
Search for existing issues: Before creating a new issue, search the issue tracker to see if the problem has already been reported.
Provide clear and concise information: When creating a new issue, please include as much detail as possible, such as:
Clear description of the problem
Steps to reproduce the issue
Expected behavior
Actual behavior
Screenshots or logs (if applicable)
Use issue templates: If available, use the provided issue templates to structure your report.**Submitting Pull Requests:**
Fork the repository: Create a fork of the project on your GitHub account.
Create a new branch: Create a new branch based on the main branch or a feature branch.
Make changes: Implement your changes and commit them with clear commit messages.
Push changes to your fork: Push your changes to your forked repository.
Open a Pull Request: Create a pull request from your branch to the main repository.
Provide details: Clearly describe the changes you've made and the benefits they bring.
Address code review feedback: Be open to feedback and make necessary changes.**Testing:**
Write unit tests for any new features or bug fixes.
Ensure existing tests pass after your changes.## License
Issued : Copyright (c)| 2024 Deep Raj## Memes: