feat: clawdbot 클라이언트 추가 및 DB/앱 업데이트
- clawdbot_client.py: 챗봇 연동 클라이언트 - db_setup.py, pet_recommend_app.py 수정 - .gitignore: _dev_scripts/ 제외 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
97
db_setup.py
97
db_setup.py
@@ -963,5 +963,100 @@ class InventorySupplementary(Base):
|
||||
supplementary = relationship('SupplementaryProduct', back_populates='inventories')
|
||||
|
||||
|
||||
# 26. 테이블 생성
|
||||
# ============================================================
|
||||
# 26. RecommendationLog 테이블 (추천 조회 로그)
|
||||
# 보호자 질문 → 추천 결과 → 백그라운드 분석 결과 저장
|
||||
# ============================================================
|
||||
class RecommendationLog(Base):
|
||||
"""추천 조회 로그 테이블 - GPT vs Opus 비교용"""
|
||||
__tablename__ = 'recommendation_log'
|
||||
__table_args__ = (
|
||||
Index('ix_reclog_created', 'created_at'),
|
||||
Index('ix_reclog_animal', 'animal_type'),
|
||||
Index('ix_reclog_session', 'session_id'),
|
||||
{'comment': '동물약 추천 조회 로그'}
|
||||
)
|
||||
|
||||
id = Column(Integer, primary_key=True, comment='고유 ID')
|
||||
session_id = Column(String(100), nullable=True, comment='세션 ID')
|
||||
|
||||
# 입력 정보
|
||||
animal_type = Column(String(10), nullable=False, comment='동물 종류: dog/cat')
|
||||
breed = Column(String(100), nullable=True, comment='견종/묘종')
|
||||
weight_kg = Column(Float, nullable=True, comment='체중 (kg)')
|
||||
pregnancy_status = Column(String(20), nullable=True, comment='임신/수유 상태')
|
||||
symptoms = Column(JSONB, nullable=True, comment='선택된 증상 코드 목록')
|
||||
symptom_descriptions = Column(JSONB, nullable=True, comment='증상 설명 목록')
|
||||
|
||||
# 추천 결과
|
||||
matched_products = Column(JSONB, nullable=True, comment='추천된 제품 목록')
|
||||
product_count = Column(Integer, default=0, comment='추천 제품 수')
|
||||
|
||||
# AI 응답 (즉시 응답)
|
||||
gpt_response = Column(Text, nullable=True, comment='GPT-4o-mini 즉시 응답')
|
||||
gpt_response_time_ms = Column(Integer, nullable=True, comment='GPT 응답 시간 (ms)')
|
||||
|
||||
# AI 응답 (백그라운드 Opus)
|
||||
opus_response = Column(Text, nullable=True, comment='Claude Opus 심층 분석')
|
||||
opus_response_time_ms = Column(Integer, nullable=True, comment='Opus 응답 시간 (ms)')
|
||||
opus_analyzed_at = Column(DateTime, nullable=True, comment='Opus 분석 완료 시간')
|
||||
|
||||
# 근거 자료
|
||||
evidence_references = Column(JSONB, nullable=True, comment='PubMed 등 근거 자료')
|
||||
evidence_fetched_at = Column(DateTime, nullable=True, comment='근거 자료 수집 시간')
|
||||
|
||||
# 품질 비교
|
||||
quality_score_gpt = Column(Float, nullable=True, comment='GPT 응답 품질 점수')
|
||||
quality_score_opus = Column(Float, nullable=True, comment='Opus 응답 품질 점수')
|
||||
reviewed_at = Column(DateTime, nullable=True, comment='검토 완료 시간')
|
||||
reviewer_notes = Column(Text, nullable=True, comment='검토자 메모')
|
||||
|
||||
# 메타 정보
|
||||
created_at = Column(DateTime, default=datetime.utcnow, server_default=func.now(), nullable=False, comment='생성 시간')
|
||||
client_ip = Column(String(50), nullable=True, comment='클라이언트 IP')
|
||||
user_agent = Column(String(500), nullable=True, comment='User Agent')
|
||||
|
||||
|
||||
# ============================================================
|
||||
# 27. EvidenceReference 테이블 (근거 자료)
|
||||
# PubMed 등에서 수집한 논문/근거 자료
|
||||
# ============================================================
|
||||
class EvidenceReference(Base):
|
||||
"""근거 자료 테이블 - PubMed 논문 등"""
|
||||
__tablename__ = 'evidence_reference'
|
||||
__table_args__ = (
|
||||
Index('ix_evidence_component', 'component_code'),
|
||||
Index('ix_evidence_symptom', 'symptom_code'),
|
||||
Index('ix_evidence_pubmed', 'pubmed_id'),
|
||||
{'comment': '동물약 근거 자료 (PubMed 등)'}
|
||||
)
|
||||
|
||||
id = Column(Integer, primary_key=True, comment='고유 ID')
|
||||
|
||||
# 연결 정보
|
||||
component_code = Column(String(50), nullable=True, comment='성분 코드')
|
||||
symptom_code = Column(String(20), nullable=True, comment='증상 코드')
|
||||
product_idx = Column(Integer, nullable=True, comment='제품 IDX')
|
||||
|
||||
# 논문 정보
|
||||
pubmed_id = Column(String(20), nullable=True, comment='PubMed ID')
|
||||
doi = Column(String(100), nullable=True, comment='DOI')
|
||||
title = Column(Text, nullable=False, comment='논문 제목')
|
||||
authors = Column(Text, nullable=True, comment='저자')
|
||||
journal = Column(String(300), nullable=True, comment='저널명')
|
||||
publication_date = Column(Date, nullable=True, comment='출판일')
|
||||
abstract = Column(Text, nullable=True, comment='초록')
|
||||
|
||||
# 분석 정보
|
||||
relevance_score = Column(Float, nullable=True, comment='관련성 점수 (0~1)')
|
||||
key_findings = Column(Text, nullable=True, comment='주요 발견 요약')
|
||||
animal_species = Column(String(100), nullable=True, comment='연구 대상 동물')
|
||||
|
||||
# 메타 정보
|
||||
source = Column(String(50), default='pubmed', comment='출처: pubmed, scholar, manual')
|
||||
fetched_at = Column(DateTime, default=datetime.utcnow, comment='수집 시간')
|
||||
is_verified = Column(Boolean, default=False, comment='검증 여부')
|
||||
|
||||
|
||||
# 28. 테이블 생성
|
||||
Base.metadata.create_all(engine)
|
||||
Reference in New Issue
Block a user