From 5673308a3d8d917484ae4b03b8314b0875493d37 Mon Sep 17 00:00:00 2001 From: karnoark Date: Thu, 5 Sep 2024 16:38:23 +0530 Subject: [PATCH] stripped away additional text --- src/gpt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gpt.py b/src/gpt.py index 22c7d6c..77a9992 100644 --- a/src/gpt.py +++ b/src/gpt.py @@ -326,7 +326,11 @@ class GPTAnswerer: prompt = ChatPromptTemplate.from_template(section_prompt) chain = prompt | self.llm_cheap | StrOutputParser() output = chain.invoke({"question": question}) - section_name = output.lower().replace(" ", "_") + match = re.search(r"(Personal information|Self Identification|Legal Authorization|Work Preferences|Education Details|Experience Details|Projects|Availability|Salary Expectations|Certifications|Languages|Interests|Cover letter)", output, re.IGNORECASE) + if not match: + raise ValueError("Could not extract section name from the response.") + + section_name = match.group(1).lower().replace(" ", "_") if section_name == "cover_letter": chain = chains.get(section_name) output = chain.invoke({"resume": self.resume, "job_description": self.job_description})