feder-cr/Jobs_Applier_AI_Agent_AIHawk · warning · ValueError
No numbers found in the string
Error message
No numbers found in the string
What it means
extract_number_from_string pulls all digit runs out of the LLM's answer with re.findall(r'\d+'). If the model answered a numeric question with no digits at all (e.g. 'N/A' or prose), the function raises ValueError because it cannot return a number.
Source
Thrown at src/libs/llm_manager.py:647
try:
output = self.extract_number_from_string(output_str)
logger.debug(f"Extracted number: {output}")
except ValueError:
logger.warning(
f"Failed to extract number, using default experience: {default_experience}"
)
output = default_experience
return output
def extract_number_from_string(self, output_str):
logger.debug(f"Extracting number from string: {output_str}")
numbers = re.findall(r"\d+", output_str)
if numbers:
logger.debug(f"Numbers found: {numbers}")
return str(numbers[0])
else:
logger.error("No numbers found in the string")
raise ValueError("No numbers found in the string")
def answer_question_from_options(self, question: str, options: list[str]) -> str:
logger.debug(f"Answering question from options: {question}")
func_template = self._preprocess_template_string(prompts.options_template)
prompt = ChatPromptTemplate.from_template(func_template)
chain = prompt | self.llm_cheap | StrOutputParser()
raw_output_str = chain.invoke(
{
RESUME: self.resume,
JOB_APPLICATION_PROFILE: self.job_application_profile,
QUESTION: question,
OPTIONS: options,
}
)
output_str = self._clean_llm_output(raw_output_str)
logger.debug(f"Raw output for options question: {output_str}")
best_option = self.find_best_match(output_str, options)
logger.debug(f"Best option determined: {best_option}")View on GitHub (pinned to 79155b52fa)
Solutions
- Retry the numeric question: instruct the model to answer with digits only; often the second attempt works.
- Use a stronger model or lower temperature for the numeric chain.
- Wrap the call and default to '0' or skip the question when the model gives no numeric answer.
Example fix
# before
val = llm_manager.extract_number_from_string(ans)
# after
try:
val = llm_manager.extract_number_from_string(ans)
except ValueError:
val = '0' # or re-invoke the numeric chain with a digits-only instruction Defensive patterns
Strategy: fallback
Validate before calling
import re
if not re.search(r'\d', llm_answer):
llm_answer = '0' # or re-prompt with 'answer with digits only' Type guard
def contains_digit(s: str) -> bool:
return bool(re.search(r'\d', s)) Try / catch
try:
val = llm_manager.extract_number_from_string(ans)
except ValueError:
val = '0' # or retry the numeric chain once Prevention
- Prompt numeric questions with 'respond with only a number'.
- Treat a no-digit answer as a skip/default rather than a crash in form-filling loops.
When it happens
Trigger: answer_question_numeric invokes the LLM for a numeric field (years of experience, salary) and the reply contains no digits, so numbers is empty and the error is raised.
Common situations: LLM refusing or hedging on numeric questions ('I prefer not to say'), non-English digit formats being unlikely but possible (e.g. spelled-out numbers), or a weak/cheap model ignoring the instruction to answer with a number.
Related errors
- Could not extract section name from the response.
- Unsupported model type: {llm_model_type}
- Section '{section_name}' not found in either resume or job_a
- Chain not defined for section '{section_name}'
- Failed to get a response from the model after multiple attem
AI-assisted analysis of feder-cr/Jobs_Applier_AI_Agent_AIHawk@79155b52fa (2026-08-28).
Data as JSON: /api/errors/37c1cc74a9e385ee.
Report an issue: GitHub.