Skip to content

Commit

Permalink
removed gpt terms and changed project name
Browse files Browse the repository at this point in the history
  • Loading branch information
c0sogi committed May 17, 2023
1 parent aaea7fa commit 14812d9
Show file tree
Hide file tree
Showing 41 changed files with 1,043 additions and 991 deletions.
2 changes: 1 addition & 1 deletion .env-sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DELETE THESE COMMENT LINE!!
# DEFAULT_LLM_MODEL is defined in `LLM_MODELS` in `app\models\gpt_llms.py`
# DEFAULT_LLM_MODEL is defined in `LLM_MODELS` in `app\models\llms.py`

API_ENV="local"
PORT=8000
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "frontend"]
path = frontend
url = https://github.com/c0sogi/ChatGPT-Flutter-App
url = https://github.com/c0sogi/LLMChat-frontend
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@
"**/deprecated_api_request_in_flutter.dart": true,
},
"python.analysis.typeCheckingMode": "basic",
"cmake.sourceDirectory": "D:/Projects/chatgpt-webapp-server/frontend/linux",
}
10 changes: 5 additions & 5 deletions app/common/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
user_dependency,
)
from app.utils.logger import api_logger
from app.utils.chatgpt.chatgpt_cache_manager import ChatGptCacheManager
from app.utils.chat.cache_manager import CacheManager
from app.utils.js_initializer import js_url_initializer
from app.dependencies import process_pool_executor

Expand Down Expand Up @@ -49,7 +49,7 @@ def create_app(config: Config) -> FastAPI:
)

# Routers
new_app.mount("/chatgpt", StaticFiles(directory="./app/web", html=True))
new_app.mount("/chat", StaticFiles(directory="./app/web", html=True))
new_app.include_router(index.router, tags=["index"])
new_app.include_router(websocket.router, prefix="/ws", tags=["websocket"])
new_app.include_router(
Expand Down Expand Up @@ -79,15 +79,15 @@ async def startup():
if cache.redis is None:
raise ConnectionError("Redis is not connected yet!")
if cache.is_initiated and await cache.redis.ping():
await ChatGptCacheManager.delete_user(f"testaccount@{config.host_main}")
await CacheManager.delete_user(f"testaccount@{config.host_main}")
api_logger.critical("Redis CACHE connected!")
else:
api_logger.critical("Redis CACHE connection failed!")

@new_app.on_event("shutdown")
async def shutdown():
process_pool_executor.shutdown()
# await ChatGptCacheManager.delete_user(f"testaccount@{HOST_MAIN}")
process_pool_executor.shutdown(cancel_futures=True, wait=True)
# await CacheManager.delete_user(f"testaccount@{HOST_MAIN}")
await db.close()
await cache.close()
api_logger.critical("DB & CACHE connection closed!")
Expand Down
2 changes: 1 addition & 1 deletion app/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __call__(cls, *args, **kwargs):
"/openapi.json",
"/test",
)
EXCEPT_PATH_REGEX: Pattern = compile("^(/docs|/redoc|/api/auth|/favicon.ico|/chatgpt|/flutter_service_worker.js)")
EXCEPT_PATH_REGEX: Pattern = compile("^(/docs|/redoc|/api/auth|/favicon.ico|/chat|/flutter_service_worker.js)")
TOKEN_EXPIRE_HOURS: int = 168
MAX_API_KEY: int = 3
MAX_API_WHITELIST: int = 10
Expand Down
148 changes: 0 additions & 148 deletions app/database/crud/chatgpt.py

This file was deleted.

148 changes: 148 additions & 0 deletions app/database/crud/deprecated_chatgpt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# from typing import Optional

# from sqlalchemy import select
# from app.errors.api_exceptions import (
# Responses_404,
# Responses_500,
# )
# from app.database.connection import db
# from app.database.schemas.auth import (
# ChatMessages,
# ChatRooms,
# GptPresets,
# )


# async def create_chat_room(
# chat_room_type: str,
# name: str,
# description: str | None,
# user_id: int,
# status: str = "active",
# ) -> ChatRooms:
# if db.session is None:
# raise Responses_500.database_not_initialized
# async with db.session() as transaction:
# new_chat_room: ChatRooms = ChatRooms(
# status=status,
# chat_room_type=chat_room_type,
# name=name,
# description=description,
# user_id=user_id,
# )
# transaction.add(new_chat_room)
# await transaction.commit()
# await transaction.refresh(new_chat_room)
# return new_chat_room


# async def get_chat_all_rooms(user_id: int) -> list[ChatRooms]:
# return await ChatRooms.fetchall_filtered_by(user_id=user_id) # type: ignore


# async def create_chat_message(
# role: str,
# message: str,
# chat_room_id: int,
# user_id: int,
# status: str = "active",
# ) -> ChatMessages:
# if db.session is None:
# raise Responses_500.database_not_initialized
# async with db.session() as transaction:
# new_chat_message: ChatMessages = ChatMessages(
# status=status,
# role=role,
# message=message,
# user_id=user_id,
# chat_room_id=chat_room_id,
# )
# transaction.add(new_chat_message)
# await transaction.commit()
# await transaction.refresh(new_chat_message)
# return new_chat_message


# async def get_chat_all_messages(
# chat_room_id: int,
# user_id: int,
# ) -> list[ChatMessages]:
# return await ChatMessages.fetchall_filtered_by(
# user_id=user_id,
# chat_room_id=chat_room_id,
# ) # type: ignore


# async def create_gpt_preset(
# user_id: int,
# temperature: float,
# top_p: float,
# presence_penalty: float,
# frequency_penalty: float,
# ) -> GptPresets:
# if db.session is None:
# raise Responses_500.database_not_initialized
# async with db.session() as transaction:
# new_gpt_preset: GptPresets = GptPresets(
# user_id=user_id,
# temperature=temperature,
# top_p=top_p,
# presence_penalty=presence_penalty,
# frequency_penalty=frequency_penalty,
# )
# transaction.add(new_gpt_preset)
# await transaction.commit()
# await transaction.refresh(new_gpt_preset)
# return new_gpt_preset


# async def get_gpt_presets(user_id: int) -> list[GptPresets]:
# return await GptPresets.fetchall_filtered_by(user_id=user_id) # type: ignore


# async def get_gpt_preset(user_id: int, preset_id: int) -> GptPresets:
# return await GptPresets.fetchone_filtered_by(user_id=user_id, id=preset_id)


# async def update_gpt_preset(
# user_id: int,
# preset_id: int,
# temperature: float,
# top_p: float,
# presence_penalty: float,
# frequency_penalty: float,
# status: str = "active",
# ) -> GptPresets:
# if db.session is None:
# raise Responses_500.database_not_initialized
# async with db.session() as transaction:
# matched_preset: Optional[GptPresets] = await transaction.scalar(
# select(GptPresets).filter_by(user_id=user_id, id=preset_id)
# )
# if matched_preset is None:
# raise Responses_404.not_found_preset
# matched_preset.set_values_as(
# temperature=temperature,
# top_p=top_p,
# presence_penalty=presence_penalty,
# frequency_penalty=frequency_penalty,
# status=status,
# )
# transaction.add(matched_preset)
# await transaction.commit()
# await transaction.refresh(matched_preset)
# return matched_preset


# async def delete_gpt_preset(user_id: int, preset_id: int) -> None:
# if db.session is None:
# raise Responses_500.database_not_initialized
# async with db.session() as transaction:
# matched_preset: Optional[GptPresets] = await transaction.scalar(
# select(GptPresets).filter_by(user_id=user_id, id=preset_id)
# )
# if matched_preset is None:
# raise Responses_404.not_found_preset
# await transaction.delete(matched_preset)
# await transaction.commit()
# return
Loading

0 comments on commit 14812d9

Please sign in to comment.