diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d178dd7..bd758be 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -57,4 +57,4 @@ jobs: docker rm ticats_ai || true docker image rm public.ecr.aws/h7p2f6d8/ticats_ai:latest || true docker pull public.ecr.aws/h7p2f6d8/ticats_ai:latest - docker run -d -p 8000:8000 --name ticats_ai -e DATABASE_URL="${{ secrets.DATABASE_URL }}" public.ecr.aws/h7p2f6d8/ticats_ai:latest \ No newline at end of file + docker run -d -p 8000:8000 --name ticats_ai -e DATABASE_URL="${{ secrets.DATABASE_URL }}" -e NAVER_SECRET_KEY="${{ secrets.NAVER_SECRET_KEY }}" -e GEMINAI_SECRET_KEY="${{ secrets.GEMINAI_SECRET_KEY }}" public.ecr.aws/h7p2f6d8/ticats_ai:latest \ No newline at end of file diff --git a/app/routers/keyword_router.py b/app/routers/keyword_router.py index b5b784c..ff76f9e 100644 --- a/app/routers/keyword_router.py +++ b/app/routers/keyword_router.py @@ -25,7 +25,6 @@ def get_keyword_service(): # Main Section @router.get("", response_model=KeywordResponse) async def get_keyword(goods_code: str = None, keyword_service: KeywordService = Depends(get_keyword_service)): - evaluation_text = keyword_service.get_evaluations(goods_code) topic, sentiment = keyword_service.united_Processor(evaluation_text) diff --git a/app/routers/ocr_router.py b/app/routers/ocr_router.py index 47cd2eb..50dce04 100644 --- a/app/routers/ocr_router.py +++ b/app/routers/ocr_router.py @@ -1,3 +1,6 @@ +import json +from typing import Optional + from fastapi import APIRouter, Depends, UploadFile, File from pydantic import BaseModel @@ -6,8 +9,10 @@ # Response schema definition class OcrResponseSchema(BaseModel): - result: str - title: str + title: Optional[str] + place: Optional[str] + date: Optional[str] + seat: Optional[str] # Router @@ -21,4 +26,17 @@ class OcrResponseSchema(BaseModel): async def upload_ocr_photo(image: UploadFile = File(...), ocr_service: OcrService = Depends(OcrService)): image_content = await image.read() ocr_result = ocr_service.info_extractor(image_content) - return ocr_result + + # OCR 결과가 None일 경우 기본값을 설정 + if ocr_result is None: + ocr_result = {} + + # OCR 결과에서 필요한 필드를 추출하여 응답 형식에 맞게 변환 + response_data = { + "title": ocr_result.get("공연제목") or None, + "place": ocr_result.get("공연장소") or None, + "date": ocr_result.get("공연날짜") or None, + "seat": ocr_result.get("좌석정보") or None + } + + return response_data diff --git a/app/services/ocr_service.py b/app/services/ocr_service.py index 6c9959c..8e3a867 100644 --- a/app/services/ocr_service.py +++ b/app/services/ocr_service.py @@ -141,7 +141,7 @@ def info_extraction(self, ocr_result): if infos: result = ast.literal_eval("{" + infos.group(1) + "}") else: - result = {'info': 'None'} + result = {} return result