From 88bbd64440859a6b6fa9613586a71d3466eb9446 Mon Sep 17 00:00:00 2001 From: dogsub Date: Thu, 29 May 2025 13:25:03 +0900 Subject: [PATCH 1/7] =?UTF-8?q?:sparkles:=20feat:=20[KAN-83]=20Prod=20CI?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/befly-prod-ci.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/befly-prod-ci.yml b/.github/workflows/befly-prod-ci.yml index afa25cb..243da04 100644 --- a/.github/workflows/befly-prod-ci.yml +++ b/.github/workflows/befly-prod-ci.yml @@ -35,3 +35,22 @@ jobs: - name: Push to Docker Hub run: | docker push ${{ secrets.DOCKER_USERNAME }}/befly-ai:${{ steps.vars.outputs.sha }} + + - name: Checkout Manifests Repo + uses: actions/checkout@v3 + with: + repository: KEA-ReNov8/Befly-Minifest + path: manifest-repo + token: ${{ secrets.PAT }} + + - name: Bump image tag in consult-service deployment + run: | + cd manifest-repo + IMAGE=${{ secrets.DOCKER_USERNAME }}/befly-ai:${{ steps.vars.outputs.sha }} + # apps/consult-service/deployment.yaml 의 image 필드만 교체 + yq eval -i ".spec.template.spec.containers[0].image = \"${IMAGE}\"" apps/consult-service/deployment.yaml + git add apps/consult-service/deployment.yaml + git config user.name "github-actions" + git config user.email "actions@github.com" + git commit -m "ci: bump consult-service image to ${{ steps.vars.outputs.sha }}" + git push origin main From 1201444ee4a5d33c72ae30e947568751fe026bb9 Mon Sep 17 00:00:00 2001 From: gohyeoncheol Date: Sun, 1 Jun 2025 14:30:05 +0900 Subject: [PATCH 2/7] =?UTF-8?q?header->=20cookie=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/main.py b/app/main.py index 5edf864..9625d88 100644 --- a/app/main.py +++ b/app/main.py @@ -1,16 +1,16 @@ from fastapi import FastAPI, Depends -from fastapi.security import APIKeyHeader +from fastapi.security import APIKeyCookie from app.api.routes.chat import router as chat_router from app.core.config import settings from app.Exception.handlers import setup_exception_handlers -bearer_header = APIKeyHeader(name="Authorization", auto_error=False, description="액세스 토큰 (Bearer 형식)") +cookie_scheme = APIKeyCookie(name="accessToken", auto_error=False, description="액세스 토큰 (쿠키)") app = FastAPI( title=settings.APP_NAME, dependencies=[ - Depends(bearer_header) + Depends(cookie_scheme) ] ) From bec3c08d8eb760a76b672da270e8112aae3b20e1 Mon Sep 17 00:00:00 2001 From: KwonHalim Date: Sun, 1 Jun 2025 07:03:09 +0000 Subject: [PATCH 3/7] =?UTF-8?q?:sparkles:=20=EB=8F=84=EC=BB=A4=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7e7de48..56e836b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,5 @@ COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . EXPOSE 8000 -CMD ["/bin/bash", "-c", "echo 'Befly AI App Starting...' && gunicorn app.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000"] \ No newline at end of file +CMD ["/bin/bash", "-c", "echo 'Befly AI App Starting...' && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"] +#CMD ["/bin/bash", "-c", "echo 'Befly AI App Starting...' && gunicorn app.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000"] \ No newline at end of file From 7380583a4a9057caf4d2b706086cfdb01f2a99f5 Mon Sep 17 00:00:00 2001 From: KwonHalim Date: Sun, 1 Jun 2025 07:03:57 +0000 Subject: [PATCH 4/7] =?UTF-8?q?:arrow=5Fup:=20requirements.txt=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index d6b4df5..2d9d7e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,3 +15,4 @@ asyncio # 비동기 처리 httpx # 비동기 HTTP 클라이언트 motor langchain-google-genai +tkinter \ No newline at end of file From 0a619660d7b5dcae3ee3dbdb897218d97bef36ca Mon Sep 17 00:00:00 2001 From: KwonHalim Date: Sun, 1 Jun 2025 07:07:59 +0000 Subject: [PATCH 5/7] =?UTF-8?q?:arrow=5Fdown:=20requirements.txt=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 2d9d7e8..228de32 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,5 +14,4 @@ python-json-logger # 구조화된 로깅 asyncio # 비동기 처리 httpx # 비동기 HTTP 클라이언트 motor -langchain-google-genai -tkinter \ No newline at end of file +langchain-google-genai \ No newline at end of file From 5a2ce9dfc7e140d6ae6e83c5de87d2f095c59ddb Mon Sep 17 00:00:00 2001 From: KwonHalim <129161091+KwonHalim@users.noreply.github.com> Date: Wed, 4 Jun 2025 19:01:18 +0900 Subject: [PATCH 6/7] =?UTF-8?q?:sparkles:=20=EC=9A=B0=EC=9A=B8=EA=B0=90=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=ED=8F=89=EA=B0=80=20=EC=A7=80=ED=91=9C=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/prompt/evaulatorAI.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/prompt/evaulatorAI.py b/app/prompt/evaulatorAI.py index ecc96f2..0f3191e 100644 --- a/app/prompt/evaulatorAI.py +++ b/app/prompt/evaulatorAI.py @@ -47,6 +47,14 @@ 자신을 다른 사람들과 비교했을 때 느끼는 감정을 질문합니다. 자신의 장점과 단점에 대한 인식을 질문합니다. +우울감 (PHQ-9 관련): +일상생활에서 즐거움을 느끼지 못하는 빈도와 정도를 질문합니다. +슬픔, 우울감, 절망감의 지속 시간과 영향을 파악합니다. +수면이나 식욕의 변화, 피로감, 무가치함에 대한 인식을 평가합니다. +집중력 저하, 느린 움직임 또는 초조함의 유무를 질문합니다. +자살 사고나 자기 해를 가하려는 생각이 있었는지 민감하게 질문합니다. +이러한 증상들이 일상 기능(일, 가족, 인간관계)에 얼마나 영향을 미쳤는지 파악합니다. + 스트레스 (지각된 스트레스 척도 - PSS 관련): 일상생활에서 스트레스를 느끼는 정도와 빈도를 질문합니다. From d2d2843168613776ce78f0ee189853ae4da2563a Mon Sep 17 00:00:00 2001 From: KwonHalim <129161091+KwonHalim@users.noreply.github.com> Date: Thu, 5 Jun 2025 10:15:12 +0900 Subject: [PATCH 7/7] =?UTF-8?q?:sparkles:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=A0=84=EC=B2=B4=20=EC=A1=B0=ED=9A=8C=20API=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/routes/chat.py | 19 +++++++++++++++++++ app/repository/chat_repository.py | 13 ++++++++++++- app/service/chat_service.py | 21 ++++++++++++++++++++- 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/app/api/routes/chat.py b/app/api/routes/chat.py index ffa1356..ac1543e 100644 --- a/app/api/routes/chat.py +++ b/app/api/routes/chat.py @@ -66,6 +66,7 @@ async def chat_history( ): headers = request.headers user_id = headers.get("X-USER-ID") + print("user_id", user_id) model = await ChatService.get_chat_history(session_id, user_id) return ResponseModel( code = "common200", @@ -74,6 +75,23 @@ async def chat_history( ) +@router.get("/list/all", + response_model=ResponseModel, + summary="채팅방 목록 전체 조회", + description="유저의 채팅 목록을 조건 없이 모두 조회합니다." + ) +async def list_all( + request: Request, +): + user_id = request.headers.get("X-USER-ID") + model = await ChatService.get_all_chat(user_id) + return ResponseModel( + code="COMMON200", + message="모든 채팅 목록입니다.", + result = model + ) + + @router.get("/list/{status_field}", response_model=ResponseModel, summary="채팅방 목록 조회", @@ -108,6 +126,7 @@ async def evaluate_user( request: Request ): user_id = request.headers.get("X-USER-ID") + print(user_id) model = await ChatService.evaluate_user(session_id, user_id) return ResponseModel( code="COMMON200", diff --git a/app/repository/chat_repository.py b/app/repository/chat_repository.py index 6f91df9..5ac8f63 100644 --- a/app/repository/chat_repository.py +++ b/app/repository/chat_repository.py @@ -1,5 +1,7 @@ from typing import Optional +from motor.motor_asyncio import AsyncIOMotorCursor + from app.database.MongoDB import get_db from app.core.config import settings @@ -14,7 +16,7 @@ async def find_sessions_by_user(user_id: str, status_field: Optional[bool] = Non return await db[settings.MONGODB_COLLECTION].distinct("session_id", query) @staticmethod - async def find_session_info(session_id: str, status_field: Optional[bool] = None): + async def find_session_info(session_id: str, status_field): db = get_db() query = {"session_id": session_id} @@ -26,3 +28,12 @@ async def find_session_info(session_id: str, status_field: Optional[bool] = None query, sort=[("created_at", -1)] ) + + @staticmethod + async def get_all_chat(user_id: str): + db = get_db() + query = {"user_id": user_id} + cursor: AsyncIOMotorCursor = db[settings.MONGODB_COLLECTION].find(query, sort=[("created_at", -1)]) + chat_docs = await cursor.to_list(length=None) + print(f"Found {len(chat_docs)} chats for user_id: {user_id}") + return chat_docs \ No newline at end of file diff --git a/app/service/chat_service.py b/app/service/chat_service.py index 5fe3a03..4e06946 100644 --- a/app/service/chat_service.py +++ b/app/service/chat_service.py @@ -102,6 +102,23 @@ async def get_chat_list(user_id: str, status_field: bool): return chat_list + async def get_all_chat(user_id: str): + chat_list = await ChatRepository.get_all_chat(user_id) + all_chat = [] + + for chat in chat_list: + if chat: + all_chat.append({ + "session_id": chat.get("session_id"), + "chat_title": chat.get("chat_title"), + "created_at": chat.get("created_at"), + "last_message": chat.get("content", ""), + "category": chat.get("category"), + "status": chat.get("worry_state") + }) + return all_chat + + @staticmethod async def evaluate_user(session_id: str, user_id: str): try: @@ -182,4 +199,6 @@ async def update_after_keyword_and_change_status(session_id: str, data_dict: dic return None except Exception as e: print(e) - raise CustomException(500, "CHAT002", "채팅 세션 업데이트 중 오류가 발생했습니다.") \ No newline at end of file + raise CustomException(500, "CHAT002", "채팅 세션 업데이트 중 오류가 발생했습니다.") + +