Creditsupdates in fotoer wdigets adn hoemapge and singe site settigns page #Run MIgration 0033 #MAJOR
This commit is contained in:
@@ -444,6 +444,9 @@ class AIEngine:
|
||||
tokens_input = raw_response.get('input_tokens', 0)
|
||||
tokens_output = raw_response.get('output_tokens', 0)
|
||||
|
||||
# Extract site_id from save_result (could be from content, cluster, or task)
|
||||
site_id = save_result.get('site_id') or save_result.get('site')
|
||||
|
||||
# Deduct credits based on actual token usage
|
||||
CreditService.deduct_credits_for_operation(
|
||||
account=self.account,
|
||||
@@ -454,6 +457,7 @@ class AIEngine:
|
||||
model_used=raw_response.get('model', ''),
|
||||
related_object_type=self._get_related_object_type(function_name),
|
||||
related_object_id=save_result.get('id') or save_result.get('cluster_id') or save_result.get('task_id'),
|
||||
site=site_id,
|
||||
metadata={
|
||||
'function_name': function_name,
|
||||
'clusters_created': clusters_created,
|
||||
|
||||
Reference in New Issue
Block a user