Issue #518 - Subscription not updating after checkout: - Fix stale closure in SubscriptionContext checkout polling (use subscriptionRef) - Move checkout success polling from InitialRouteHandler into SubscriptionContext - Remove redundant polling code from InitialRouteHandler - Fix plan label: 'Free' instead of 'No Plan', proper capitalization - Add plan refresh button in UserBadge - Add 'View Costing Details' to UserBadge dropdown - Rename 'ALwrity Podcast Maker' to 'Podcast Creator' across UI - Clean subscription=success URL param after verification Blog Writer WYSIWYG Editor enhancements: - Per-section preview toggle (view/edit icons) - Enhanced hover-based toolbar - Circular SVG progress stats bar with detailed tooltip - Research tool chips in stats bar footer - Per-section TTS with useTextToSpeech hook (browser native) - Full blog preview modal with print/PDF support - PlayAllTTSButton: sequential playback with progress bar - OnThisPageNav: floating sidebar with scroll tracking - Section data attributes for scroll anchoring GSC Brainstorm Topics feature: - Backend: gsc_brainstorm_service.py (rule-based + LLM recommendations) - Backend: POST /gsc/brainstorm endpoint with 3-word minimum validation - Frontend: gscBrainstorm.ts API client - Frontend: useGSCBrainstormConnection hook (popup OAuth, no /onboarding redirect) - Frontend: useGSCBrainstorm hook (connect check + brainstorm call) - Frontend: GSCBrainstormModal (3-tab results: Opportunities, Gaps, AI Recs) - Frontend: BrainstormButton (visible at 3+ words, GSC connect overlay) - Wire BrainstormButton into ManualResearchForm and ResearchAction - Add blog_writer to gsc_auth router features for ALWRITY_ENABLED_FEATURES
65 lines
1.7 KiB
Python
65 lines
1.7 KiB
Python
from fastapi import APIRouter, Depends, HTTPException
|
|
from pydantic import BaseModel
|
|
from typing import List, Any, Dict
|
|
from loguru import logger
|
|
|
|
from services.writing_assistant import WritingAssistantService
|
|
from middleware.auth_middleware import get_current_user
|
|
|
|
|
|
router = APIRouter(prefix="/api/writing-assistant", tags=["writing-assistant"])
|
|
|
|
|
|
class SuggestRequest(BaseModel):
|
|
text: str
|
|
|
|
|
|
class SourceModel(BaseModel):
|
|
title: str
|
|
url: str
|
|
text: str | None = ""
|
|
author: str | None = ""
|
|
published_date: str | None = ""
|
|
score: float
|
|
|
|
|
|
class SuggestionModel(BaseModel):
|
|
text: str
|
|
confidence: float
|
|
sources: List[SourceModel]
|
|
|
|
|
|
class SuggestResponse(BaseModel):
|
|
success: bool
|
|
suggestions: List[SuggestionModel]
|
|
|
|
|
|
assistant_service = WritingAssistantService()
|
|
|
|
|
|
@router.post("/suggest", response_model=SuggestResponse)
|
|
async def suggest_endpoint(req: SuggestRequest, current_user: Dict[str, Any] = Depends(get_current_user)) -> SuggestResponse:
|
|
try:
|
|
user_id = current_user.get("id")
|
|
suggestions = await assistant_service.suggest(req.text, user_id=user_id)
|
|
return SuggestResponse(
|
|
success=True,
|
|
suggestions=[
|
|
SuggestionModel(
|
|
text=s.text,
|
|
confidence=s.confidence,
|
|
sources=[
|
|
SourceModel(**src) for src in s.sources
|
|
],
|
|
)
|
|
for s in suggestions
|
|
],
|
|
)
|
|
except HTTPException:
|
|
raise
|
|
except Exception as e:
|
|
logger.error(f"Writing assistant error: {e}")
|
|
raise HTTPException(status_code=500, detail=str(e))
|
|
|
|
|