hgzero/ai-python/app/config.py
Minseo-Jo b5159ef74e AI 제안사항 Hallucination 문제 해결 및 추출 개선
주요 변경사항:
1. AI 서비스 설정
   - claude_max_tokens: 8192 → 25000으로 증가 (회의록 통합을 위한 충분한 토큰 확보)
   - AI 서비스 타임아웃: 30초 → 60초로 증가

2. 프롬프트 개선 (consolidate_prompt.py)
   - JSON 생성 전문가 역할 추가
   - JSON 이스케이프 규칙 명시 (큰따옴표, 줄바꿈, 역슬래시)
   - Markdown 볼드체(**) 제거하여 JSON 파싱 오류 방지
   - 문자열 검증 지시사항 추가

3. JSON 파싱 개선 (claude_service.py)
   - 4단계 재시도 전략 구현:
     * 이스케이프되지 않은 개행 문자 자동 수정
     * strict=False 옵션으로 파싱
     * 잘린 응답 복구 시도
     * 제어 문자 제거 후 재시도
   - 디버깅 로깅 강화 (Input/Output Tokens, Stop Reason)
   - 파싱 실패 시 전체 응답을 파일로 저장

4. 회의 종료 로직 개선 (EndMeetingService.java)
   - 통합 회의록 생성 또는 조회 로직 추가 (userId=NULL)
   - Minutes 테이블에 전체 결정사항 저장
   - AgendaSection에 minutesId 정확히 매핑

5. 테스트 데이터 추가
   - AI 회의록 요약 테스트용 SQL 스크립트 작성
   - 3명 참석자, 3개 안건의 현실적인 회의 시나리오

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-31 11:09:22 +09:00

59 lines
1.8 KiB
Python

"""환경 설정"""
from pydantic_settings import BaseSettings
from functools import lru_cache
from typing import List
class Settings(BaseSettings):
"""환경 설정 클래스"""
# 서버 설정
app_name: str = "AI Service (Python)"
host: str = "0.0.0.0"
port: int = 8087
# Claude API
claude_api_key: str = "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"
claude_model: str = "claude-sonnet-4-5-20250929"
claude_max_tokens: int = 25000 # 회의록 통합을 위해 25000으로 증가
claude_temperature: float = 0.7
# Redis
redis_host: str = "20.249.177.114"
redis_port: int = 6379
redis_password: str = ""
redis_db: int = 4
# Azure Event Hub
eventhub_connection_string: str = "Endpoint=sb://hgzero-eventhub-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=VUqZ9vFgu35E3c6RiUzoOGVUP8IZpFvlV+AEhC6sUpo="
eventhub_name: str = "hgzero-eventhub-name"
eventhub_consumer_group: str = "ai-transcript-group"
# CORS
cors_origins: List[str] = [
"http://localhost:8888",
"http://localhost:8080",
"http://localhost:3000",
"http://127.0.0.1:8888",
"http://127.0.0.1:8080",
"http://127.0.0.1:3000",
"http://localhost:*" # 모든 localhost 포트 허용
]
# 로깅
log_level: str = "INFO"
# 분석 임계값 (실시간 응답을 위해 낮춤)
min_segments_for_analysis: int = 2 # 2개 세그먼트 (약 30초, 빠른 피드백)
text_retention_seconds: int = 300 # 5분
class Config:
env_file = ".env"
case_sensitive = False
@lru_cache()
def get_settings() -> Settings:
"""싱글톤 설정 인스턴스"""
return Settings()