File size: 1,663 Bytes
26ce7c2
 
0ccf2c7
ca18edf
0ccf2c7
556ffec
ca18edf
556ffec
 
 
0ccf2c7
556ffec
 
0ccf2c7
 
 
 
 
 
 
 
 
 
 
 
 
 
ca18edf
0ccf2c7
556ffec
0ccf2c7
 
556ffec
ca18edf
 
 
0ccf2c7
 
556ffec
 
 
ca18edf
 
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
43
44
import os
import streamlit as st
from groq import Groq  # Correct import for the Groq client

# Ensure the correct API key is set in the environment
api_key = "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"

# Streamlit interface
st.title("AI Chatbot with Groq")

# User input for the chatbot
user_input = st.text_input("Ask something:", "")

# Scholarship search option
search_scholarships = st.checkbox("Search for scholarships")

# If user asked about scholarships
if search_scholarships:
    st.write("You can explore various scholarships for your education:")
    st.write("1. **Merit-based Scholarships**: Awarded based on academic performance.")
    st.write("2. **Need-based Scholarships**: For students who need financial assistance.")
    st.write("3. **Athletic Scholarships**: Given to students excelling in sports.")
    st.write("4. **Government Scholarships**: Offered by governments for local or international students.")
    st.write("5. **Private Scholarships**: Funded by organizations or businesses.")

# Process user input to interact with the Groq API
if user_input and not search_scholarships:
    try:
        # Initialize Groq client with the API key
        client = Groq(api_key=api_key)

        # Create a chat completion request using the user's input
        chat_completion = client.chat.completions.create(
            messages=[{"role": "user", "content": user_input}],
            model="llama-3.3-70b-versatile"
        )

        # Display the AI's response
        st.write("AI's response: ")
        st.write(chat_completion.choices[0].message.content)

    except Exception as e:
        st.error(f"Error: {e}")