duythduong commited on
Commit
253280e
·
1 Parent(s): ec74c58

chore: add more corebase

Browse files
apis/__init__.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from fastapi import APIRouter
2
+ from .v1.routes.documents import router as documents_router
3
+
4
+
5
+ api_v1_router = APIRouter(prefix="/v1")
6
+ api_v1_router.include_router(documents_router)
apis/create_app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ from .v1.configs.swagger_config import swagger_config
4
+
5
+
6
+ # Define create_app function.
7
+ # Avoid circular import by using this function
8
+ # to create FastAPI app instance.
9
+ def create_app():
10
+ app = FastAPI(**swagger_config)
11
+
12
+ # CORs handling
13
+ app.add_middleware(
14
+ CORSMiddleware,
15
+ allow_origins=["*"],
16
+ allow_credentials=True,
17
+ allow_methods=["*"],
18
+ allow_headers=["*"],
19
+ )
20
+
21
+ return app
apis/{configs → v1/configs}/llm_configs.py RENAMED
File without changes
apis/v1/configs/swagger_config.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Swagger configuration
2
+ swagger_config = {
3
+ "title": "RAG System API",
4
+ "description": "API for the Retrieval-Augmented Generation (RAG) System",
5
+ "docs_url": "/",
6
+ "openapi_tags": [
7
+ {
8
+ "name": "Document",
9
+ "description": "Operations with documents"
10
+ },
11
+ {
12
+ "name": "RAG",
13
+ "description": "Retrieve and Generate operations"
14
+ }
15
+ ]
16
+ }
apis/{configs → v1/configs}/word_embedding_config.py RENAMED
File without changes
apis/{controllers → v1/controllers}/database_controller.py RENAMED
File without changes
apis/{providers/database_provider.py → v1/controllers/document_controller.py} RENAMED
File without changes
apis/{utils/constants.py → v1/interfaces/document_interface.py} RENAMED
File without changes
apis/v1/middleware/auth_middleware.py ADDED
File without changes
apis/v1/providers/vectordb_provider.py ADDED
File without changes
apis/v1/providers/word_embedding_provider.py ADDED
File without changes
apis/v1/routes/documents.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Annotated
2
+ from io import BytesIO
3
+ from fastapi import APIRouter, Depends, BackgroundTasks
4
+ from ..interfaces.document_interface import DocumentUploadResponseInterface
5
+ router = APIRouter(prefix="/documents", tags=["Documents"])
6
+
7
+ @router.post("/upload", response_model=DocumentResponse)
8
+ async def upload_document(file: Annotated[BytesIO, Field(..., description="File to upload")], background_tasks: BackgroundTasks):
9
+ """
10
+ Upload a document
11
+ """
12
+
13
+ return DocumentUploadResponseInterface(file=file)
apis/v1/schemas/document_schema.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from typing import AnyStr, Dict
2
+ from pydantic import BaseModel, Field
3
+ from ..providers import jd_db
4
+
5
+
6
+ class DocumentResponse(BaseModel):
7
+
apis/{utils → v1/utils}/__pycache__/prompts.cpython-311.pyc RENAMED
File without changes
apis/v1/utils/constants.py ADDED
File without changes
apis/{utils → v1/utils}/prompts.py RENAMED
File without changes