habulaj commited on
Commit
ada9d6c
·
verified ·
1 Parent(s): 38d0cef

Update routers/inference.py

Browse files
Files changed (1) hide show
  1. routers/inference.py +20 -6
routers/inference.py CHANGED
@@ -499,13 +499,13 @@ News base: Noah Centineo Attached to Play Rambo in Prequel Movie 'John Rambo'
499
  detail="Modelo não retornou conteúdo válido"
500
  )
501
 
502
- # Extração do título, subtítulo e conteúdo
503
  title_match = re.search(r"<headline>(.*?)</headline>", response_text, re.DOTALL)
504
  title = title_match.group(1).strip() if title_match else "Título não encontrado"
505
-
506
  subhead_match = re.search(r"<subhead>(.*?)</subhead>", response_text, re.DOTALL)
507
  subhead = subhead_match.group(1).strip() if subhead_match else "Subtítulo não encontrado"
508
-
509
  body_match = re.search(r"<body>(.*?)</body>", response_text, re.DOTALL)
510
  if body_match:
511
  content = body_match.group(1).strip()
@@ -515,10 +515,24 @@ News base: Noah Centineo Attached to Play Rambo in Prequel Movie 'John Rambo'
515
  content = body_start_match.group(1).strip()
516
  else:
517
  content = "Conteúdo não encontrado"
518
-
 
 
 
 
 
 
 
519
  logger.info(f"Processamento concluído com sucesso - Título: {title[:50]}...")
520
-
521
- return NewsResponse(title=title, subhead=subhead, content=content, sources=sources)
 
 
 
 
 
 
 
522
 
523
  except HTTPException:
524
  raise
 
499
  detail="Modelo não retornou conteúdo válido"
500
  )
501
 
502
+ # Extração do título, subtítulo, conteúdo e campos do Instagram
503
  title_match = re.search(r"<headline>(.*?)</headline>", response_text, re.DOTALL)
504
  title = title_match.group(1).strip() if title_match else "Título não encontrado"
505
+
506
  subhead_match = re.search(r"<subhead>(.*?)</subhead>", response_text, re.DOTALL)
507
  subhead = subhead_match.group(1).strip() if subhead_match else "Subtítulo não encontrado"
508
+
509
  body_match = re.search(r"<body>(.*?)</body>", response_text, re.DOTALL)
510
  if body_match:
511
  content = body_match.group(1).strip()
 
515
  content = body_start_match.group(1).strip()
516
  else:
517
  content = "Conteúdo não encontrado"
518
+
519
+ # Novos campos do Instagram
520
+ insta_title_match = re.search(r"<instagram_title>(.*?)</instagram_title>", response_text, re.DOTALL)
521
+ instagram_title = insta_title_match.group(1).strip() if insta_title_match else "Título Instagram não encontrado"
522
+
523
+ insta_desc_match = re.search(r"<instagram_description>(.*?)</instagram_description>", response_text, re.DOTALL)
524
+ instagram_description = insta_desc_match.group(1).strip() if insta_desc_match else "Descrição Instagram não encontrada"
525
+
526
  logger.info(f"Processamento concluído com sucesso - Título: {title[:50]}...")
527
+
528
+ return NewsResponse(
529
+ title=title,
530
+ subhead=subhead,
531
+ content=content,
532
+ sources=sources,
533
+ instagram_title=instagram_title,
534
+ instagram_description=instagram_description
535
+ )
536
 
537
  except HTTPException:
538
  raise