Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/ai-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

name: CI/CD for AI Service


name: CI/CD for 00 Service
on:
push:
branches: [ "release/1.0.0" ]
Expand All @@ -19,7 +17,7 @@ env:
CONTAINER_NAME: msa-ai-service


# GitHub Actions Runner에 부여할 권한

permissions:
id-token: write
contents: read
Expand All @@ -28,28 +26,28 @@ jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 1. 소스 코드 체크아웃

- name: Checkout code
uses: actions/checkout@v4

# 2. AWS 자격 증명 설정 (OIDC 역할 사용)

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::490913547024:role/gitactionToECR # 기존에 사용하던 역할 ARN
aws-region: ${{ env.AWS_REGION }}

# 3. Amazon ECR 로그인

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2

# 4. 이미지 태그로 사용할 짧은 Git 커밋 해시 생성

- name: Set short git commit SHA
id: vars
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

# 5. Docker 이미지 빌드 및 ECR에 푸시

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
Expand All @@ -60,7 +58,7 @@ jobs:
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT

# 6. 최신 ECS 태스크 정의 파일 다운로드


- name: Download task definition
id: download-task-def
Expand All @@ -72,7 +70,6 @@ jobs:
- name: Clean task definition for old SDK
id: clean-task-def
run: |
# jq를 사용해 다운로드한 파일에서 enableFaultInjection 키를 삭제합니다.
jq 'del(.enableFaultInjection)' ${{ steps.download-task-def.outputs.file }} > cleaned-task-def.json
echo "file=cleaned-task-def.json" >> $GITHUB_OUTPUT

Expand All @@ -86,7 +83,7 @@ jobs:
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

# 8. 새로운 태스크 정의를 ECS 서비스에 배포

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
Expand Down
3 changes: 0 additions & 3 deletions msa-ai-service/.env

This file was deleted.

12 changes: 11 additions & 1 deletion msa-ai-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ FROM python:3.10-slim

WORKDIR /app

# SSL 인증서와 필요한 툴 설치
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 1. log_config.yaml 파일을 컨테이너 안으로 복사하는 라인 추가
COPY log_config.yaml .

COPY . .

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
# 2. CMD 명령어에 --log-config 옵션 추가
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--log-config", "log_config.yaml"]
2 changes: 1 addition & 1 deletion msa-ai-service/app/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
MONGODB_NAME = os.getenv("MONGODB_NAME", "ai_service_db")
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")

REVIEW_LABELS = ["quantity", "size", "sweet", "salty", "spicy", "deep"]
REVIEW_LABELS = ["quantity", "size", "sweet", "salty", "spicy", "deep", "sour"]
POLARITY_LABELS = ["POSITIVE", "NEGATIVE"]
1 change: 0 additions & 1 deletion msa-ai-service/app/services/change_stream_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def watch_reviews():
process_new_reviews(change)

def start_watchers():
# ✅ 서버 시작 시 bootstrap 먼저 실행
bootstrap_unanswered_questions()
bootstrap_reviews_embedding()

Expand Down
2 changes: 1 addition & 1 deletion msa-ai-service/app/services/rag_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def generate_answer(store_name, menu_name, question, label, reviews):

규칙:
1. 반드시 위 리뷰만 사실 근거로 삼아 답변하세요.
2. '{label}' 속성에 해당하는 리뷰들 중, 긍정/부정 리뷰 개수를 세어라.
2. {label} 속성에 해당하는 리뷰들 중, 긍정/부정 리뷰 개수를 세어라.
3. 다음 형식으로 요약하라:
- "'{label}' 관련 리뷰 {len(reviews)}건 중 X건은 긍정적이고, Y건은 부정적입니다."
- 마지막에 결론을 붙여라. (예: "대체로 짜다고 합니다", "의견이 갈립니다", "비율이 비슷합니다", "너무 짜다고 합니다")
Expand Down
34 changes: 34 additions & 0 deletions msa-ai-service/log_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: 1
disable_existing_loggers: false
formatters:
default:
(): "uvicorn.logging.DefaultFormatter"
fmt: "%(levelprefix)s %(message)s"
use_colors: null
access:
(): "uvicorn.logging.AccessFormatter"
# 아래 fmt와 datefmt를 수정하여 접속 로그 형식을 바꿀 수 있습니다.
fmt: '%(asctime)s %(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s'
datefmt: "%Y-%m-%d %H:%M:%S" # 원하는 날짜/시간 포맷
handlers:
default:
formatter: default
class: logging.StreamHandler
stream: ext://sys.stderr
access:
formatter: access
class: logging.StreamHandler
stream: ext://sys.stdout
loggers:
uvicorn:
handlers:
- default
level: INFO
propagate: false
uvicorn.error:
level: INFO
uvicorn.access:
handlers:
- access
level: INFO
propagate: false
8 changes: 4 additions & 4 deletions msa-ai-service/task-definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
],
"essential": true,
"environment": [
{
"name": "SPRING_PROFILES_ACTIVE",
"value": "dev"
}
{ "name": "ENV", "value": "prod" },
{ "name": "MONGODB_URI", "value": "mongodb+srv://ksm3255:[email protected]/?retryWrites=true&w=majority&appName=Team1Mongodb" },
{ "name": "MONGODB_NAME", "value": "ai_service_db" },
{ "name": "OPENAI_API_KEY", "value": "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" }
],
"mountPoints": [],
"volumesFrom": [],
Expand Down
Loading