Add tiered summarization based on pricing plans
- Implement advanced AI summarization with action items for Pro plan - Create basic bullet-point summarization for Freemium plan - Add plan tier validation and feature differentiation - Support speaker identification in transcripts - Define plan limits (600 mins Pro/200 mins Freemium)
This commit is contained in:
@@ -55,6 +55,7 @@ async def get_api_key(api_key_header: str = Security(api_key_header)) -> str:
|
||||
class TranscribeRequest(BaseModel):
|
||||
media_url: Optional[str] = None
|
||||
media_type: Optional[str] # Corrected type hint for media_type
|
||||
plan_tier: Optional[str] = "freemium" # Default to freemium plan if not specified
|
||||
|
||||
class ChatResp(BaseModel): # Added BaseModel inheritance
|
||||
error: Optional[str] = None
|
||||
@@ -78,6 +79,16 @@ async def chat_endpoint(
|
||||
api_key: str = Depends(get_api_key)
|
||||
):
|
||||
try:
|
||||
# Get the plan tier from the request or default to freemium
|
||||
plan_tier = request.plan_tier.lower() if request.plan_tier else "freemium"
|
||||
|
||||
# Validate plan tier using our PlanTier enum
|
||||
valid_tiers = [t.value for t in PlanTier]
|
||||
if plan_tier not in valid_tiers:
|
||||
plan_tier = PlanTier.FREEMIUM.value # Default to freemium if invalid tier
|
||||
|
||||
# Check if the plan includes speaker identification
|
||||
include_speakers = PlanLimits.get_limit(plan_tier, "speaker_identification")
|
||||
|
||||
# Use the transcribe_media function to transcribe the media
|
||||
if request.media_url:
|
||||
@@ -88,7 +99,7 @@ async def chat_endpoint(
|
||||
|
||||
# Parse response
|
||||
words = transcription_response["results"]["channels"][0]["alternatives"][0]["words"]
|
||||
transcript = group_words_into_sentences(words=words)
|
||||
transcript = group_words_into_sentences(words=words, include_speakers=include_speakers)
|
||||
return TranscriptResponse(
|
||||
transcript=transcript, # Corrected to return the transcript
|
||||
error=None
|
||||
|
||||
Reference in New Issue
Block a user