File size: 3,280 Bytes
380a0b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import os
from groq import Groq

# Set API Key (Replace with your actual API key)
os.environ["GROQ_API_KEY"] = "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"

# Initialize the Groq Client
client = Groq(api_key=os.environ["GROQ_API_KEY"])

# Test Query
chat_completion = client.chat.completions.create(
    messages=[{"role": "user", "content": "Explain the importance of fast language models"}],
    model="llama-3.3-70b-versatile",
)

# Print response
print(chat_completion.choices[0].message.content)
import random
import time
import pandas as pd

# Function to simulate data updates
def get_real_time_data():
    return {
        "Heart Rate (BPM)": random.randint(60, 120),
        "Oxygen Saturation (%)": round(random.uniform(85, 100), 1),
        "Blood Pressure (mmHg)": f"{random.randint(90, 120)}/{random.randint(60, 80)}",
        "Respiratory Rate (BPM)": random.randint(12, 20),
        "Hydration Level (%)": round(random.uniform(40, 100), 1),
        "Battery Level (%)": random.randint(10, 100),
        "Food Supply (Days)": random.randint(1, 10),
        "Water Supply (Liters)": random.randint(1, 50),
    }

# Testing the function
for _ in range(5):
    print(get_real_time_data())
    time.sleep(1)

def predict_survival_time(data):
    oxygen_factor = data["Oxygen Saturation (%)"] / 100
    hydration_factor = data["Hydration Level (%)"] / 100
    battery_factor = data["Battery Level (%)"] / 100
    food_factor = data["Food Supply (Days)"] / 10

    survival_hours = (oxygen_factor + hydration_factor + battery_factor + food_factor) * 10
    return round(survival_hours, 2)

# Example test
sample_data = get_real_time_data()
print("Predicted Survival Time (Hours):", predict_survival_time(sample_data))

import streamlit as st
import pandas as pd
import random
import time

st.title("🚀 Astronaut Survival Monitor")

# Simulating real-time data updates
def get_real_time_data():
    return {
        "Heart Rate (BPM)": random.randint(60, 120),
        "Oxygen Saturation (%)": round(random.uniform(85, 100), 1),
        "Blood Pressure (mmHg)": f"{random.randint(90, 120)}/{random.randint(60, 80)}",
        "Respiratory Rate (BPM)": random.randint(12, 20),
        "Hydration Level (%)": round(random.uniform(40, 100), 1),
        "Battery Level (%)": random.randint(10, 100),
        "Food Supply (Days)": random.randint(1, 10),
        "Water Supply (Liters)": random.randint(1, 50),
    }

# Survival Time Prediction
def predict_survival_time(data):
    oxygen_factor = data["Oxygen Saturation (%)"] / 100
    hydration_factor = data["Hydration Level (%)"] / 100
    battery_factor = data["Battery Level (%)"] / 100
    food_factor = data["Food Supply (Days)"] / 10

    survival_hours = (oxygen_factor + hydration_factor + battery_factor + food_factor) * 10
    return round(survival_hours, 2)

# Real-time simulation
data = get_real_time_data()
survival_time = predict_survival_time(data)

st.metric("Predicted Survival Time", f"{survival_time} Hours")

# Display real-time health and resource data
st.write("### Health Metrics")
for key, value in data.items():
    st.metric(key, value)

st.warning("🚨 Alert: Low Oxygen or Power Levels Detected!") if data["Oxygen Saturation (%)"] < 90 or data["Battery Level (%)"] < 20 else None