Spaces:
Sleeping
Sleeping
import streamlit as st | |
import google.generativeai as genai | |
import os | |
import PyPDF2 as pdf | |
from dotenv import load_dotenv | |
import json | |
load_dotenv() ## load all our environment variables | |
os.getenv("GOOGLE_API_KEY") | |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) | |
def get_gemini_response(input): | |
model=genai.GenerativeModel('gemini-pro') | |
response=model.generate_content(input) | |
return response.text | |
def input_pdf_text(uploaded_file): | |
reader=pdf.PdfReader(uploaded_file) | |
text="" | |
for page in range(len(reader.pages)): | |
page=reader.pages[page] | |
text+=str(page.extract_text()) | |
return text | |
#Prompt Template | |
input_prompt=""" | |
Act Like a skilled or very experience Student Recommendation letter writer. your job is to write top notch reco letters for students so that they can apply to college. You are provided with the student's brag sheet and student name. It must be grammatically correct. this will be put into a pdf doc and sent to colleges. start with 'to whom it may concern' | |
my name is: {myname} | |
my designation is: {designation} | |
my relationship with the student is: {relationship} | |
Student's Aspiration: {aspirations} | |
school name: {school} | |
student name: {name} | |
student brag sheet:{sbs} | |
Write a recommendation letter. | |
""}} | |
""" | |
## streamlit app | |
st.title("AI Recommendation Writer") | |
st.text("Write Reco Letters for students quickly!") | |
myname = st.text_input("Enter Your Name:") | |
designation = st.text_input("Enter Your Designation:") | |
relation = st.text_input("Enter Your Relation with Student:") | |
school = st.text_input("Enter School Name:") | |
text = st.text_input("Enter Student Name:") | |
aspirations = st.text_input("Enter Student's Aspiration:") | |
uploaded_file=st.file_uploader("Upload Student Questionaire",type="pdf",help="Please upload the pdf") | |
submit = st.button("Submit") | |
if submit: | |
if uploaded_file is not None: | |
uploaded=input_pdf_text(uploaded_file) | |
response=get_gemini_response(input_prompt.format(name = text, sbs = uploaded, myname = myname, designation = designation, relationship=relation, aspirations=aspirations, school = school )) | |
st.subheader(response) | |