credits adn tokens final correct setup
This commit is contained in:
@@ -63,10 +63,14 @@ class LinkerService:
|
||||
content.linker_version += 1
|
||||
content.save(update_fields=['html_content', 'internal_links', 'linker_version'])
|
||||
|
||||
# Deduct credits
|
||||
# Deduct credits (non-AI operation - use fixed token estimate)
|
||||
# Estimate: 1 token per 4 characters of HTML content
|
||||
estimated_tokens = len(content.html_content or '') // 4
|
||||
self.credit_service.deduct_credits_for_operation(
|
||||
account=account,
|
||||
operation_type='linking',
|
||||
tokens_input=estimated_tokens,
|
||||
tokens_output=0, # No output tokens for linking operation
|
||||
description=f"Internal linking for content: {content.title or 'Untitled'}",
|
||||
related_object_type='content',
|
||||
related_object_id=content.id
|
||||
@@ -139,10 +143,14 @@ class LinkerService:
|
||||
content.linker_version += 1
|
||||
content.save(update_fields=['html_content', 'internal_links', 'linker_version'])
|
||||
|
||||
# Deduct credits
|
||||
# Deduct credits (non-AI operation - use fixed token estimate)
|
||||
# Estimate: 1 token per 4 characters of HTML content
|
||||
estimated_tokens = len(content.html_content or '') // 4
|
||||
self.credit_service.deduct_credits_for_operation(
|
||||
account=account,
|
||||
operation_type='linking',
|
||||
tokens_input=estimated_tokens,
|
||||
tokens_output=0,
|
||||
description=f"Product linking for: {content.title or 'Untitled'}",
|
||||
related_object_type='content',
|
||||
related_object_id=content.id
|
||||
@@ -193,10 +201,14 @@ class LinkerService:
|
||||
content.linker_version += 1
|
||||
content.save(update_fields=['html_content', 'internal_links', 'linker_version'])
|
||||
|
||||
# Deduct credits
|
||||
# Deduct credits (non-AI operation - use fixed token estimate)
|
||||
# Estimate: 1 token per 4 characters of HTML content
|
||||
estimated_tokens = len(content.html_content or '') // 4
|
||||
self.credit_service.deduct_credits_for_operation(
|
||||
account=account,
|
||||
operation_type='linking',
|
||||
tokens_input=estimated_tokens,
|
||||
tokens_output=0,
|
||||
description=f"Taxonomy linking for: {content.title or 'Untitled'}",
|
||||
related_object_type='content',
|
||||
related_object_id=content.id
|
||||
|
||||
Reference in New Issue
Block a user