Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
aisbf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
aisbf
Commits
b4bc6fb6
Commit
b4bc6fb6
authored
Apr 21, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Cast Decimal token counts to float in estimate_cost method
parent
4c2be0ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
analytics.py
aisbf/analytics.py
+7
-2
antani_sqlite_db_3f9c7e7f.sqlite3
antani_sqlite_db_3f9c7e7f.sqlite3
+0
-0
No files found.
aisbf/analytics.py
View file @
b4bc6fb6
...
...
@@ -927,14 +927,19 @@ class Analytics:
logger
.
info
(
f
" tokens_used: {tokens_used}, prompt: {prompt_tokens}, completion: {completion_tokens}"
)
logger
.
info
(
f
" Pricing: prompt=${provider_pricing.get('prompt', 0)}/M, completion=${provider_pricing.get('completion', 0)}/M"
)
# Convert Decimal values from MySQL to float for calculations
tokens_used
=
float
(
tokens_used
)
if
tokens_used
is
not
None
else
0
prompt_tokens
=
float
(
prompt_tokens
)
if
prompt_tokens
is
not
None
else
0
completion_tokens
=
float
(
completion_tokens
)
if
completion_tokens
is
not
None
else
0
# Calculate cost with actual token breakdown if available
if
prompt_tokens
is
not
None
and
completion_tokens
is
not
None
:
if
prompt_tokens
>
0
and
completion_tokens
>
0
:
prompt_cost
=
(
prompt_tokens
/
1_000_000
)
*
provider_pricing
.
get
(
'prompt'
,
0
)
completion_cost
=
(
completion_tokens
/
1_000_000
)
*
provider_pricing
.
get
(
'completion'
,
0
)
total_cost
=
prompt_cost
+
completion_cost
logger
.
info
(
f
" Calculated: ${prompt_cost:.8f} + ${completion_cost:.8f} = ${total_cost:.8f}"
)
return
total_cost
elif
prompt_tokens
is
not
None
:
elif
prompt_tokens
>
0
:
# Only prompt tokens provided, calculate completion from total
completion_tokens_calc
=
tokens_used
-
prompt_tokens
prompt_cost
=
(
prompt_tokens
/
1_000_000
)
*
provider_pricing
.
get
(
'prompt'
,
0
)
...
...
antani_sqlite_db_3f9c7e7f.sqlite3
deleted
100644 → 0
View file @
4c2be0ef
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment