Spaces:
Build error
Build error
File size: 881 Bytes
e9c71f8 | 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 | import os
import streamlit as st
from groq import Groq
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# Retrieve API key
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
# Validate API key
if not GROQ_API_KEY:
st.error("API key is missing! Please check your .env file or environment variables.")
st.stop()
# Initialize Groq client with API key
client = Groq(api_key=GROQ_API_KEY)
st.title("Health Assistant Chatbot")
user_input = st.text_input("Ask a health-related question:")
if st.button("Submit") and user_input:
response = client.chat.completions.create(
model="llama-3.3-70b-versatile",
messages=[{"role": "user", "content": user_input}],
temperature=0.6,
max_completion_tokens=4096,
top_p=0.95,
)
st.write("### Response:")
st.write(response.choices[0].message.content)
|