Spaces:
Running
Running
app.py: added exception handling
Browse files
app.py
CHANGED
@@ -48,6 +48,8 @@ def pdf_to_string(file):
|
|
48 |
file.close()
|
49 |
return text
|
50 |
|
|
|
|
|
51 |
|
52 |
def extract_resume_fields(full_text, model):
|
53 |
"""
|
@@ -81,7 +83,7 @@ def extract_resume_fields(full_text, model):
|
|
81 |
output = chain.invoke(full_text)
|
82 |
print(output)
|
83 |
return output
|
84 |
-
except (
|
85 |
if attempt == max_attempts:
|
86 |
raise e
|
87 |
else:
|
@@ -127,8 +129,9 @@ st.title("Resume Parser")
|
|
127 |
llm_dict = {
|
128 |
"GPT 3.5 turbo": ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo"),
|
129 |
"Anthropic Sonnet": ChatAnthropic(model_name="claude-3-sonnet-20240229"),
|
130 |
-
"Llama 3": ChatGroq(model_name="llama3-
|
131 |
-
"
|
|
|
132 |
"Mistral": ChatGroq(model_name="mixtral-8x7b-32768"),
|
133 |
# "Gemini 1.5 Pro": ChatGoogleGenerativeAI(model_name="gemini-1.5-pro-latest"),
|
134 |
}
|
@@ -139,7 +142,7 @@ uploaded_file = st.file_uploader("Upload a PDF file", type="pdf")
|
|
139 |
col1, col2 = st.columns(2)
|
140 |
|
141 |
with col1:
|
142 |
-
selected_model1 = st.selectbox("Select Model 1", list(llm_dict.keys()), index=list(llm_dict.keys()).index("Llama 3"))
|
143 |
|
144 |
with col2:
|
145 |
selected_model2 = st.selectbox("Select Model 2", list(llm_dict.keys()), index=list(llm_dict.keys()).index("Mistral"))
|
|
|
48 |
file.close()
|
49 |
return text
|
50 |
|
51 |
+
class CustomOutputParserException(Exception):
|
52 |
+
pass
|
53 |
|
54 |
def extract_resume_fields(full_text, model):
|
55 |
"""
|
|
|
83 |
output = chain.invoke(full_text)
|
84 |
print(output)
|
85 |
return output
|
86 |
+
except (CustomOutputParserException, ValidationError) as e:
|
87 |
if attempt == max_attempts:
|
88 |
raise e
|
89 |
else:
|
|
|
129 |
llm_dict = {
|
130 |
"GPT 3.5 turbo": ChatOpenAI(temperature=0, model_name="gpt-3.5-turbo"),
|
131 |
"Anthropic Sonnet": ChatAnthropic(model_name="claude-3-sonnet-20240229"),
|
132 |
+
"Llama 3 8b": ChatGroq(model_name="llama3-8b-8192"),
|
133 |
+
"Llama 3 70b": ChatGroq(model_name="llama3-70b-8192"),
|
134 |
+
"Gemma 7b": ChatGroq(model_name="gemma-7b-it"),
|
135 |
"Mistral": ChatGroq(model_name="mixtral-8x7b-32768"),
|
136 |
# "Gemini 1.5 Pro": ChatGoogleGenerativeAI(model_name="gemini-1.5-pro-latest"),
|
137 |
}
|
|
|
142 |
col1, col2 = st.columns(2)
|
143 |
|
144 |
with col1:
|
145 |
+
selected_model1 = st.selectbox("Select Model 1", list(llm_dict.keys()), index=list(llm_dict.keys()).index("Llama 3 70b"))
|
146 |
|
147 |
with col2:
|
148 |
selected_model2 = st.selectbox("Select Model 2", list(llm_dict.keys()), index=list(llm_dict.keys()).index("Mistral"))
|