File size: 2,038 Bytes
4a0d2c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93bc171
4a0d2c6
 
a624e23
 
4a0d2c6
2e4fd26
 
 
 
 
4a0d2c6
a624e23
4a0d2c6
 
 
 
 
2e4fd26
 
 
4a0d2c6
2e4fd26
 
 
 
 
 
 
4a0d2c6
2e4fd26
4a0d2c6
 
 
 
 
 
93bc171
4a0d2c6
 
 
 
 
 
 
 
 
 
 
 
 
fce2427
4a0d2c6
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
 /*************************************************************************
 * 
 * CONFIDENTIAL
 * __________________
 * 
 *  Copyright (2023-2025) AI Labs, IronOne Technologies, LLC
 *  All Rights Reserved
 *
 *  Author  : Theekshana Samaradiwakara
 *  Description :Python Backend API to chat with private data  
 *  CreatedDate : 14/11/2023
 *  LastModifiedDate : 15/10/2024
 *************************************************************************/
"""

import os
import logging
import uvicorn
from dotenv import load_dotenv

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from reggpt.configs.api import API_TITLE, API_VERSION, API_DESCRIPTION 
from reggpt.api.router import ChatAPI

from dotenv import load_dotenv
import os

load_dotenv()

def filer():
    return "reggpt/logs/log"
    # today = datetime.datetime.today()
    # log_filename = f"logs/{today.year}-{today.month:02d}-{today.day:02d}.log"
    # return log_filename


# file_handler = logging.FileHandler(filer())
# # file_handler = logging.handlers.TimedRotatingFileHandler(filer(),when="D")
# file_handler.setLevel(logging.INFO)

# logging.basicConfig(
#     level=logging.DEBUG,
#     format="%(asctime)s %(levelname)s (%(name)s) : %(message)s",
#     datefmt="%Y-%m-%d %H:%M:%S",
#     handlers=[file_handler],
#     force=True,
# )

# logger = logging.getLogger(__name__)

load_dotenv()
host = os.environ.get("APP_HOST")
port = int(os.environ.get("APP_PORT"))

# initialize API
app = FastAPI(title=API_TITLE, version=API_VERSION, description=API_DESCRIPTION)
api = ChatAPI()
app.include_router(api.router)

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],  # origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

if __name__ == "__main__":
    # config = uvicorn.Config("server:app",host=host, port=port, log_config= logging.basicConfig())
    config = uvicorn.Config("app:app", host=host, port=port)
    server = uvicorn.Server(config)
    server.run()
    # uvicorn.run(app)