LeoWalker commited on
Commit
a7ddb9f
1 Parent(s): 318df0b

updated how to write the fields out

Browse files
Files changed (2) hide show
  1. app.py +19 -2
  2. requirements.txt +2 -1
app.py CHANGED
@@ -10,6 +10,7 @@ from resume_template import Resume
10
  from json import JSONDecodeError
11
  import PyPDF2
12
  import json
 
13
 
14
  load_dotenv()
15
 
@@ -100,11 +101,27 @@ uploaded_file = st.file_uploader("Upload a PDF file", type="pdf")
100
  if uploaded_file is not None:
101
  # Add a button to trigger the conversion
102
  if st.button("Convert PDF to Text"):
 
 
103
  # Convert the uploaded file to a string
104
  text = pdf_to_string(uploaded_file)
105
 
106
  # Extract resume fields using the selected model
107
  extracted_fields = extract_resume_fields(text, selected_model)
108
 
109
- # Display the extracted fields on the Streamlit app
110
- st.json(extracted_fields)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  from json import JSONDecodeError
11
  import PyPDF2
12
  import json
13
+ import time
14
 
15
  load_dotenv()
16
 
 
101
  if uploaded_file is not None:
102
  # Add a button to trigger the conversion
103
  if st.button("Convert PDF to Text"):
104
+ start_time = time.time() # Start the timer
105
+
106
  # Convert the uploaded file to a string
107
  text = pdf_to_string(uploaded_file)
108
 
109
  # Extract resume fields using the selected model
110
  extracted_fields = extract_resume_fields(text, selected_model)
111
 
112
+ end_time = time.time() # Stop the timer
113
+ elapsed_time = end_time - start_time # Calculate the elapsed time
114
+
115
+ # Display the elapsed time
116
+ st.write(f"Extraction completed in {elapsed_time:.2f} seconds")
117
+
118
+ # # Display the extracted fields on the Streamlit app
119
+ # st.json(extracted_fields)
120
+
121
+ # If extracted_fields is a JSON string, convert it to a dictionary
122
+ if isinstance(extracted_fields, str):
123
+ extracted_fields = json.loads(extracted_fields)
124
+
125
+ for key, value in extracted_fields.items():
126
+ st.write(f"{key}: {value}")
127
+
requirements.txt CHANGED
@@ -6,4 +6,5 @@ PyPDF2
6
  openai
7
  anthropic
8
  langchain
9
- langchain-community
 
 
6
  openai
7
  anthropic
8
  langchain
9
+ langchain-community
10
+ langchain_openai