basic structure setup

This commit is contained in:
Niklas Mueller 2024-06-15 17:01:42 +02:00
parent 0ba46dad75
commit 95f8488227
9 changed files with 200 additions and 2 deletions

47
.env Normal file
View file

@ -0,0 +1,47 @@
################################
# General Settings
################################
LOGGING_LEVEL=DEBUG
################################
# Object Storage Settings
################################
# NOTE! MinIO requires an key at least consisting of 8 chars for the secret key
S3_ENDPOINT=http://localhost:9000
S3_ACCESS_KEY=admin
S3_SECRET_KEY=secret-admin-key
BUCKET_NAME=rag-bucket
################################
# Vector DB Settings
################################
VECTOR_STORE_ENDPOINT=localhost
VECTOR_STORE_PORT=9200
OPENSEARCH_USE_SSL=True
################################
# LLM Settings
################################
# Which LLm to use
LLM_OPTION=ollamallm
# LLM_API_ENDPOINT=http://<ip-of-ollama-instance>:11434
LLM_API_ENDPOINT=http://127.0.0.1:11434
# if required for you llm setup (for self hosted ollama not needed)
LLM_API_KEY=placeholder
# valid Language options - "en" "de" "multi"
LLM_LANGUAGE=de
# LLM Model to be used - "mistral", "phi3", "llama3", etc.
LLM_MODEL_NAME=mistral

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.vscode

View file

@ -1,3 +1,23 @@
# rag-chat
# RAG-Chat
Chat with your Documents/Knowledgebase
## Usage
Clone the repo, enter it and run:
```
podman-compose -f docker-compose.yaml up
```
## Structure
### Object Storage
* Minio (http://localhost:9001/)
### Vector Storage
* OpenSearch (Dashboard under: http://localhost:5601/)
### RAG-Backend
* API-Docs http://localhost:8000/docs

67
docker-compose.yaml Normal file
View file

@ -0,0 +1,67 @@
version: '3.4'
services:
opensearch-node:
image: docker.io/opensearchproject/opensearch:2.11.1
container_name: opensearch-node
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx2g"
ports:
- 9200:9200
- 9300:9300
networks:
- rag
volumes:
- opensearch-data:/usr/share/opensearch/data
opensearch-dashboards:
image: docker.io/opensearchproject/opensearch-dashboards:2.11.1
container_name: opensearch-dashboards
ports:
- 5601:5601
expose:
- "5601"
environment:
OPENSEARCH_HOSTS: 'https://opensearch-node:9200'
networks:
- rag
minio:
container_name: minio
image: docker.io/minio/minio
ports:
- "9000:9000"
- "9001:9001"
volumes:
- minio_storage:/data
- ./init-scripts:/docker-entrypoint-initdb.d
environment:
MINIO_ROOT_USER: ${S3_ACCESS_KEY}
MINIO_ROOT_PASSWORD: ${S3_SECRET_KEY}
command: server --console-address ":9001" /data
networks:
- rag
backend:
container_name: rag-chat-backend
build:
context: ./rag-chat-backend
dockerfile: Dockerfile
image: rag-chat-backend:0.1
ports:
- "8000:8000"
environment:
- VECTOR_STORE_ENDPOINT=opensearch-node
- S3_ENDPOINT=http://minio:9000
env_file:
- .env
networks:
- rag
networks:
rag: {}
volumes:
opensearch-data:
minio_storage: {}

View file

@ -0,0 +1,15 @@
FROM python:3.10-slim
WORKDIR /app
COPY ./requirements.txt /app
RUN apt-get update && apt-get install -y build-essential
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
EXPOSE 8000
COPY . /app
CMD ["python", "src/app.py"]

View file

@ -0,0 +1,11 @@
uvicorn==0.22.0
fastapi==0.109.1
minio==7.1.17
opensearch-py==2.3.2
opensearch-logger==1.3.0
python-dotenv==1.0.0
python-multipart==0.0.7
PyPDF2==3.0.1

View file

View file

@ -0,0 +1,30 @@
"""FastAPI Backend"""
import uvicorn
import os
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from dotenv import load_dotenv
from core.config import settings
load_dotenv()
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
print('OPENSEARCH_USE_SSL')
print(os.getenv('OPENSEARCH_USE_SSL'))
print('settings.API_V1_STR')
print(settings.API_V1_STR)
if __name__ == "__main__":
uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True)

View file

@ -0,0 +1,7 @@
# config.py
class Settings:
API_V1_STR: str = "/api"
settings = Settings()