Spaces:
Sleeping
Sleeping
File size: 1,191 Bytes
865f9e2 7bcdd52 865f9e2 7bcdd52 e867cd4 7bcdd52 865f9e2 7bcdd52 865f9e2 7bcdd52 e867cd4 7bcdd52 | 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 | import os
import streamlit as st
from groq import Groq
# Set your API key in the environment
os.environ["GROQ_API_KEY"] = "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"
# Initialize Groq client with the API key from the environment
client = Groq(
api_key=os.environ.get("GROQ_API_KEY"),
)
# Function to interact with Groq API and get responses
def get_chat_response(user_message):
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": user_message,
}
],
model="llama-3.3-70b-versatile",
)
return chat_completion.choices[0].message.content
# Streamlit UI setup
st.title("AI-based Healthcare Chatbot")
st.write("Welcome to the Healthcare Chatbot! Ask me anything about health.")
# Text input for user query
user_input = st.text_input("Your Question:")
if user_input:
# Get the response from Groq API
response = get_chat_response(user_input)
# Display the chatbot's response
st.write("Chatbot Response:")
st.write(response)
# You can add more user-friendly features like history or options to rephrase responses, etc.
|