habulaj commited on
Commit
0e95daf
·
verified ·
1 Parent(s): 989fadf

Update routers/analyze.py

Browse files
Files changed (1) hide show
  1. routers/analyze.py +4 -8
routers/analyze.py CHANGED
@@ -134,13 +134,11 @@ async def rewrite_article_direct(content: str) -> Optional[Dict[str, Any]]:
134
  rewritten_data = {
135
  "title": result.title,
136
  "subhead": result.subhead,
137
- "content": result.content,
138
- "title_instagram": getattr(result, "title_instagram", ""),
139
- "content_instagram": getattr(result, "content_instagram", "")
140
  }
141
 
142
  # Validação básica da resposta
143
- required_keys = ["title", "subhead", "content", "title_instagram", "content_instagram"]
144
  if all(key in rewritten_data and rewritten_data[key].strip() for key in required_keys):
145
  log.info("Artigo reescrito com sucesso (chamada direta)")
146
  return {
@@ -199,7 +197,7 @@ async def rewrite_article_http(content: str) -> Optional[Dict[str, Any]]:
199
  rewritten_data = json.loads(response_text)
200
 
201
  # Validação básica da resposta
202
- required_keys = ["title", "subhead", "content", "title_instagram", "content_instagram"]
203
  if all(key in rewritten_data for key in required_keys):
204
  log.info("Artigo reescrito com sucesso (HTTP)")
205
  return {
@@ -306,9 +304,7 @@ async def update_news_rewrite(news_id: int, rewritten_data: Dict[str, str]):
306
  payload = {
307
  "title_pt": rewritten_data.get("title", ""),
308
  "text_pt": rewritten_data.get("content", ""),
309
- "subhead_pt": rewritten_data.get("subhead", ""),
310
- "title_instagram": rewritten_data.get("title_instagram", ""),
311
- "content_instagram": rewritten_data.get("content_instagram", "")
312
  }
313
 
314
  async with session.patch(url, headers=SUPABASE_ROLE_HEADERS, json=payload, params=params) as response:
 
134
  rewritten_data = {
135
  "title": result.title,
136
  "subhead": result.subhead,
137
+ "content": result.content
 
 
138
  }
139
 
140
  # Validação básica da resposta
141
+ required_keys = ["title", "subhead", "content"]
142
  if all(key in rewritten_data and rewritten_data[key].strip() for key in required_keys):
143
  log.info("Artigo reescrito com sucesso (chamada direta)")
144
  return {
 
197
  rewritten_data = json.loads(response_text)
198
 
199
  # Validação básica da resposta
200
+ required_keys = ["title", "subhead", "content"]
201
  if all(key in rewritten_data for key in required_keys):
202
  log.info("Artigo reescrito com sucesso (HTTP)")
203
  return {
 
304
  payload = {
305
  "title_pt": rewritten_data.get("title", ""),
306
  "text_pt": rewritten_data.get("content", ""),
307
+ "subhead_pt": rewritten_data.get("subhead", "")
 
 
308
  }
309
 
310
  async with session.patch(url, headers=SUPABASE_ROLE_HEADERS, json=payload, params=params) as response: