### Vector Search Service Logic (Java) Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt An example of internal Java service usage for performing hybrid RAG searches. It demonstrates how to query for relevant context by combining user queries with pet-specific diary data and general healthcare information. ```java // Internal service usage example HybridRagService ragService; String ragContext = ragService.search( "강아지 기침 증상", // User query 5L // Pet ID for filtering ); // Returns combined context: // // ### 📚 라이펫 건강 정보: // 기침은 감염, 알레르기, 심장 질환 등 다양한 원인... // // ### 🐾 과거 일기 기록: // [1] 오늘 몽치가 산책 중 기침을 했다 (유사도: 87%) // 날짜: 2026-01-03 // [2] 가끔 기침하는 것 같아서 걱정 (유사도: 72%) // 날짜: 2025-12-28 ``` -------------------------------- ### Health Check API Endpoint Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt This endpoint returns the current health status of the Healthcare AI Chatbot service, including its operational status and the AI models it supports. It is a simple GET request used for monitoring and diagnostics. ```bash curl -X GET http://localhost:8085/api/chat/health ``` -------------------------------- ### Fast Chat with Haiku Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt Provides quick and cost-efficient responses using the Claude Haiku model. This endpoint is suitable for users seeking rapid advice or general pet health tips. ```bash curl -X POST http://localhost:8085/api/chat/haiku \ -H "Content-Type: application/json" \ -d '{ "message": "강아지 건강 팁 알려주세요" }' ``` -------------------------------- ### Fast Chat with Haiku Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt Provides a quick and cost-efficient consultation using the Claude Haiku model. ```APIDOC ## POST /api/chat/haiku ### Description Engage in a fast and cost-effective chat consultation using the Claude Haiku model, suitable for brief inquiries. ### Method POST ### Endpoint `/api/chat/haiku` ### Parameters #### Request Body - **message** (string) - Required - The user's quick query or request. ### Request Example ```json { "message": "강아지 건강 팁 알려주세요" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the response (e.g., "success"). - **model** (string) - The AI model used (e.g., "Claude Haiku (Fast)"). - **response** (string) - The chatbot's concise answer. #### Response Example ```json { "status": "success", "model": "Claude Haiku (Fast)", "response": "강아지 건강 유지를 위한 핵심 팁: 1. 정기적인 산책과 운동 2. 균형잡힌 사료와 충분한 물 3. 연 1-2회 건강검진 4. 예방접종 일정 준수 5. 치아 관리와 그루밍" } ``` ``` -------------------------------- ### Extract Waveform Image Source (Java) Source: https://github.com/skrookies3team/healthcare_aichatbot_service_backend/blob/dev/기다려봐 아무튼 그전에 쓰레드들의 대화들을 바탕으로 계속 이어나가고싶어 공통지침이랑 파일들.md This snippet demonstrates how to select and extract the 'src' attribute of an image element representing a waveform from an HTML document using Jsoup. ```java Element imgElement = doc.selectFirst(".waveform-image, .heart-wave img"); return imgElement != null ? imgElement.attr("src") : null; } } ``` -------------------------------- ### Persona Chat with Hybrid RAG Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt Enables personalized chat by combining pet-specific historical context from diary entries with general veterinary knowledge. Requires userId and petId for context retrieval. ```bash curl -X POST http://localhost:8085/api/chat/persona \ -H "Content-Type: application/json" \ -d '{ "userId": 1, "petId": 5, "message": "우리 강아지가 최근에 잘 지내고 있나요?" }' ``` -------------------------------- ### Kafka Event Consumer Logic (Java) Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt This Java code snippet outlines the logic for consuming diary events from Apache Kafka. It processes events, generates embeddings using AWS Titan, stores them in Milvus, and handles manual offset commits for reliable message processing. ```java // Automatic event processing when Diary Service publishes events // Topic: diary-events // Consumer Group: healthcare-group // Example Kafka message: // { // "eventType": "DIARY_CREATED", // "diaryId": 42, // "userId": 1, // "petId": 5, // "content": "오늘 몽치가 산책 중 기침을 했다. 조금 걱정된다.", // "imageUrl": "https://s3.../image.jpg", // "createdAt": "2026-01-03T09:00:00" // } // Processing flow: // 1. Event consumed from Kafka // 2. Content vectorized using AWS Titan Embeddings (1024 dimensions) // 3. Vector stored in Milvus with metadata (userId, petId, diaryId) // 4. Available for RAG retrieval in future chats // 5. Manual offset commit after successful processing ``` -------------------------------- ### HeartHealthRecord Entity and Factory Method (Java) Source: https://github.com/skrookies3team/healthcare_aichatbot_service_backend/blob/dev/기다려봐 아무튼 그전에 쓰레드들의 대화들을 바탕으로 계속 이어나가고싶어 공통지침이랑 파일들.md Defines the JPA entity `HeartHealthRecord` for storing heart health data in the database. It includes fields mapped to database columns and a factory method `fromWithaPetData` to create an entity instance from the `WithaPetReportData` DTO. ```java @Entity @Table(name = "heart_health_records") @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class HeartHealthRecord { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(nullable = false) private Long petId; // user_service의 Pet ID @Column(unique = true) private String withaPetReportId; // P000004363 @Column private String withaPetAuscultationId; // 000000144470 @Column private Integer heartRate; @Column(columnDefinition = "TEXT") private String aiDiagnosis; @Column private String audioFileUrl; @Column private String waveformImageUrl; @Column private LocalDateTime recordedAt; @Column private Boolean isAbnormal; @CreatedDate @Column(updatable = false) private LocalDateTime createdAt; @LastModifiedDate private LocalDateTime updatedAt; // 스크래핑 데이터로 생성하는 팩토리 메서드 public static HeartHealthRecord fromWithaPetData( Long petId, WithaPetReportData data) { HeartHealthRecord record = new HeartHealthRecord(); record.petId = petId; record.withaPetReportId = data.getReportId(); record.withaPetAuscultationId = data.getAuscultationId(); record.heartRate = data.getHeartRate(); record.aiDiagnosis = data.getAiDiagnosis(); record.audioFileUrl = data.getAudioFileUrl(); record.waveformImageUrl = data.getWaveformImageUrl(); record.recordedAt = data.getRecordDate(); record.isAbnormal = data.getIsAbnormal(); return record; } } ``` -------------------------------- ### Basic Chat with Sonnet + RAG Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt Engages in a basic chat using the Claude Sonnet model, enhanced with RAG context from healthcare documents. ```APIDOC ## POST /api/chat/test-chat ### Description Send a message to the chatbot for consultation using Claude Sonnet with RAG-enhanced context derived from general veterinary knowledge. ### Method POST ### Endpoint `/api/chat/test-chat` ### Parameters #### Request Body - **message** (string) - Required - The user's query or message for the chatbot. ### Request Example ```json { "message": "강아지가 기침을 해요. 어떻게 해야 하나요?" } ``` ### Response #### Success Response (200) - **success** (boolean) - Indicates if the request was processed successfully. - **model** (string) - The AI model used for the response (e.g., "Sonnet"). - **response** (string) - The chatbot's answer to the user's query. #### Response Example ```json { "success": true, "model": "Sonnet", "response": "강아지의 기침은 여러 원인이 있을 수 있습니다. 켄넬 코프(kennel cough) 같은 감염, 알레르기, 또는 심장 질환의 징후일 수 있습니다. 기침이 지속되거나 다른 증상(구토, 식욕부진)이 동반되면 즉시 동물병원 방문을 권장합니다." } ``` ``` -------------------------------- ### WithaPetReportData DTO (Java) Source: https://github.com/skrookies3team/healthcare_aichatbot_service_backend/blob/dev/기다려봐 아무튼 그전에 쓰레드들의 대화들을 바탕으로 계속 이어나가고싶어 공통지침이랑 파일들.md Defines the Data Transfer Object (DTO) for holding report data related to pet health from the WithaPet service. It includes fields for report ID, pet name, heart rate, recording date, AI diagnosis, audio/waveform URLs, normal range, abnormality status, and auscultation ID. ```java @Data @Builder @NoArgsConstructor @AllArgsConstructor public class WithaPetReportData { private String reportId; // P000004363 private String petName; // 강아지 이름 private Integer heartRate; // 95 bpm private LocalDateTime recordDate; // 청진 일시 private String aiDiagnosis; // AI 진단 결과 private String audioFileUrl; // 심장음 오디오 URL private String waveformImageUrl; // 파형 이미지 URL private String normalRange; // 정상 범위 (75-110 bpm) private Boolean isAbnormal; // 이상 여부 private String auscultationId; // 000000144470 (포탈 링크용) } ``` -------------------------------- ### Pet Persona Chat Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt Enables interactive conversations where the pet "speaks" in the first person, drawing from its memory of diary entries. ```APIDOC ## POST /api/chat/persona (Pet Persona Chat) ### Description Allows for interactive conversations where the chatbot responds as if it were the pet, using information and memories extracted from the pet's diary entries. The pet "speaks" in the first person. ### Method POST ### Endpoint `/api/chat/persona` ### Parameters #### Request Body - **petId** (integer) - Required - The unique identifier for the pet whose persona is being adopted. - **message** (string) - Required - A message directed to the pet, initiating the conversation. ### Request Example ```json { "petId": 1, "message": "몽치야, 오늘 기분 어때?" } ``` ### Response #### Success Response (200) - **response** (string) - The pet's first-person response, reflecting its "mood" and "memories". - **petId** (string) - The identifier of the pet whose persona is being used. #### Response Example ```json { "response": "좋아! 🐾 지난주에 산책 갔던 공원 또 가고 싶어! 그때 새로운 친구도 만났잖아. 나 요즘 엄청 건강해!", "petId": "1" } ``` ``` -------------------------------- ### Persona Chat with Hybrid RAG Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt Delivers advanced personalized chat by combining pet-specific diary context with general health knowledge using hybrid RAG. ```APIDOC ## POST /api/chat/persona (User Persona Chat) ### Description Provides an advanced personalized chat experience by integrating a user's pet-specific historical context from diary entries with general veterinary knowledge. This endpoint utilizes a hybrid RAG approach for context-aware responses. ### Method POST ### Endpoint `/api/chat/persona` ### Parameters #### Request Body - **userId** (integer) - Required - The unique identifier for the user. - **petId** (integer) - Required - The unique identifier for the pet. - **message** (string) - Required - The user's query about their pet's well-being or history. ### Request Example ```json { "userId": 1, "petId": 5, "message": "우리 강아지가 최근에 잘 지내고 있나요?" } ``` ### Response #### Success Response (200) - **answer** (string) - A personalized response generated based on the pet's history and general knowledge. - **relatedDiaries** (array of integers) - A list of diary entry IDs relevant to the query. - **timestamp** (string) - The timestamp when the response was generated. #### Response Example ```json { "answer": "지난주 일기를 보니 산책도 잘 다니고 사료도 잘 먹고 있어요! 특히 3일 전에 새로운 친구 강아지를 만나서 즐겁게 놀았던 기록이 있네요. 전반적으로 건강하고 활발한 상태입니다.", "relatedDiaries": [123, 118, 115], "timestamp": "2026-01-03T10:30:00" } ``` ``` -------------------------------- ### Basic Chat with Sonnet + RAG Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt Allows users to send a message to the chatbot and receive a response generated by the Claude Sonnet model, enhanced with RAG context from general healthcare documents. This endpoint is for standard consultations. ```bash curl -X POST http://localhost:8085/api/chat/test-chat \ -H "Content-Type: application/json" \ -d '{ "message": "강아지가 기침을 해요. 어떻게 해야 하나요?" }' ``` -------------------------------- ### Draggable Chat Bubble Component in React Source: https://github.com/skrookies3team/healthcare_aichatbot_service_backend/blob/dev/혹시그럼 헬스케어 챗봇 서비스 MSA 아키텍처 개발 로드맵.pdf 이거는 내용을 전부 분석.md This React component, ChatBubble, provides a draggable interface for chat bots. It utilizes React Spring for smooth animations and Use Gesture for drag functionality. The component displays either a pet avatar for healthcare bots or a general icon, along with a notification badge for unread messages. It also persists the bubble's position using local storage and handles click events to open/close chat interfaces. ```typescript import { useRef } from 'react'; import { useSpring, animated, config } from '@react-spring/web'; import { useDrag } from '@use-gesture/react'; import { PetAvatar } from './PetAvatar'; import { NotificationBadge } from './NotificationBadge'; import { useChatHeadsStore } from './store/chatHeadsStore'; interface ChatBubbleProps { botType: 'healthcare' | 'general'; icon?: string; } /** * 드래그 가능한 채팅 버블 컴포넌트 * - React Spring + Use Gesture 활용 * - 펫 프로필 사진 표시 (Healthcare) * - 읽지 않은 메시지 배지 * - 위치 저장 (localStorage) */ export function ChatBubble({ botType, icon }: ChatBubbleProps) { const bubbleRef = useRef(null); const { currentPet, activeChatBot, unreadCount, bubblePositions, setActiveChatBot, updateBubblePosition, resetUnreadCount, } = useChatHeadsStore(); // React Spring 애니메이션 const [{ x, y }, api] = useSpring(() => ({ x: bubblePositions[botType].x, y: bubblePositions[botType].y, config: config.gentle, })); // Use Gesture 드래그 핸들러 const bind = useDrag( ({ offset: [ox, oy], active }) => { // 드래그 중에는 즉시 이동 api.start({ x: ox, y: oy, immediate: active, }); // 드래그 종료 시 위치 저장 if (!active) { updateBubblePosition(botType, { x: ox, y: oy }); } }, { from: () => [x.get(), y.get()], bounds: { left: 0, right: window.innerWidth - 80, top: 0, bottom: window.innerHeight - 80, }, } ); const handleClick = (e: React.MouseEvent) => { // 드래그가 아닌 클릭일 때만 채팅 창 열기 const wasDragging = bubbleRef.current?.classList.contains('dragging'); if (!wasDragging) { setActiveChatBot(activeChatBot === botType ? null : botType); if (unreadCount[botType] > 0) { resetUnreadCount(botType); } } }; const isActive = activeChatBot === botType; return ( {/* 펫 프로필 (Healthcare) 또는 아이콘 (General) */} {botType === 'healthcare' && currentPet ? ( ) : (
{icon || '💬'}
)} {/* 읽지 않은 메시지 배지 */} {unreadCount[botType] > 0 && ( )} {/* 호버 툴팁 */}
{botType === 'healthcare' ? `${currentPet?.name || 'Pet'} Chat` : 'General Info'}
); } ``` -------------------------------- ### Pet Persona Chat (First-Person) Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt Facilitates an interactive conversation where the chatbot responds as if it were the pet, drawing on memories from diary entries. This endpoint is for engaging, pet-centric interactions. ```bash curl -X POST http://localhost:8085/api/chat/persona \ -H "Content-Type: application/json" \ -d '{ "petId": 1, "message": "몽치야, 오늘 기분 어때?" }' ``` -------------------------------- ### Health Check Endpoint Source: https://context7.com/skrookies3team/healthcare_aichatbot_service_backend/llms.txt Checks the health status of the Healthcare AI Chatbot Service and lists available AI models. ```APIDOC ## GET /api/chat/health ### Description Returns the service health status and lists the AI models that are currently available for use. ### Method GET ### Endpoint `/api/chat/health` ### Parameters None ### Request Example ```bash curl -X GET http://localhost:8085/api/chat/health ``` ### Response #### Success Response (200) - **status** (string) - The health status of the service (e.g., "UP"). - **service** (string) - The name of the service. - **models** (string) - A comma-separated list of available AI models. - **port** (string) - The port the service is running on. #### Response Example ```json { "status": "UP", "service": "Healthcare AI Chatbot", "models": "Sonnet (default), Haiku (fast)", "port": "8085" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.