ShivaPrakash commited on
Commit
31e723c
1 Parent(s): 8d55312

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +172 -0
app.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import docx
4
+ import io
5
+ import base64
6
+ # Sample data
7
+ questions = [
8
+ {"no": 1, "question": "What is the capital of France?", "a": "Paris", "b": "London", "c": "Berlin", "d": "Madrid", "answer": "Paris"},
9
+ {"no": 2, "question": "What is the largest planet in our solar system?", "a": "Earth", "b": "Mars", "c": "Jupiter", "d": "Saturn", "answer": "Jupiter"},
10
+ # Add more questions as needed
11
+ ]
12
+
13
+ text = """Explore pathways to get started with learning and working with Generative AI.Lesson Activities:Introduction (10 minutes):
14
+ Briefly discuss the history and evolution of AI.
15
+ Introduce the concept of Generative AI and its different types (e.g., text, image, audio).
16
+ Showcase examples of Generative AI applications in various industries.
17
+ Challenges and Opportunities (15 minutes):
18
+ Discuss the rapid pace of advancements in AI and the resulting confusion.
19
+ Address ethical concerns and potential biases in AI systems.
20
+ Explore the vast potential of Generative AI for innovation and problem-solving.
21
+ The Generative AI Engineer (20 minutes):
22
+ Define the role and responsibilities of a Generative AI engineer.
23
+ Explain the skillset required, including machine learning, software engineering, and problem-solving skills.
24
+ Discuss the importance of bridging the gap between research and practical applications.
25
+ Getting Started with Generative AI (25 minutes):
26
+ Provide resources and tools for learning about Generative AI.
27
+ Introduce popular platforms and frameworks for building AI models.
28
+ Share tips for building a portfolio and gaining practical experience.
29
+ Q&A and Discussion (30 minutes):
30
+ Answer questions from students and address their concerns.
31
+ Encourage discussion and sharing of ideas.
32
+ Motivate students to explore and experiment with Generative AI."""
33
+
34
+ # Initialize score
35
+ score = 0
36
+ answer = ['','','','','','','','','','']
37
+ i = 0
38
+
39
+
40
+ st.set_page_config(page_title="Dhrona.ai", page_icon="🏹")
41
+ st.title("🏹 Dhrona.ai 🏹 ")
42
+ # st.subheader('Your personalized teaching assistant by AI Anamolies')
43
+
44
+ default_title = "This is where title of your for the uploaded lecture gets published"
45
+ default_lessonplan = "This is where the default lesson plan gets uploaded"
46
+ default_notes = "This is where the notes get published"
47
+
48
+ ss = st.session_state
49
+
50
+
51
+ with st.sidebar:
52
+ with st.form("config"):
53
+ st.header("Upload here")
54
+ yturl = st.text_input('Enter YouTube URL ')
55
+ st.subheader("or")
56
+ audiofile = st.file_uploader("Please choose a file")
57
+ st.subheader("or")
58
+ driveurl = st.text_input('Enter location of the file')
59
+ if st.form_submit_button("submit"):
60
+
61
+ if 'youtube.com' in yturl:
62
+ # transcript = extract_youtube_transcript(url)
63
+ st.write('Text Summary:')
64
+ # st.write(transcript)
65
+ elif audiofile:
66
+ # transcript = extract_pdf_text(url)
67
+ st.write('Text Summary:')
68
+ # st.write(transcript)
69
+ elif driveurl:
70
+ # transcript = extract_pdf_text(url)
71
+ st.write('Text Summary:')
72
+ # st.write(transcript)
73
+ else:
74
+ st.write('Please enter a valid YouTube URL or file URL.')
75
+
76
+ st.info("""
77
+ [Dhrona.ai](https://github.com/xleven/ai-hackathon-judge) is a personalized teaching assistant
78
+ built by AI anomalies : [Siddartha](https://github.com/xleven) & [Shiva](https://github.com/langchain-ai/langchain) with [Streamlit](https://streamlit.io).
79
+ """, icon="ℹ️")
80
+
81
+ st.info("""
82
+ All you need to do is upload an Youtube url or audio file of your lecture. "Dhron" will give you a detailed, yet crisp notes along with a lesson plan. Once you are done going through the notes, you can test your skills by answering 10 MCQ's
83
+ """, icon="ℹ️")
84
+
85
+ st.header("Lesson Info")
86
+ title = st.write(default_title)
87
+
88
+ with st.expander("Lesson Plan"):
89
+ st.write(f"{default_lessonplan}")
90
+
91
+ with st.expander("Notes"):
92
+ st.write(f"{default_notes}")
93
+
94
+ # lessonplan = st.text_area("Lesson Plan", default_lessonplan, height=200)
95
+ # notes = st.text_area("Notes", default_notes, height=600)
96
+
97
+ st.divider()
98
+
99
+ #update your file here
100
+ file1 = "Notes.docx"
101
+
102
+ # Function to create a Word document from a string
103
+ def create_word_document(text):
104
+ doc = docx.Document()
105
+ doc.add_paragraph(text)
106
+ # Add more formatting as needed
107
+ return doc
108
+
109
+ # Function to save the document to a BytesIO object
110
+ def save_document_to_bytesio(doc):
111
+ bio = io.BytesIO()
112
+ doc.save(bio)
113
+ return bio
114
+
115
+ # Create a Word document from a string
116
+ # text = "This is a sample text for the Word document."
117
+ doc = create_word_document(text)
118
+
119
+ # Save the document to a BytesIO object
120
+ bio = save_document_to_bytesio(doc)
121
+
122
+
123
+ st.subheader("Download your notes here")
124
+ st.download_button(
125
+ label="Download Notes",
126
+ # data=text.encode('utf-8'),
127
+ # file_name=file1,
128
+ data= bio.getvalue(),
129
+ file_name=file1,
130
+ mime="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
131
+ # mime="text/plain",
132
+ # file_name="example.md",
133
+ # mime="text/markdown",
134
+
135
+ )
136
+
137
+ st.divider()
138
+
139
+ st.header("Assessment")
140
+ with st.expander("Lets take the test when ready!!"):
141
+ # st.write(f"{default_lessonplan}")
142
+
143
+
144
+ # Create a form for the quiz
145
+ with st.form(key='quiz_form'):
146
+ for question in questions:
147
+ st.subheader(f"Question {question['no']}: {question['question']}")
148
+ options = [question['a'], question['b'], question['c'], question['d']]
149
+ user_answer = st.radio("Select an answer", options, key=f"question_{question['no']}")
150
+ # st.write(user_answer)
151
+ answer[i] = user_answer
152
+ i +=1
153
+ print(answer)
154
+ # Submit button to calculate the score
155
+
156
+ if st.form_submit_button("Submit"):
157
+ i = 0
158
+ # "entering submit function"
159
+ # st.write(answer)
160
+ # st.write(questions)
161
+ for question in questions:
162
+ # st.write("Entering for loop")
163
+ # user_answer = st.radio(key=f"question_{question['no']}")
164
+ if question['answer'] == answer[i]:
165
+ # st.write("correct")
166
+ score += 1
167
+ else:
168
+ pass
169
+ # return score
170
+ i = i+1
171
+ # Display the final score outside the form
172
+ st.header(f"Your score: {score}/{len(questions)}")