refactor: Remove 3 non-working API endpoints for demo readiness
🔧 REMOVED NON-WORKING ENDPOINTS: - Removed GET /recommend-news (article ID recommendations) - Removed POST /analyze-article (AI article analysis) - Removed POST /generate-insights (AI insights generation) - Removed associated request models (AnalyzeRequest, InsightsRequest) 📝 UPDATED DOCUMENTATION: - Updated README.md from 13 to 10 API endpoints - Updated all endpoint counts throughout documentation - Reorganized API sections to reflect current functionality - Maintained accurate system metrics (337 articles) ✅ CURRENT WORKING ENDPOINTS (10): - Core System (3): /, /health, /stats - News Management (2): /fetch-news, /articles - Recommendations (3): /recommend-by-query, /recommend-by-interests, /trending - Search & Discovery (1): /search - AI Analysis (1): /ai-status 🚀 System now ready for live demo with 100% working endpoints!
This commit is contained in:
@@ -88,11 +88,7 @@ class SearchQuery(BaseModel):
|
||||
top_k: int = 10
|
||||
include_content: bool = False
|
||||
|
||||
class AnalyzeRequest(BaseModel):
|
||||
article_id: str
|
||||
|
||||
class InsightsRequest(BaseModel):
|
||||
article_count: int = 5
|
||||
|
||||
# API Endpoints
|
||||
|
||||
@@ -147,24 +143,6 @@ async def fetch_news():
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Error fetching news: {str(e)}")
|
||||
|
||||
@app.get("/recommend-news")
|
||||
async def recommend_news(
|
||||
article_id: str = Query(..., description="ID of the article to find similar articles for"),
|
||||
top_k: int = Query(5, description="Number of recommendations to return")
|
||||
):
|
||||
"""Get news recommendations based on article ID"""
|
||||
try:
|
||||
recommendations = recommender.recommend_by_article_id(article_id, top_k)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"article_id": article_id,
|
||||
"recommendations": recommendations,
|
||||
"count": len(recommendations)
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Error getting recommendations: {str(e)}")
|
||||
|
||||
@app.post("/recommend-by-query")
|
||||
async def recommend_by_query(query_data: NewsQuery):
|
||||
@@ -408,54 +386,6 @@ async def get_stats():
|
||||
|
||||
# AI Analysis Endpoints
|
||||
|
||||
@app.post("/analyze-article")
|
||||
async def analyze_article(request: AnalyzeRequest):
|
||||
"""Analyze a specific article with AI"""
|
||||
try:
|
||||
# Get article from vector store
|
||||
articles = recommender.vector_store.get_all_articles()
|
||||
article = next((a for a in articles if a.get('id') == request.article_id), None)
|
||||
|
||||
if not article:
|
||||
raise HTTPException(status_code=404, detail="Article not found")
|
||||
|
||||
# Perform AI analysis
|
||||
summary = ai_analyzer.summarize_article(article)
|
||||
keywords = ai_analyzer.extract_keywords(article)
|
||||
sentiment = ai_analyzer.analyze_sentiment(article)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"article_id": request.article_id,
|
||||
"analysis": {
|
||||
"summary": summary,
|
||||
"keywords": keywords,
|
||||
"sentiment": sentiment
|
||||
}
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Error analyzing article: {str(e)}")
|
||||
|
||||
@app.post("/generate-insights")
|
||||
async def generate_insights(request: InsightsRequest):
|
||||
"""Generate AI insights from recent articles"""
|
||||
try:
|
||||
# Get recent articles
|
||||
recent_articles = recommender.get_trending_articles(request.article_count)
|
||||
|
||||
# Generate insights
|
||||
insights = ai_analyzer.generate_insights(recent_articles)
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
"insights": insights,
|
||||
"article_count": len(recent_articles)
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"Error generating insights: {str(e)}")
|
||||
|
||||
@app.get("/ai-status")
|
||||
async def get_ai_status():
|
||||
"""Get AI analyzer status and capabilities"""
|
||||
|
||||
Reference in New Issue
Block a user