Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,6 @@ from langchain_core.output_parsers import StrOutputParser
|
|
| 6 |
from langchain.chat_models import ChatOpenAI
|
| 7 |
from fpdf import FPDF
|
| 8 |
import os
|
| 9 |
-
import pandas as pd
|
| 10 |
|
| 11 |
# Set up Streamlit UI
|
| 12 |
st.title('Educational Assistant')
|
|
@@ -148,21 +147,9 @@ if openai_api_key:
|
|
| 148 |
study_plan_response = chain_4.invoke({'data': data})
|
| 149 |
st.write(study_plan_response)
|
| 150 |
|
| 151 |
-
# Extract the study plan and convert it into a structured format
|
| 152 |
-
study_plan = study_plan_response.strip().split("\n")
|
| 153 |
-
|
| 154 |
-
# Assuming the study plan is a list of 7 days with topics
|
| 155 |
-
days = ["Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7"]
|
| 156 |
-
topics = [plan.split(":")[1].strip() if ":" in plan else "" for plan in study_plan]
|
| 157 |
-
|
| 158 |
-
# Create a DataFrame to display the study plan in tabular form
|
| 159 |
-
study_plan_df = pd.DataFrame(list(zip(days, topics)), columns=["Day", "Topics to Study"])
|
| 160 |
-
|
| 161 |
-
st.table(study_plan_df)
|
| 162 |
-
|
| 163 |
# Generate PDF for the study plan and offer it as a download
|
| 164 |
pdf_filename = generate_pdf(study_plan_response, filename="study_plan_response.pdf")
|
| 165 |
st.download_button("Download Study Plan as PDF", data=open(pdf_filename, "rb").read(), file_name=pdf_filename, mime="application/pdf")
|
| 166 |
|
| 167 |
else:
|
| 168 |
-
st.sidebar.warning("Please enter your OpenAI API Key to proceed.")
|
|
|
|
| 6 |
from langchain.chat_models import ChatOpenAI
|
| 7 |
from fpdf import FPDF
|
| 8 |
import os
|
|
|
|
| 9 |
|
| 10 |
# Set up Streamlit UI
|
| 11 |
st.title('Educational Assistant')
|
|
|
|
| 147 |
study_plan_response = chain_4.invoke({'data': data})
|
| 148 |
st.write(study_plan_response)
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
# Generate PDF for the study plan and offer it as a download
|
| 151 |
pdf_filename = generate_pdf(study_plan_response, filename="study_plan_response.pdf")
|
| 152 |
st.download_button("Download Study Plan as PDF", data=open(pdf_filename, "rb").read(), file_name=pdf_filename, mime="application/pdf")
|
| 153 |
|
| 154 |
else:
|
| 155 |
+
st.sidebar.warning("Please enter your OpenAI API Key to proceed.")
|