Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import numpy as np
|
|
8 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
9 |
from sklearn.metrics.pairwise import cosine_similarity
|
10 |
from io import StringIO
|
|
|
11 |
|
12 |
# Function to extract text from a PDF file
|
13 |
def extract_text_from_pdf(pdf_file):
|
@@ -67,18 +68,98 @@ def generate_math_solution(query):
|
|
67 |
messages=[{"role": "user", "content": prompt}]
|
68 |
)
|
69 |
return response['choices'][0]['message']['content']
|
70 |
-
|
71 |
-
from PIL import Image # Required for local image files
|
72 |
|
73 |
# Streamlit app starts here
|
74 |
st.set_page_config(page_title="AI Assistance", page_icon=":robot:", layout="wide")
|
75 |
|
76 |
-
#
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
#
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
# Input OpenAI API key
|
84 |
openai_api_key = st.text_input("Enter your OpenAI API key:", type="password")
|
@@ -106,21 +187,10 @@ if openai_api_key:
|
|
106 |
"Text-To-Diagram-Generator"
|
107 |
))
|
108 |
|
109 |
-
#
|
110 |
-
st.sidebar.markdown("""
|
111 |
-
## Contact
|
112 |
-
|
113 |
-
For any questions or issues, please contact:
|
114 |
-
|
115 |
-
- **Email**: [[email protected]](mailto:[email protected])
|
116 |
-
- **GitHub**: [Click here to access the Github Profile](https://github.com/shukdevtroy)
|
117 |
-
- **WhatsApp**: [Click here to chat](https://wa.me/+8801719296601)
|
118 |
-
- **HuggingFace Profile**: [Click here to access the HuggingFace Profile](https://huggingface.co/shukdevdatta123)
|
119 |
-
""")
|
120 |
|
121 |
if mode == "Course Query Assistant":
|
122 |
st.header("Course Query Assistant")
|
123 |
-
|
124 |
# Display image/logo in the "Course Query Assistant" section (optional)
|
125 |
course_query_image = Image.open("Capture.PNG") # Ensure the file is in the correct directory
|
126 |
st.image(course_query_image, width=150) # Adjust the size as per preference
|
|
|
8 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
9 |
from sklearn.metrics.pairwise import cosine_similarity
|
10 |
from io import StringIO
|
11 |
+
from PIL import Image
|
12 |
|
13 |
# Function to extract text from a PDF file
|
14 |
def extract_text_from_pdf(pdf_file):
|
|
|
68 |
messages=[{"role": "user", "content": prompt}]
|
69 |
)
|
70 |
return response['choices'][0]['message']['content']
|
|
|
|
|
71 |
|
72 |
# Streamlit app starts here
|
73 |
st.set_page_config(page_title="AI Assistance", page_icon=":robot:", layout="wide")
|
74 |
|
75 |
+
# Custom CSS for the page styling
|
76 |
+
st.markdown("""
|
77 |
+
<style>
|
78 |
+
body {
|
79 |
+
background-color: #f0f4f7;
|
80 |
+
font-family: 'Arial', sans-serif;
|
81 |
+
color: #333;
|
82 |
+
}
|
83 |
+
.header {
|
84 |
+
text-align: center;
|
85 |
+
font-size: 2.5em;
|
86 |
+
font-weight: bold;
|
87 |
+
color: #4CAF50;
|
88 |
+
margin-top: 30px;
|
89 |
+
animation: fadeIn 2s ease-out;
|
90 |
+
}
|
91 |
+
.sidebar .sidebar-content {
|
92 |
+
background-color: #333;
|
93 |
+
color: white;
|
94 |
+
}
|
95 |
+
.sidebar .sidebar-content a {
|
96 |
+
color: white;
|
97 |
+
font-size: 1.2em;
|
98 |
+
}
|
99 |
+
.sidebar .sidebar-content a:hover {
|
100 |
+
color: #4CAF50;
|
101 |
+
}
|
102 |
+
.stButton>button {
|
103 |
+
background-color: #4CAF50;
|
104 |
+
color: white;
|
105 |
+
font-size: 1.2em;
|
106 |
+
padding: 10px 20px;
|
107 |
+
border-radius: 5px;
|
108 |
+
border: none;
|
109 |
+
transition: background-color 0.3s;
|
110 |
+
}
|
111 |
+
.stButton>button:hover {
|
112 |
+
background-color: #45a049;
|
113 |
+
}
|
114 |
+
.stTextInput input {
|
115 |
+
padding: 10px;
|
116 |
+
font-size: 1.1em;
|
117 |
+
border-radius: 5px;
|
118 |
+
border: 1px solid #ccc;
|
119 |
+
}
|
120 |
+
.stFileUploader {
|
121 |
+
border-radius: 5px;
|
122 |
+
border: 1px solid #ddd;
|
123 |
+
padding: 10px;
|
124 |
+
}
|
125 |
+
.stImage {
|
126 |
+
animation: fadeIn 2s ease-out;
|
127 |
+
}
|
128 |
+
@keyframes fadeIn {
|
129 |
+
0% { opacity: 0; }
|
130 |
+
100% { opacity: 1; }
|
131 |
+
}
|
132 |
+
.stTextArea textarea {
|
133 |
+
padding: 10px;
|
134 |
+
font-size: 1.1em;
|
135 |
+
border-radius: 5px;
|
136 |
+
border: 1px solid #ccc;
|
137 |
+
}
|
138 |
+
</style>
|
139 |
+
""", unsafe_allow_html=True)
|
140 |
+
|
141 |
+
# Custom JavaScript for animations
|
142 |
+
st.markdown("""
|
143 |
+
<script type="text/javascript">
|
144 |
+
window.onload = function() {
|
145 |
+
const elements = document.querySelectorAll('.stButton button, .stTextInput input, .stTextArea textarea');
|
146 |
+
elements.forEach(element => {
|
147 |
+
element.style.transition = 'all 0.3s ease';
|
148 |
+
element.addEventListener('mouseover', function() {
|
149 |
+
element.style.transform = 'scale(1.05)';
|
150 |
+
});
|
151 |
+
element.addEventListener('mouseout', function() {
|
152 |
+
element.style.transform = 'scale(1)';
|
153 |
+
});
|
154 |
+
});
|
155 |
+
};
|
156 |
+
</script>
|
157 |
+
""", unsafe_allow_html=True)
|
158 |
+
|
159 |
+
# Add your app logic here...
|
160 |
+
|
161 |
+
# Display the app header
|
162 |
+
st.markdown("<h1 class='header'>AI Assistance</h1>", unsafe_allow_html=True)
|
163 |
|
164 |
# Input OpenAI API key
|
165 |
openai_api_key = st.text_input("Enter your OpenAI API key:", type="password")
|
|
|
187 |
"Text-To-Diagram-Generator"
|
188 |
))
|
189 |
|
190 |
+
# Main app content here...
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
if mode == "Course Query Assistant":
|
193 |
st.header("Course Query Assistant")
|
|
|
194 |
# Display image/logo in the "Course Query Assistant" section (optional)
|
195 |
course_query_image = Image.open("Capture.PNG") # Ensure the file is in the correct directory
|
196 |
st.image(course_query_image, width=150) # Adjust the size as per preference
|