Spaces:
Running
Running
File size: 9,869 Bytes
a96145c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 | import random
import time
from .models import Analysis, Article, NewsItem, RedditPost
_MOCK_ARTICLES = [
{
"title": "New AI model achieves breakthrough in protein folding prediction",
"text": (
"Researchers at DeepMind and several universities have announced a major breakthrough "
"in protein folding prediction using a new deep learning architecture. The model, called "
"AlphaFold-Next, is able to predict protein structures with accuracy approaching "
"experimental methods. This advancement could accelerate drug discovery and our "
"understanding of diseases. The team trained the model on a dataset of over 100,000 "
"known protein structures and used a novel attention mechanism to capture long-range "
"interactions between amino acids. Early tests show the model generalises well to "
"previously unseen protein families."
),
"domain": "nature.com",
"subreddit": "science",
"score": 5420,
"comments": 342,
},
{
"title": "WHO declares new global health emergency as novel virus spreads across continents",
"text": (
"The World Health Organization has declared a Public Health Emergency of International "
"Concern as a novel respiratory virus continues to spread rapidly across multiple "
"continents. The virus, which emerged in Southeast Asia, has been detected in 15 "
"countries so far. Health officials are implementing containment measures including "
"travel restrictions and increased surveillance. The WHO is coordinating with national "
"health agencies to ensure a rapid response. Vaccines are expected to begin clinical "
"trials within six months, according to the Director-General."
),
"domain": "reuters.com",
"subreddit": "worldnews",
"score": 8210,
"comments": 2801,
},
{
"title": "New study links ultra-processed foods to increased cancer risk",
"text": (
"A comprehensive study published in The Lancet has found a significant correlation "
"between consumption of ultra-processed foods and increased risk of developing certain "
"types of cancer. The study followed over 200,000 participants for 15 years and "
"controlled for lifestyle factors such as smoking and exercise. Researchers found that "
"participants who consumed the highest levels of ultra-processed foods had a 23% higher "
"risk of developing colorectal cancer. The findings add to growing evidence that dietary "
"patterns play a crucial role in cancer prevention."
),
"domain": "bbc.com",
"subreddit": "health",
"score": 3890,
"comments": 567,
},
{
"title": "SpaceX successfully launches satellite constellation for global internet coverage",
"text": (
"SpaceX has successfully launched another batch of 60 Starlink satellites, bringing the "
"total constellation size to over 5,000. The Falcon 9 rocket lifted off from Cape "
"Canaveral and successfully deployed the satellites in low Earth orbit. This expansion "
"will bring high-speed internet access to previously unserved rural areas across the "
"globe. The company plans to increase the constellation to 12,000 satellites within "
"the next three years, with initial tests showing latency as low as 20 milliseconds."
),
"domain": "reuters.com",
"subreddit": "technology",
"score": 4560,
"comments": 890,
},
{
"title": "Federal Reserve signals interest rate cut as inflation continues to cool",
"text": (
"The Federal Reserve has signalled it may cut interest rates at its next meeting as "
"inflation continues to trend downward toward the 2% target. Recent economic data "
"shows consumer prices rose only 2.3% year-over-year, down from a peak of 9.1% two "
"years ago. Fed Chair Jerome Powell stated that while progress has been made, the "
"committee would remain data-dependent. Markets responded positively, with the S&P "
"500 rising 1.2% on the news. Economists expect a quarter-point cut in September."
),
"domain": "wsj.com",
"subreddit": "economy",
"score": 3200,
"comments": 1200,
},
{
"title": "Global climate summit reaches historic agreement on fossil fuel phase-out",
"text": (
"Nearly 200 nations have reached a landmark agreement to phase out fossil fuels at the "
"UN Climate Summit in Dubai. The agreement sets a timeline for reducing coal, oil, and "
"gas production, with developed nations committing to faster reductions. Developing "
"countries will receive financial support through a new climate fund worth $100 billion "
"annually. Environmental groups have cautiously welcomed the deal while noting that "
"the timeline may need to accelerate to meet Paris Agreement targets. The agreement "
"marks the first time all nations have explicitly committed to transitioning away from "
"fossil fuels."
),
"domain": "theguardian.com",
"subreddit": "worldnews",
"score": 9500,
"comments": 3400,
},
{
"title": "Cybersecurity researchers discover zero-day exploit affecting billions of devices",
"text": (
"Security researchers have discovered a critical vulnerability in a widely-used "
"networking library that affects an estimated 3 billion devices worldwide. The "
"zero-day exploit, dubbed 'PacketStorm', allows remote code execution without user "
"interaction. Major technology companies including Google, Apple, and Microsoft have "
"released emergency patches. Users are strongly advised to update their devices "
"immediately. The vulnerability has been present in the codebase for over a decade "
"and was discovered during a routine security audit."
),
"domain": "reuters.com",
"subreddit": "technology",
"score": 6700,
"comments": 1500,
},
{
"title": "Unprecedented heatwave breaks temperature records across Europe",
"text": (
"An unprecedented heatwave is sweeping across Europe, with temperatures exceeding "
"45°C in several countries. Multiple heat records have been broken, including the "
"all-time high for the United Kingdom at 42.3°C. Authorities have issued red alerts "
"and are urging residents to stay indoors. The extreme weather has been linked to "
"climate change by leading meteorological agencies. Hospitals are reporting increased "
"admissions for heat-related illnesses, and transport networks have been disrupted "
"due to heat-damaged infrastructure."
),
"domain": "bbc.com",
"subreddit": "worldnews",
"score": 7800,
"comments": 2100,
},
{
"title": "New CRISPR therapy shows promising results in clinical trial for sickle cell disease",
"text": (
"A groundbreaking CRISPR-based gene therapy has shown remarkable results in a Phase 3 "
"clinical trial for sickle cell disease. Out of 45 patients, 42 showed complete "
"remission of symptoms 12 months after treatment. The therapy, developed by Vertex "
"Pharmaceuticals, uses CRISPR-Cas9 to edit the patient's own stem cells, correcting "
"the genetic mutation responsible for the disease. The FDA has granted breakthrough "
"therapy designation, potentially accelerating approval. This marks one of the first "
"successful CRISPR-based treatments for a genetic blood disorder."
),
"domain": "nature.com",
"subreddit": "science",
"score": 5100,
"comments": 450,
},
{
"title": "AI regulation bill passes Senate with bipartisan support",
"text": (
"The US Senate has passed a landmark artificial intelligence regulation bill with "
"significant bipartisan support. The legislation requires AI companies to conduct "
"safety testing before releasing powerful models, establish transparency requirements, "
"and create a new federal agency to oversee AI development. The bill was co-sponsored "
"by senators from both parties and represents one of the most comprehensive AI "
"governance frameworks in the world. Tech companies have expressed mixed reactions, "
"with some supporting the clarity while others worry about innovation impact."
),
"domain": "nytimes.com",
"subreddit": "politics",
"score": 4300,
"comments": 1800,
},
]
def generate_demo_items() -> list[NewsItem]:
items = []
for art in _MOCK_ARTICLES:
post = RedditPost(
id=f"mock_{random.randint(100000, 999999)}",
title=art["title"],
url=f"https://{art['domain']}/article/{random.randint(1000, 9999)}",
subreddit=art["subreddit"],
score=art["score"],
num_comments=art["comments"],
source_domain=art["domain"],
)
article = Article(
url=post.url,
title=art["title"],
text=art["text"],
source_domain=art["domain"],
)
items.append(NewsItem(post=post, article=article))
return items
|