-
Notifications
You must be signed in to change notification settings - Fork 4
Revert: Remove chat feature (accidental direct push) #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| FROM python:3.13-slim | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| ENV PYTHONPATH=/app/chat_service:/app/shared_utils | ||
|
|
||
| RUN apt-get update && apt-get install -y build-essential && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Copy requirements.txt from chat_service folder in root context | ||
| COPY chat_service/requirements.txt . | ||
|
|
||
| RUN pip install --no-cache-dir -r requirements.txt | ||
|
|
||
| # Copy utils folder from root context into /app/utils | ||
| COPY shared_utils ./shared_utils | ||
|
|
||
| # Copy chat_service folder from root context into /app/chat_service | ||
| COPY chat_service ./chat_service | ||
|
|
||
| # Remove unnecessary system packages | ||
| RUN apt-get update && \ | ||
| DEBIAN_FRONTEND=noninteractive apt-get remove --purge -y linux-libc-dev && \ | ||
| apt-get autoremove -y && \ | ||
| apt-get clean && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Create non-root user for security and set permissions | ||
| RUN groupadd -r appuser && useradd -r -g appuser -d /app -s /bin/bash appuser && \ | ||
| chown -R appuser:appuser /app | ||
|
|
||
| USER appuser | ||
|
|
||
| # Expose the FastAPI port | ||
| EXPOSE 8000 | ||
|
|
||
| CMD ["sh", "-c", "PYTHONPATH=/app/chat_service uvicorn chat_service.main:app --host 0.0.0.0 --port 8000"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| OPENAI_BASE_URL=http://webworkdgx/vllm_qwen3coder/v1 # Please change this to your LLM Server URL endpoint | ||
| OPENAI_API_KEY=lm-studio | ||
|
|
||
| # Large Language Model Configuration | ||
| OPENAI_MODEL=Qwen2.5-14B-Coder-Instruct | ||
| MODEL_TEMPERATURE=0.1 | ||
| MODEL_MAX_TOKENS=2000 | ||
| MODEL_TOP_K=5 | ||
| MODEL_TOP_P=0.8 | ||
| MODEL_FREQ_PENALTY=0.1 | ||
| MODEL_PRESENCE_PENALTY=0.1 | ||
|
|
||
| # Context Management | ||
| MODEL_MAX_CONTEXT=4000 | ||
| MODEL_MIN_SIMILARITY=0.3 | ||
| MODEL_ENABLE_RERANKING=true | ||
|
|
||
| # RAG Optimization | ||
| ENABLE_LLM_QUERY_CLASSIFICATION=true | ||
| ENABLE_RESPONSE_POST_PROCESSING=true | ||
|
|
||
| # Redis storage | ||
| REDIS_URL="redis://redis:6379/0?decode_responses=True&protocol=3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| from fastapi import FastAPI | ||
| from routers import health, chat | ||
| from prometheus_fastapi_instrumentator import Instrumentator | ||
|
|
||
| import logging | ||
|
|
||
| # Set up logger | ||
| logging.basicConfig( | ||
| level=logging.INFO, format="%(asctime)s [%(levelname)s] %(name)s: %(message)s" | ||
| ) | ||
|
|
||
| app = FastAPI(root_path="/chat") | ||
|
|
||
| # Initialize Prometheus metrics | ||
| instrumentator = Instrumentator() | ||
| instrumentator.instrument(app).expose(app) | ||
|
|
||
| app.include_router(health.router) | ||
| app.include_router(chat.router) |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| from pydantic import BaseModel, Field | ||
| from typing import List, Dict, Any | ||
|
|
||
|
|
||
| class ChatRequest(BaseModel): | ||
| """ | ||
| Request model for chat API endpoints. | ||
| """ | ||
|
|
||
| message: str | ||
| session_id: str | ||
| doc_ids: List[str] = None | ||
| collection_name: str = Field(default="default_collection", description="ChromaDB collection name") | ||
|
|
||
|
|
||
| class ChatResponse(BaseModel): | ||
| """ | ||
| Response model for chat API | ||
| """ | ||
|
|
||
| response: str | ||
| relevant_chunks: List[Dict[str, Any]] = Field( | ||
| default_factory=list, description="Additional metadata about the RAG process" | ||
| ) | ||
| metadata: Dict[str, Any] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
CMDinstruction is incorrectly overriding thePYTHONPATHenvironment variable, which will likely causeImportErrorat runtime. Additionally, the Dockerfile can be optimized to reduce image size by combiningRUNlayers.CMDBug: TheENVat line 5 correctly setsPYTHONPATHto include bothchat_serviceandshared_utils. However, theCMDat line 36 re-definesPYTHONPATHfor its execution scope but omits/app/shared_utils. This will prevent modules fromshared_utilsfrom being imported.Layer Optimization: The Dockerfile runs
apt-get updatetwice (lines 7 and 21) and uses separateRUNcommands to install and then remove packages. This creates unnecessary layers. These steps should be combined into a singleRUNcommand to install build dependencies, use them to install Python packages, and then clean them up in the same layer.I suggest refactoring the
CMDto use the exec form and rely on theENVvariable, and consolidating theRUNcommands for better efficiency and a smaller final image.