Phase 0: Update credit costs and CreditService, add credit checks to AI Engine
- Updated CREDIT_COSTS to match Phase 0 spec (flat structure) - Added get_credit_cost() method to CreditService - Updated check_credits() to accept operation_type and amount - Added deduct_credits_for_operation() convenience method - Updated AI Engine to check credits BEFORE AI call - Updated AI Engine to deduct credits AFTER successful execution - Added helper methods for operation type mapping and amount calculation
This commit is contained in:
@@ -1,22 +1,21 @@
|
||||
"""
|
||||
Credit Cost Constants
|
||||
Phase 0: Credit-only system costs per operation
|
||||
"""
|
||||
CREDIT_COSTS = {
|
||||
'clustering': {
|
||||
'base': 1, # 1 credit per 30 keywords
|
||||
'per_keyword': 1 / 30,
|
||||
},
|
||||
'ideas': {
|
||||
'base': 1, # 1 credit per idea
|
||||
},
|
||||
'content': {
|
||||
'base': 3, # 3 credits per full blog post
|
||||
},
|
||||
'images': {
|
||||
'base': 1, # 1 credit per image
|
||||
},
|
||||
'reparse': {
|
||||
'base': 1, # 1 credit per reparse
|
||||
},
|
||||
'clustering': 10, # Per clustering request
|
||||
'idea_generation': 15, # Per cluster → ideas request
|
||||
'content_generation': 1, # Per 100 words
|
||||
'image_prompt_extraction': 2, # Per content piece
|
||||
'image_generation': 5, # Per image
|
||||
'linking': 8, # Per content piece (NEW)
|
||||
'optimization': 1, # Per 200 words (NEW)
|
||||
'site_structure_generation': 50, # Per site blueprint (NEW)
|
||||
'site_page_generation': 20, # Per page (NEW)
|
||||
# Legacy operation types (for backward compatibility)
|
||||
'ideas': 15, # Alias for idea_generation
|
||||
'content': 3, # Legacy: 3 credits per content piece
|
||||
'images': 5, # Alias for image_generation
|
||||
'reparse': 1, # Per reparse
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user