Merge pull request #285 from karnoark/local-v3-02

Fix Section Name Parsing Issue in answer_question_textual_wide_range Method
This commit is contained in:
Federico 2024-09-05 19:15:36 +02:00 committed by GitHub
commit 3ab71e82ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -326,7 +326,11 @@ class GPTAnswerer:
prompt = ChatPromptTemplate.from_template(section_prompt) prompt = ChatPromptTemplate.from_template(section_prompt)
chain = prompt | self.llm_cheap | StrOutputParser() chain = prompt | self.llm_cheap | StrOutputParser()
output = chain.invoke({"question": question}) 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": if section_name == "cover_letter":
chain = chains.get(section_name) chain = chains.get(section_name)
output = chain.invoke({"resume": self.resume, "job_description": self.job_description}) output = chain.invoke({"resume": self.resume, "job_description": self.job_description})