Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions controllers/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,18 @@ async def search_jobs(
response = await model.generate_content_async(prompt)
chat_response = response.text

# Extract the JSON part from the response
try:
# Find the JSON object in the response
json_start = chat_response.find('{')
json_end = chat_response.rfind('}') + 1
if json_start == -1 or json_end == 0:
raise HTTPException(status_code=500, detail="Invalid response format from chat API")
json_str = chat_response[json_start:json_end]
search_params = json.loads(json_str)
except Exception as e:
print(f"Error parsing JSON from chat API: {e}")
# Extract the JSON part from the response
try:
# Find the JSON object in the response
json_start = chat_response.find('{')
json_end = chat_response.rfind('}') + 1
if json_start == -1 or json_end == 0:
raise ValueError("Invalid response format from chat API")
json_str = chat_response[json_start:json_end]
search_params = json.loads(json_str)
except (ValueError, json.JSONDecodeError) as e:
print(f"Error parsing JSON from chat API: {e}")
raise HTTPException(status_code=500, detail="Failed to parse search parameters")
raise HTTPException(status_code=500, detail="Failed to parse search parameters")

if page < 1:
Expand Down