File size: 2,053 Bytes
9deb214
98d2653
 
22a3dda
f600486
eff09be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import google.generativeai as genai


# App header
st.header("Know Your Medicine")

# Retrieve the API key from Streamlit secrets
GOOGLE_API_KEY = st.secrets["GEMINI_API_KEY"]

# Configure the Google Generative AI API with your API key
genai.configure(api_key=GOOGLE_API_KEY)

# Input field for the medicine name
st.subheader("Enter Medicine Details:")
medicine_name = st.text_input('Medicine Name', '')

# Create the prompt based on user input
if medicine_name:
    prompt = f"""
    Analyze the following details:
    1. Write the medicine name and purpose of the medicine.
    2. Write down the symptoms for which this medicine should be used.
    3. List the possible side effects of the medicine.
    4. Mention any common drug interactions or contraindications.
    5. Provide common brand names or generic alternatives, if available.
    6. Mention any specific precautions (e.g., avoid alcohol, potential allergies).

    Medicine Name = {medicine_name}
    """

# Button to submit the prompt
if st.button("Generate"):
    if medicine_name:  # Ensure the medicine name is entered
        try:
            # Initialize the generative model (adjust model name if needed)
            model = genai.GenerativeModel('gemini-pro')  # Ensure this is the correct model name

            # Generate content based on the prompt
            response = model.generate_content(prompt)
            
            # Check if there is a response from the model
            if response:
                st.subheader("Generated Medicine Analysis:")
                st.write(response.text)  # Display the generated response
            else:
                st.error("Error: Unable to generate the analysis.")
                
        except Exception as e:
            st.error(f"Error: {e}")
    else:
        st.error("Please enter a medicine name to generate the analysis.")

# Add space or content at the bottom
st.write("\n" * 20)  # Adds space to push the content down

# Footer
st.markdown("Built with 🧠 by Hruday & Google Gemini")