Spaces:
Sleeping
Sleeping
feat: implement medical API call and enhance soft medical triage functionality
Browse filesFiles changed (2)
441 unmodified lines442443444445446447441 unmodified linescall_type="spiritual_analysis",agent_name="SpiritualDistressAnalyzer")# Factory function for easy client creationdef create_ai_client(agent_name: str) -> UniversalAIClient:441 unmodified lines442443444445446447448449450451452453454455456457458459460461462463464465466467468469470441 unmodified linescall_type="spiritual_analysis",agent_name="SpiritualDistressAnalyzer")def call_medical_api(self, system_prompt: str, user_prompt: str,temperature: float = 0.3) -> str:"""Call AI API for medical assistance.Uses the soft medical triage agent configuration.Args:system_prompt: System prompt for the AIuser_prompt: User prompt/message for medical guidancetemperature: Temperature for response generationReturns:AI response as string"""return self.generate_response(system_prompt=system_prompt,user_prompt=user_prompt,temperature=temperature,call_type="medical_assistance",agent_name="SoftMedicalTriage")# Factory function for easy client creationdef create_ai_client(agent_name: str) -> UniversalAIClient:
84 unmodified lines8586878889909184 unmodified linesdef conduct_triage(self, message: str, background: ClinicalBackground, history: List) -> str:"""Conduct soft medical triage."""return "Thank you for sharing. How can I help you today?"import os84 unmodified lines85868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513684 unmodified linesdef conduct_triage(self, message: str, background: ClinicalBackground, history: List) -> str:"""Conduct soft medical triage."""try:# Build conversation contextcontext = ""if history:recent_history = history[-6:] # Last 3 exchangescontext = "Recent conversation:\n"for msg in recent_history:context += f"{msg.role}: {msg.message}\n"context += "\n"# Build patient contextpatient_context = f"""Patient: {background.patient_name}, {background.age} years oldMedical conditions: {', '.join(background.conditions)}Primary goal: {background.primary_goal}Exercise preferences: {', '.join(background.exercise_preferences)}Exercise limitations: {', '.join(background.exercise_limitations)}"""# Create prompt for medical assistantprompt = f"""{context}Patient context:{patient_context}Current message: "{message}"Provide helpful medical guidance and support."""# Get system prompt for medical assistantfrom src.config.prompts import SYSTEM_PROMPT_SOFT_MEDICAL_TRIAGE# Call AIresponse = self.api.call_medical_api(system_prompt=SYSTEM_PROMPT_SOFT_MEDICAL_TRIAGE,user_prompt=prompt)return responseexcept Exception as e:# Fallback responseimport logginglogging.error(f"Medical triage error: {e}")# Detect language for fallbackif any(ord(c) >= 0x0400 and ord(c) <= 0x04FF for c in message):return "Дякую, що звернулися. Як я можу вам допомогти з вашим здоров'ям сьогодні?"else:return "Thank you for reaching out. How can I help you with your health today?"import os
src/core/ai_client.py+23
src/core/core_classes.py+46-1