Abhaykoul commited on
Commit
f8ddf42
β€’
1 Parent(s): 216a21d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -1,18 +1,16 @@
1
  import streamlit as st
2
  import requests
3
  import time
4
- import os
5
- session = requests.Session()
6
 
7
  # Function to interact with the AI
8
  def chat_with_ai(message):
9
- api_url = os.getenv("CHAT_API_URL")
10
  payload = {"message": message}
11
 
12
  try:
13
- with session.post(api_url, json=payload) as response:
14
  if response.status_code == 200:
15
- return response.json().get('response') # Access 'response' key
16
  else:
17
  return {"error": "Failed to get a response from the AI API."}
18
  except requests.RequestException as e:
@@ -21,7 +19,7 @@ def chat_with_ai(message):
21
  # Streamlit app
22
  def main():
23
  st.title("AI Study Notes Generator πŸ“š")
24
- st.sidebar.image("logo.png", use_column_width=True) # Display a logo in the sidebar
25
  st.sidebar.markdown("## Class Selection")
26
  st.sidebar.markdown("Please select your class and enter the study topic.")
27
 
@@ -42,10 +40,10 @@ def main():
42
  st.success("Goodbye! Have a great day!")
43
  else:
44
  with st.spinner("Requesting HelpingAI..."):
45
- time.sleep(2) # Wait for 2 seconds
46
  with st.spinner("Generating study notes. Please wait..."):
47
  # Detailed and descriptive prompt
48
- prompt = f"Using advanced AI capabilities, generate {note_type.lower()} for students of {user_class}. The topic of study is '{user_input}'. The notes should be presented in a {note_format.lower()} format to facilitate easy understanding and learning. The content should be accurate, comprehensive, and tailored to the academic level of {user_class}. The goal is to provide a valuable learning resource that can help students grasp the topic effectively."
49
  response = chat_with_ai(prompt)
50
 
51
  # Display generated study notes
@@ -54,11 +52,11 @@ def main():
54
 
55
  # About section
56
  st.sidebar.markdown("## About")
57
- st.sidebar.markdown("This application uses AI to generate study notes based on the class and topic you provide. It's designed to help students get a quick overview of a topic. The application is made by Abhay Koul, also known as OEvortex, and it uses the API of HelpingAI, a company by OEvortex. You can learn more about OEvortex on YouTube.")
58
 
59
  # Footer
60
  st.sidebar.markdown("---")
61
- st.sidebar.markdown("Β© 2023 AI Study Notes Generator by OEvortex, HelpingAI")
62
 
63
  # Main area
64
  st.markdown("---")
 
1
  import streamlit as st
2
  import requests
3
  import time
 
 
4
 
5
  # Function to interact with the AI
6
  def chat_with_ai(message):
7
+ api_url = "https://abhaykoul-webscout1.hf.space/chat"
8
  payload = {"message": message}
9
 
10
  try:
11
+ with requests.post(api_url, json=payload) as response:
12
  if response.status_code == 200:
13
+ return response.json().get('response') # Access 'response' key
14
  else:
15
  return {"error": "Failed to get a response from the AI API."}
16
  except requests.RequestException as e:
 
19
  # Streamlit app
20
  def main():
21
  st.title("AI Study Notes Generator πŸ“š")
22
+ st.sidebar.image("logo.png", use_column_width=True) # Display a logo in the sidebar
23
  st.sidebar.markdown("## Class Selection")
24
  st.sidebar.markdown("Please select your class and enter the study topic.")
25
 
 
40
  st.success("Goodbye! Have a great day!")
41
  else:
42
  with st.spinner("Requesting HelpingAI..."):
43
+ time.sleep(2) # Wait for 2 seconds
44
  with st.spinner("Generating study notes. Please wait..."):
45
  # Detailed and descriptive prompt
46
+ prompt = f"Using advanced AI capabilities, generate {note_type.lower()} for students of {user_class}. The topic of study is '{user_input}'. The notes should be presented in a {note_format.lower()} format to facilitate easy understanding and learning. The content should be accurate, comprehensive, and tailored to the academic level of {user_class}. The goal is to provide a valuable learning resource that can help students grasp the topic effectively also just make it easier for them to study and only notes."
47
  response = chat_with_ai(prompt)
48
 
49
  # Display generated study notes
 
52
 
53
  # About section
54
  st.sidebar.markdown("## About")
55
+ st.sidebar.markdown("This application uses AI to generate study notes based on the class and topic you provide. It's designed to help students get a quick overview of a topic and makes it easier to understand and learn.")
56
 
57
  # Footer
58
  st.sidebar.markdown("---")
59
+ st.sidebar.markdown("Β© 2024 AI Study Notes Generator OEvortex")
60
 
61
  # Main area
62
  st.markdown("---")