forked from retoor/devplacepy
feat: add news sanitize CLI command and upload static file serving with content-disposition
This commit is contained in:
@@ -7,7 +7,7 @@ import httpx
|
||||
|
||||
from devplacepy.database import get_table
|
||||
from devplacepy.services.base import BaseService
|
||||
from devplacepy.utils import generate_uid, make_combined_slug
|
||||
from devplacepy.utils import generate_uid, make_combined_slug, strip_html
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -147,10 +147,10 @@ class NewsService(BaseService):
|
||||
"status": is_published,
|
||||
"title": article.get("title", ""),
|
||||
"slug": existing_slug or make_combined_slug(article.get("title", "") or "news", existing["uid"]),
|
||||
"description": (article.get("description", "") or "")[:5000],
|
||||
"description": strip_html(article.get("description", "") or "")[:5000],
|
||||
"url": article.get("link", ""),
|
||||
"source_name": article.get("feed_name", ""),
|
||||
"content": (article.get("content", "") or "")[:10000],
|
||||
"content": strip_html(article.get("content", "") or "")[:10000],
|
||||
"author": article.get("author", ""),
|
||||
"article_published": article.get("published", ""),
|
||||
"synced_at": now,
|
||||
@@ -166,13 +166,13 @@ class NewsService(BaseService):
|
||||
"slug": article_slug,
|
||||
"external_id": external_id,
|
||||
"title": article.get("title", ""),
|
||||
"description": (article.get("description", "") or "")[:5000],
|
||||
"description": strip_html(article.get("description", "") or "")[:5000],
|
||||
"url": article.get("link", ""),
|
||||
"image_url": "",
|
||||
"source_name": article.get("feed_name", ""),
|
||||
"grade": grade_val,
|
||||
"status": is_published,
|
||||
"content": (article.get("content", "") or "")[:10000],
|
||||
"content": strip_html(article.get("content", "") or "")[:10000],
|
||||
"author": article.get("author", ""),
|
||||
"article_published": article.get("published", ""),
|
||||
"synced_at": now,
|
||||
@@ -212,8 +212,8 @@ class NewsService(BaseService):
|
||||
|
||||
async def _grade_article(self, article: dict, ai_url: str, ai_model: str) -> int | None:
|
||||
title = (article.get("title", "") or "")[:500]
|
||||
description = (article.get("description", "") or "")[:1000]
|
||||
content = (article.get("content", "") or "")[:1500]
|
||||
description = strip_html(article.get("description", "") or "")[:1000]
|
||||
content = strip_html(article.get("content", "") or "")[:1500]
|
||||
|
||||
prompt = (
|
||||
"Rate this article's relevance to software developers on a scale of 1-10. "
|
||||
|
||||
Reference in New Issue
Block a user