Issue Description
I’m building a Python application that processes resume documents and performs web automation for job applications. The script uses OpenAI’s chat models and a browser automation library, but I keep getting a comparison error.
Error Message
TypeError: '>=' not supported between instances of 'int' and 'str'
Sample Code
from langchain_openai import ChatOpenAI
from browser_use import Agent
import asyncio
from dotenv import load_dotenv
import json
import PyPDF2
load_dotenv()
def extract_resume_text(pdf_file):
try:
with open(pdf_file, "rb") as document:
pdf_reader = PyPDF2.PdfReader(document)
content = ""
for page_num in pdf_reader.pages:
extracted_text = page_num.extract_text()
if extracted_text:
content += extracted_text
return content
except Exception as error:
print(f"PDF reading failed: {error}")
return ""
async def process_application():
resume_file = "resume.pdf"
resume_text = extract_resume_text(resume_file)
if not resume_text:
print("Failed to extract resume content")
return
print("Resume processed:", resume_text)
automation_agent = Agent(
task=f"Analyze resume and find relevant job opportunities. Resume data: {resume_text}",
llm=ChatOpenAI(model="gpt-4"),
)
try:
job_listings = await automation_agent.run("Find data science positions matching the resume profile.")
print("Job search results:", job_listings)
if isinstance(job_listings, list):
for position in job_listings:
if isinstance(position, dict):
if 'compensation' in position:
try:
position['compensation'] = int(position['compensation'])
except (ValueError, TypeError):
print(f"Invalid compensation data: {position['compensation']}")
position['compensation'] = 0
except Exception as error:
print(f"Job search error: {error}")
return
try:
with open("positions.json", "w") as output_file:
json.dump(job_listings, output_file, indent=2)
print("Results saved successfully")
except Exception as error:
print(f"File save error: {error}")
for position in job_listings:
try:
application_status = await automation_agent.run(f"Submit application for: {position}")
print(f"Application status for {position}:", application_status)
except Exception as error:
print(f"Application error for {position}: {error}")
if __name__ == "__main__":
asyncio.run(process_application())
Full Stack Trace
Traceback (most recent call last):
File "service.py", line 468, in run
for step in range(max_steps):
^^^^^^^^^^^^^^^^
TypeError: 'str' object cannot be interpreted as an integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 78, in <module>
asyncio.run(process_application())
File "asyncio/runners.py", line 194, in run
return runner.run(main)
File "service.py", line 497, in run
max_steps_reached=self.n_steps >= max_steps,
^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>=' not supported between instances of 'int' and 'str'
Environment Details
- Python 3.x
- Libraries: langchain-openai, browser-use, python-dotenv, PyPDF2
- Model: gpt-4
The error seems to happen inside the browser automation library when it tries to compare step counts. I tried adding type checking for my data but the issue persists. Has anyone encountered this before?