Spaces:
Runtime error
Runtime error
Create app.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344import osimport streamlit as stimport openai
st.set_page_config(page_title="HealthTrendBot", layout="wide")
api_key = os.getenv("DEEP_SEEK_API")if not api_key: st.error("Please set the DEEP_SEEK_API environment variable.") st.stop()
openai.api_key = api_keyopenai.api_base = "https://api.deepseek.com" # if required
if 'conversation_history' not in st.session_state: st.session_state.conversation_history = [ {"role": "system", "content": "You are a knowledgeable assistant specializing in public health trends."} ]
st.title("HealthTrendBot: Public Health Trend Analyzer")
# Display conversationfor msg in st.session_state.conversation_history[1:]: if msg["role"] == "user": st.markdown(f"**You:** {msg['content']}") else: st.markdown(f"**HealthTrendBot:** {msg['content']}")
user_input = st.text_input("Your Message:")
if st.button("Send") and user_input.strip(): st.session_state.conversation_history.append({"role": "user", "content": user_input}) try: response = openai.ChatCompletion.create( model="deepseek-chat", messages=st.session_state.conversation_history ) assistant_reply = response.choices[0].message["content"] st.session_state.conversation_history.append({"role": "assistant", "content": assistant_reply}) st.experimental_rerun() except Exception as e: st.error(f"Error: {e}")elif st.button("Send"): st.warning("Please enter a message.")app.pyAdded+44