|
|
|
|
|
|
|
|
|
|
|
import sys |
|
|
import os |
|
|
sys.path.insert(0, os.path.dirname(__file__)) |
|
|
|
|
|
|
|
|
if not os.getenv("OPENAI_API_KEY"): |
|
|
print("⚠️ OPENAI_API_KEY가 설정되지 않았습니다. .env 파일을 확인하세요.") |
|
|
|
|
|
from gradio_app import process_text |
|
|
|
|
|
def test_process_text(): |
|
|
"""process_text 함수 테스트""" |
|
|
print("=" * 60) |
|
|
print("🧪 process_text 함수 테스트 (새로운 파이프라인)") |
|
|
print("=" * 60) |
|
|
|
|
|
|
|
|
text = "이거 가지고 놀래?" |
|
|
context_situation = "장난감 매장에서" |
|
|
situation = "놀이 시간" |
|
|
profile_id = None |
|
|
analysis_mode = "detailed" |
|
|
|
|
|
print("\n📝 입력:") |
|
|
print(f" - 텍스트: {text}") |
|
|
print(f" - 상황: {context_situation}") |
|
|
print(f" - 분석 모드: {analysis_mode}") |
|
|
|
|
|
try: |
|
|
print("\n🔄 process_text 실행 중...") |
|
|
result = process_text(text, context_situation, situation, profile_id, analysis_mode) |
|
|
|
|
|
is_echo, confidence_html, quick_summary, three_step, detailed_report, save_message, analysis_id = result |
|
|
|
|
|
print("\n✅ process_text 실행 성공!") |
|
|
print(f"\n📊 결과:") |
|
|
print(f" - 반향어 감지: {is_echo}") |
|
|
print(f" - 분석 ID: {analysis_id}") |
|
|
print(f" - 저장 메시지: {save_message}") |
|
|
print(f"\n - 신뢰도 HTML 길이: {len(confidence_html)} 문자") |
|
|
print(f" - 빠른 요약 길이: {len(quick_summary)} 문자") |
|
|
print(f" - 3단계 변환 길이: {len(three_step)} 문자") |
|
|
print(f" - 상세 보고서 길이: {len(detailed_report)} 문자") |
|
|
|
|
|
print("\n📄 빠른 요약:") |
|
|
print(quick_summary[:200] + "..." if len(quick_summary) > 200 else quick_summary) |
|
|
|
|
|
print("\n📄 상세 보고서 (처음 500자):") |
|
|
print(detailed_report[:500] + "..." if len(detailed_report) > 500 else detailed_report) |
|
|
|
|
|
return True |
|
|
|
|
|
except Exception as e: |
|
|
print(f"\n❌ process_text 실행 실패: {e}") |
|
|
import traceback |
|
|
traceback.print_exc() |
|
|
return False |
|
|
|
|
|
if __name__ == "__main__": |
|
|
success = test_process_text() |
|
|
sys.exit(0 if success else 1) |
|
|
|
|
|
|