RegGPT-Back-End / app.py
Hammaad
re configured the prompts
2e4fd26
"""
/*************************************************************************
*
* 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)