JishnuSetia commited on
Commit
935cc7d
·
verified ·
1 Parent(s): 87678d8

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +61 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import google.generativeai as genai
3
+ import os
4
+ import PyPDF2 as pdf
5
+ from dotenv import load_dotenv
6
+ import json
7
+
8
+ load_dotenv() ## load all our environment variables
9
+
10
+ os.getenv("GOOGLE_API_KEY")
11
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
12
+
13
+
14
+
15
+ def get_gemini_response(input):
16
+ model=genai.GenerativeModel('gemini-pro')
17
+ response=model.generate_content(input)
18
+ return response.text
19
+
20
+ def input_pdf_text(uploaded_file):
21
+ reader=pdf.PdfReader(uploaded_file)
22
+ text=""
23
+ for page in range(len(reader.pages)):
24
+ page=reader.pages[page]
25
+ text+=str(page.extract_text())
26
+ return text
27
+
28
+ #Prompt Template
29
+
30
+ input_prompt="""
31
+ 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'
32
+ my name is: {myname}
33
+ my designation is: {designation}
34
+ my relationship with the student is: {relationship}
35
+ my contact: {contact}
36
+ school name: {school}
37
+ student name: {name}
38
+ student brag sheet:{sbs}
39
+ Write a recommendation letter.
40
+ ""}}
41
+ """
42
+
43
+ ## streamlit app
44
+ st.title("AI Recommendation Writer")
45
+ st.text("Write Reco Letters for students quickly!")
46
+ myname = st.text_input("Enter Your Name:")
47
+ designation = st.text_input("Enter Your Designation:")
48
+ contact = st.text_input("Enter Your Contact:")
49
+ relation = st.text_input("Enter Your Relation with Student:")
50
+ school = st.text_input("Enter School Name:")
51
+ text = st.text_input("Enter Student Name:")
52
+ uploaded_file=st.file_uploader("Upload Student Questionaire",type="pdf",help="Please upload the pdf")
53
+
54
+ submit = st.button("Submit")
55
+
56
+ if submit:
57
+ if uploaded_file is not None:
58
+ uploaded=input_pdf_text(uploaded_file)
59
+ response=get_gemini_response(input_prompt.format(name = text, sbs = uploaded, myname = myname, designation = designation, relationship=relation, contact=contact, school = school ))
60
+ st.subheader(response)
61
+
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ PyPDF2
3
+ google.generativeai
4
+ python-dotenv