|
import streamlit as st |
|
import requests |
|
import time |
|
|
|
session = requests.Session() |
|
|
|
|
|
def chat_with_ai(message): |
|
api_url = "https://free-ai-api.devastation-war.repl.co/chat" |
|
payload = {"message": message} |
|
|
|
try: |
|
with session.post(api_url, json=payload) as response: |
|
if response.status_code == 200: |
|
return response.json().get('response') |
|
else: |
|
return {"error": "Failed to get a response from the AI API."} |
|
except requests.RequestException as e: |
|
return {"error": f"Error: {e}"} |
|
|
|
|
|
def main(): |
|
st.title("AI Study Notes Generator π") |
|
st.sidebar.image("logo.png", use_column_width=True) |
|
st.sidebar.markdown("## Class Selection") |
|
st.sidebar.markdown("Please select your class and enter the study topic.") |
|
|
|
|
|
user_class = st.sidebar.selectbox('Select your class:', ['Class 1', 'Class 2', 'Class 3', 'Class 4', 'Class 5', 'Class 6', |
|
'Class 7', 'Class 8', 'Class 9', 'Class 10', 'Class 11', 'Class 12']) |
|
user_input = st.sidebar.text_input(f'Enter your study topic for {user_class}:', placeholder='e.g., History') |
|
|
|
|
|
note_type = st.sidebar.selectbox('Select the type of notes:', ['Detailed Explanation', 'Summary', 'Key Points']) |
|
|
|
|
|
note_format = st.sidebar.selectbox('Select the format of the notes:', ['Text', 'Bulleted List', 'Numbered List']) |
|
|
|
|
|
if st.sidebar.button('Generate Study Notes'): |
|
if user_input.lower() in ['quit', 'exit', 'bye']: |
|
st.success("Goodbye! Have a great day!") |
|
else: |
|
with st.spinner("Requesting HelpingAI..."): |
|
time.sleep(2) |
|
with st.spinner("Generating study notes. Please wait..."): |
|
|
|
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." |
|
response = chat_with_ai(prompt) |
|
|
|
|
|
st.subheader(f"{note_type} in {note_format} format for {user_class} - {user_input}") |
|
st.markdown(response) |
|
|
|
|
|
st.sidebar.markdown("## About") |
|
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.") |
|
|
|
|
|
st.sidebar.markdown("---") |
|
st.sidebar.markdown("Β© 2023 AI Study Notes Generator by OEvortex, HelpingAI") |
|
|
|
|
|
st.markdown("---") |
|
st.markdown("## Welcome to the AI Study Notes Generator! π") |
|
st.markdown("To get started, please select your class and enter your study topic in the sidebar. Then, choose the type and format of the notes you want to generate, and click 'Generate Study Notes'.") |
|
st.markdown("The AI will generate study notes based on your inputs and display them here. You can then use these notes to study and learn about your chosen topic. Happy studying! π") |
|
|
|
if __name__ == "__main__": |
|
main() |
|
|