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.