sofzcc commited on
Commit
c8386d4
·
verified ·
1 Parent(s): 057733a

Delete app

Browse files
app/__init__.py DELETED
File without changes
app/config.py DELETED
@@ -1,20 +0,0 @@
1
- from pydantic_settings import BaseSettings
2
-
3
-
4
- class Settings(BaseSettings):
5
-
6
- model_name: str = "microsoft/Phi-3-mini-4k-instruct"
7
-
8
- embedding_model: str = (
9
- "sentence-transformers/all-MiniLM-L6-v2"
10
- )
11
-
12
- device: str = "cuda"
13
-
14
- top_k: int = 5
15
-
16
- class Config:
17
- env_file = ".env"
18
-
19
-
20
- settings = Settings()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/core/lifecycle.py DELETED
@@ -1,15 +0,0 @@
1
- from contextlib import asynccontextmanager
2
- from fastapi import FastAPI
3
-
4
- from app.services.assistant_service import initialize_assistant
5
- from app.services.assistant_service import cleanup_assistant
6
-
7
-
8
- @asynccontextmanager
9
- async def lifespan(app: FastAPI):
10
-
11
- initialize_assistant()
12
-
13
- yield
14
-
15
- cleanup_assistant()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/core/logging.py DELETED
File without changes
app/dependencies.py DELETED
@@ -1,9 +0,0 @@
1
- from app.services.assistant_service import assistant_instance
2
-
3
-
4
- def get_assistant():
5
-
6
- if assistant_instance is None:
7
- raise RuntimeError("Assistant not initialized")
8
-
9
- return assistant_instance
 
 
 
 
 
 
 
 
 
 
app/main.py DELETED
@@ -1,33 +0,0 @@
1
- from pathlib import Path
2
- from fastapi import FastAPI
3
- from fastapi.staticfiles import StaticFiles
4
-
5
- from app.core.lifecycle import lifespan
6
- from app.routers.chat import router as chat_router
7
- from app.routers.health import router as health_router
8
- from app.routers.evaluation import router as evaluation_router
9
-
10
- app = FastAPI(
11
- title="Self-Service KB Assistant",
12
- version="1.0.0",
13
- lifespan=lifespan,
14
- )
15
-
16
- # Routers
17
- app.include_router(chat_router, prefix="/api/chat", tags=["chat"])
18
- app.include_router(health_router, tags=["health"])
19
- app.include_router(evaluation_router, prefix="/api/evaluation", tags=["evaluation"])
20
-
21
- # Safe static mounting
22
- SITE_DIR = Path("site")
23
-
24
- if SITE_DIR.exists():
25
- app.mount("/site", StaticFiles(directory=SITE_DIR), name="site")
26
-
27
-
28
- @app.get("/")
29
- async def root():
30
- return {
31
- "status": "running",
32
- "service": "Self-Service KB Assistant"
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/models/assistant.py DELETED
@@ -1,17 +0,0 @@
1
- class Assistant:
2
-
3
- def __init__(self):
4
- self.ready = True
5
-
6
- def answer(self, message: str):
7
-
8
- response = f"Echo: {message}"
9
-
10
- sources = []
11
-
12
- contexts = []
13
-
14
- return response, sources, contexts
15
-
16
- def cleanup(self):
17
- self.ready = False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/routers/chat.py DELETED
@@ -1,35 +0,0 @@
1
- from fastapi import APIRouter
2
- from fastapi import Depends
3
- from fastapi import HTTPException
4
-
5
- from app.dependencies import get_assistant
6
- from app.schemas.chat import ChatRequest
7
- from app.schemas.chat import ChatResponse
8
-
9
- router = APIRouter()
10
-
11
-
12
- @router.post("/", response_model=ChatResponse)
13
- async def chat(
14
- request: ChatRequest,
15
- assistant=Depends(get_assistant)
16
- ):
17
-
18
- try:
19
-
20
- response, sources, contexts = (
21
- assistant.answer(request.message)
22
- )
23
-
24
- return ChatResponse(
25
- response=response,
26
- sources=sources,
27
- contexts=contexts
28
- )
29
-
30
- except Exception as e:
31
-
32
- raise HTTPException(
33
- status_code=500,
34
- detail=str(e)
35
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/routers/evaluation.py DELETED
@@ -1,11 +0,0 @@
1
- from fastapi import APIRouter
2
-
3
- router = APIRouter()
4
-
5
-
6
- @router.get("/")
7
- async def evaluation():
8
-
9
- return {
10
- "evaluation": "ok"
11
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/routers/health.py DELETED
@@ -1,11 +0,0 @@
1
- from fastapi import APIRouter
2
-
3
- router = APIRouter()
4
-
5
-
6
- @router.get("/health")
7
- async def health():
8
-
9
- return {
10
- "status": "healthy"
11
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/schemas/chat.py DELETED
@@ -1,12 +0,0 @@
1
- from pydantic import BaseModel
2
- from typing import List
3
-
4
-
5
- class ChatRequest(BaseModel):
6
- message: str
7
-
8
-
9
- class ChatResponse(BaseModel):
10
- response: str
11
- sources: List[str]
12
- contexts: List[str]
 
 
 
 
 
 
 
 
 
 
 
 
 
app/schemas/evaluation.py DELETED
File without changes
app/services/assistant_service.py DELETED
@@ -1,21 +0,0 @@
1
- from app.models.assistant import Assistant
2
-
3
- assistant_instance = None
4
-
5
-
6
- def initialize_assistant():
7
-
8
- global assistant_instance
9
-
10
- if assistant_instance is None:
11
- assistant_instance = Assistant()
12
-
13
-
14
- def cleanup_assistant():
15
-
16
- global assistant_instance
17
-
18
- if assistant_instance is not None:
19
- assistant_instance.cleanup()
20
-
21
- assistant_instance = None
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/services/retrieval_service.py DELETED
File without changes