Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions docker-compose-ollama.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,19 @@ services:
- ${LOCAL_FILES_PATH}:/usr/src/app/local_files/
- ./indexer:/usr/src/app
ports:
- 8001:8000
- 8001:8001
environment:
- PYTHONPATH=/usr/src
- PYTHONUNBUFFERED=TRUE
- LOCAL_FILES_PATH=${LOCAL_FILES_PATH}
- EMBEDDING_MODEL_ID=${EMBEDDING_MODEL_ID}
- EMBEDDING_SIZE=${EMBEDDING_SIZE}
- START_INDEXING=${START_INDEXING}
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8001/health"]
interval: 10s
timeout: 5s
retries: 3
depends_on:
- qdrant

Expand All @@ -66,7 +71,7 @@ services:
volumes:
- ./llm:/usr/src/app
ports:
- 8003:8000
- 8003:8003
environment:
- PYTHONPATH=/usr/src
- PYTHONUNBUFFERED=TRUE
Expand All @@ -76,6 +81,7 @@ services:
- ollama
- qdrant
- indexer
entrypoint: ["./wait-for-it.sh", "http://indexer:8001/health", "60", "--", "python", "app.py"]

chat:
build: ./chat
Expand Down
2 changes: 1 addition & 1 deletion indexer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY . .
ENV START_INDEXING=${START_INDEXING}
RUN echo "START_INDEXING is $START_INDEXING"

ENV PORT 8000
ENV PORT 8001
ENV CURRENT_HOST 0.0.0.0
ENV WORKERS 1

Expand Down
29 changes: 29 additions & 0 deletions indexer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pydantic import BaseModel
from async_queue import AsyncQueue
from fastapi import FastAPI, APIRouter
from fastapi.responses import JSONResponse
from contextlib import asynccontextmanager
from async_loop import index_loop, crawl_loop

Expand All @@ -20,6 +21,34 @@
class Query(BaseModel):
query: str

@router.get(
"/health",
response_description="Health check",
status_code=200,
)
async def health():
try:
result = indexer.find("Indexer healthy")
if not result:
return JSONResponse(
status_code=500,
content={"status": "error", "detail": "Indexer is not healthy"},
)

return JSONResponse(
status_code=200,
content={"status": "ok", "detail": "Indexer is healthy"},
)

except Exception as e:
logger.error(f"Error during health check: {e}")

return JSONResponse(
status_code=500,
content={"status": "error", "detail": str(e)},
)


@router.post(
"/query",
response_description='Query local data storage',
Expand Down
3 changes: 3 additions & 0 deletions llm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ RUN pip install huggingface_hub
RUN huggingface-cli download $RERANKER_MODEL --repo-type model
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN apt-get update && apt-get install -y curl
COPY ./wait-for-it.sh /usr/local/bin/wait-for-it.sh
RUN chmod +x /usr/local/bin/wait-for-it.sh

ENV PORT 8000
ENV CURRENT_HOST 0.0.0.0
Expand Down
26 changes: 26 additions & 0 deletions llm/wait-for-it.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e

HOST=$1
TIMEOUT=$2

if [ -z "$HOST" ] || [ -z "$TIMEOUT" ]; then
echo "Usage: $0 <host:port/path> <timeout>"
exit 1
fi

echo "Waiting for $HOST to return HTTP 200..."

for ((i=1;i<=TIMEOUT;i++)); do
STATUS=$(curl -o /dev/null -s -w "%{http_code}" "$HOST" || echo "000")
if [ "$STATUS" -eq 200 ]; then
echo "Service $HOST is ready."
exit 0
fi
echo "Service $HOST not ready, retrying ($i/$TIMEOUT)..."
sleep 1
done

echo "Timeout reached while waiting for $HOST"
exit 1