saherPervaiz commited on
Commit
0ccf2c7
·
verified ·
1 Parent(s): 556ffec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -1,27 +1,41 @@
1
  import os
2
  import streamlit as st
3
- from groq import * # Import everything from groq, so you can access the chat functionality
4
 
5
- # Ensure you have the correct API key set in the environment variable
6
  api_key = "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"
7
 
8
  # Streamlit interface
9
  st.title("AI Chatbot with Groq")
10
 
 
11
  user_input = st.text_input("Ask something:", "")
12
 
13
- if user_input:
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  try:
15
- # Create the Groq client using the API key
16
  client = Groq(api_key=api_key)
17
-
18
- # Create chat completion with user input
19
  chat_completion = client.chat.completions.create(
20
  messages=[{"role": "user", "content": user_input}],
21
  model="llama-3.3-70b-versatile"
22
  )
23
-
24
- # Display the response
25
  st.write("AI's response: ")
26
  st.write(chat_completion.choices[0].message.content)
27
 
 
1
  import os
2
  import streamlit as st
3
+ from groq import Groq # Correct import for the Groq client
4
 
5
+ # Ensure the correct API key is set in the environment
6
  api_key = "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"
7
 
8
  # Streamlit interface
9
  st.title("AI Chatbot with Groq")
10
 
11
+ # User input for the chatbot
12
  user_input = st.text_input("Ask something:", "")
13
 
14
+ # Scholarship search option
15
+ search_scholarships = st.checkbox("Search for scholarships")
16
+
17
+ # If user asked about scholarships
18
+ if search_scholarships:
19
+ st.write("You can explore various scholarships for your education:")
20
+ st.write("1. **Merit-based Scholarships**: Awarded based on academic performance.")
21
+ st.write("2. **Need-based Scholarships**: For students who need financial assistance.")
22
+ st.write("3. **Athletic Scholarships**: Given to students excelling in sports.")
23
+ st.write("4. **Government Scholarships**: Offered by governments for local or international students.")
24
+ st.write("5. **Private Scholarships**: Funded by organizations or businesses.")
25
+
26
+ # Process user input to interact with the Groq API
27
+ if user_input and not search_scholarships:
28
  try:
29
+ # Initialize Groq client with the API key
30
  client = Groq(api_key=api_key)
31
+
32
+ # Create a chat completion request using the user's input
33
  chat_completion = client.chat.completions.create(
34
  messages=[{"role": "user", "content": user_input}],
35
  model="llama-3.3-70b-versatile"
36
  )
37
+
38
+ # Display the AI's response
39
  st.write("AI's response: ")
40
  st.write(chat_completion.choices[0].message.content)
41