| import os |
| import streamlit as st |
| from groq import Groq |
| from dotenv import load_dotenv |
|
|
| |
| load_dotenv() |
| API_KEY = os.getenv("GROQ_API_KEY") |
|
|
| |
| client = Groq(api_key=API_KEY) |
|
|
| |
| st.set_page_config(page_title="Life Experience Chatbot", layout="centered") |
| st.title("π AI Life Experience Chatbot") |
|
|
| |
| st.markdown( |
| """ |
| <style> |
| body { font-size: 18px; } |
| .stTextArea textarea { font-size: 16px !important; } |
| .stButton button { font-size: 16px !important; padding: 10px; } |
| </style> |
| """, |
| unsafe_allow_html=True, |
| ) |
|
|
| |
| life_topics = [ |
| "Police Life", "Student Life", "Engineer Life", "Doctor Life", "Shopkeeper Life", "Labour Life", "Freeman Life", |
| "Hostel Life", "Home Life", "Karachi Life", "Islamabad Life", "Tharimirwah Life", "Khairpur Life", "Pith Ghoth Life", |
| "Sukkur Life", "Ghotki Life", "Rancour Life", "Pakistan Life", "Qatar Life", "Saudi Life", "Iron Life" |
| ] |
|
|
| |
| selected_life = st.selectbox("Choose a Life Experience to Explore:", life_topics) |
|
|
| |
| user_input = st.text_area("Ask about this lifestyle (optional):", placeholder="E.g., 'What challenges do police officers face?'") |
|
|
| |
| if st.button("Get AI Insight"): |
| user_prompt = f"Describe the lifestyle of {selected_life}. {user_input if user_input else ''}" |
|
|
| try: |
| response = client.chat.completions.create( |
| model="llama-3.3-70b-versatile", |
| messages=[{"role": "user", "content": user_prompt}] |
| ) |
| st.write("### π AI-Generated Insight:") |
| st.write(response.choices[0].message.content) |
| except Exception as e: |
| st.error(f"Error: {e}") |