Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from google import genai | |
| from google.genai import types | |
| def generate_response(api_key, text1, text2): | |
| # Combine the texts to form a prompt | |
| prompt = f"{text1} {text2}" | |
| # Initialize the genai client with the provided API key | |
| client = genai.Client(api_key=api_key) | |
| # Define the generation configuration | |
| generate_content_config = types.GenerateContentConfig( | |
| temperature=1, | |
| top_p=0.95, | |
| top_k=40, | |
| max_output_tokens=300 | |
| ) | |
| # Generate the response from the model | |
| result = client.models.generate_content( | |
| model="gemini-1.5-pro", # Specify the model here | |
| contents=[types.Content(parts=[types.Part.from_text(text=prompt)])], | |
| config=generate_content_config | |
| ) | |
| # Extract and return the text response | |
| text_response = result.candidates[0].content.parts[0].text | |
| return text_response | |
| def main(): | |
| with gr.Blocks() as demo: | |
| with gr.Row(): | |
| api_key_input = gr.Textbox( | |
| label="Gemini API Key", | |
| placeholder="Enter your Gemini API Key here", | |
| type="password" # This makes the input behave like a password field | |
| ) | |
| text_input_1 = gr.Textbox( | |
| label="General Instruction", | |
| placeholder="For the provided list of initial investigation, course of action, create 4 paragraph. 1st for the patient on general english on the current situation, what is being done, what he/she can expect. Next for internal specialist on what is done, observations, suggestions more in line with actual clinical terms. Next paragraph on full clinical summary so that it can be produced to the next specialist outside the current clinic." | |
| ) | |
| text_input_2 = gr.Textbox( | |
| label="Specific Instruction", | |
| placeholder='''Level 1 Physio Comments :Patient exhibits mild lumbar strain with associated knee instability. Recommend core stabilization exercises, targeted stretching, and progressive strengthening. Monitor response to therapy and adjust accordingly. | |
| Internal Comments : Patient is responding well to initial treatment. Requires ongoing monitoring for pain management and mobility improvements. Consider additional assessments if progress stalls. | |
| Level 2 Physio Comments : Patient has shown moderate improvement with current treatment. Recommend progressing to advanced mobility exercises and strength training. Re-evaluate in the next session for further modifications. | |
| Consult ::: BP: 120/80 , Temperature: 98.6°F , Heart Rate: 72 , Respiratory Rate: 16 , SpO2: 98% , Height: 170 , Weight: 70 , BMI: 24.2 | |
| Current Medications ::: "Diabetes Mellitus: Metformin 500mg, Insulin as required , Hypertension: N/A , Dyslipidemia : N/A , Thyroid : N/A , Anti-Coagulants: Warfarin 2mg , Anti-Depressants: N/A , Bronchodilators: N/A , Anti Inflammatory : N/A , Steriods: N/A , Recommended Food Supplements: Vitamin D, Omega-3 , Others: N/A" | |
| Family Medical History ::: Fathers: Asthma, migraines , Mothers: N/A , Siblings: N/A , Others: N/A | |
| Cervical :: [["Forward Head Posture ","Mild to Moderate"],["Forward Flexed","Present with discomfort"],["Forward Extended ","Slightly restricted"],["Others","No significant issues"]] | |
| Thoracic :: [["Kyphotic ","Mild curvature observed"],["Scoliotic","No significant deviation"],["Others","Normal thoracic alignment"]] | |
| Lumbar :: [["Lordotic","Increased lumbar curve observed"],["Kyphotic ","No abnormal kyphosis detected"],["Scoliotic","Mild scoliosis to the left"],["Others","Normal spinal alignment"]] | |
| Sacrum :: [["Hiked","Right sacral hike observed"],["Anterior Tilt","Mild anterior pelvic tilt noted"],["Posterior Tilt","No significant posterior tilt"],["Others","Normal sacral alignment"]] | |
| Flexibility Test :: [["Apleys Scratch Test","FXTPP","FXTTP"],["Thomas Test","FXTTNA","FXTTP"],["Pects Muscle Test","FXTPP","FXTTNA"],["90 - 90 Test","FXTPPP","FXTPPP"],["Piriformis Test","FXTTP","FXTPPP"],["Sit & Reach Test ","FXTPP","FXTPP"],["Quads Muscle Test","FXTPP","FXTPPP"],["SLR","FXTPP","FXTTNA"],["Gastro - Soleus","FXTTP","FXTPPP"]] | |
| Workouts ::: [["Squats","Enhances lower body stability "],["Push-ups","Improves upper body strength"],["Lunges","Improves balance and flexibility"],["",""],["",""]] | |
| ''' | |
| ) | |
| submit_btn = gr.Button("Generate") | |
| output_text = gr.Textbox(label="Gemini Model Output", placeholder="The response will appear here") | |
| # Set up the interaction | |
| submit_btn.click( | |
| fn=generate_response, | |
| inputs=[api_key_input, text_input_1, text_input_2], | |
| outputs=output_text | |
| ) | |
| return demo | |
| app = main() | |
| app.launch() | |