tokenator 0.1.14__py3-none-any.whl → 0.1.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
tokenator/utils.py CHANGED
@@ -5,8 +5,21 @@ import platform
5
5
  import logging
6
6
  from pathlib import Path
7
7
 
8
+
8
9
  logger = logging.getLogger(__name__)
9
10
 
11
+ def is_notebook() -> bool:
12
+ try:
13
+ from IPython import get_ipython # type: ignore
14
+ shell = get_ipython().__class__.__name__
15
+ if shell == 'ZMQInteractiveShell':
16
+ return True # Jupyter notebook or qtconsole
17
+ elif shell == 'TerminalInteractiveShell':
18
+ return False # Terminal running IPython
19
+ else:
20
+ return False # Other type (?)
21
+ except NameError:
22
+ return False
10
23
 
11
24
  def is_colab() -> bool:
12
25
  """Check if running in Google Colab."""
@@ -21,7 +34,7 @@ def is_colab() -> bool:
21
34
  def get_default_db_path() -> str:
22
35
  """Get the platform-specific default database path."""
23
36
  try:
24
- if is_colab():
37
+ if is_colab() or is_notebook():
25
38
  # Use in-memory database for Colab
26
39
  return "usage.db"
27
40
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tokenator
3
- Version: 0.1.14
3
+ Version: 0.1.16
4
4
  Summary: Token usage tracking wrapper for LLMs
5
5
  License: MIT
6
6
  Author: Ujjwal Maheshwari
@@ -15,19 +15,21 @@ Classifier: Programming Language :: Python :: 3.12
15
15
  Classifier: Programming Language :: Python :: 3.13
16
16
  Requires-Dist: alembic (>=1.13.0,<2.0.0)
17
17
  Requires-Dist: anthropic (>=0.43.0,<0.44.0)
18
+ Requires-Dist: ipython
18
19
  Requires-Dist: openai (>=1.59.0,<2.0.0)
19
20
  Requires-Dist: requests (>=2.32.3,<3.0.0)
20
21
  Requires-Dist: sqlalchemy (>=2.0.0,<3.0.0)
21
22
  Description-Content-Type: text/markdown
22
23
 
23
- # Tokenator : Track and analyze LLM token usage and cost
24
+ # Tokenator : Track, analyze, compare LLM token usage and costs
24
25
 
25
- Have you ever wondered about :
26
+ Have you ever wondered :
26
27
  - How many tokens does your AI agent consume?
27
- - How much does it cost to do run a complex AI workflow with multiple LLM providers?
28
+ - How much does it cost to run a complex AI workflow with multiple LLM providers?
29
+ - Which LLM is more cost effective for my use case?
28
30
  - How much money/tokens did you spend today on developing with LLMs?
29
31
 
30
- Afraid not, tokenator is here! With tokenator's easy to use API, you can start tracking LLM usage in a matter of minutes.
32
+ Afraid not, tokenator is here! With tokenator's easy to use functions, you can start tracking LLM usage in a matter of minutes.
31
33
 
32
34
  Get started with just 3 lines of code!
33
35
 
@@ -113,6 +115,10 @@ print(cost.last_hour().model_dump_json(indent=4))
113
115
  }
114
116
  ```
115
117
 
118
+ ## Cookbooks
119
+
120
+ Want more code, example use cases and ideas? Check out our amazing [cookbooks](https://github.com/ujjwalm29/tokenator/tree/main/docs/cookbooks)!
121
+
116
122
  ## Features
117
123
 
118
124
  - Drop-in replacement for OpenAI, Anthropic client
@@ -0,0 +1,21 @@
1
+ tokenator/__init__.py,sha256=AEPE73UGB_TeNLhro3eY0hU8yy6T-_6AyDls8vWApnE,465
2
+ tokenator/anthropic/client_anthropic.py,sha256=2oxTLb5-sPK_KL-OumCjE4wPVI8U_eFyRonn9XjGXJw,7196
3
+ tokenator/anthropic/stream_interceptors.py,sha256=4VHC_-WkG3Pa10YizmFLrHcbz0Tm2MR_YB5-uohKp5A,5221
4
+ tokenator/base_wrapper.py,sha256=EQ49xGduEp05-gj1xyZDasrck4RpComaoKslHxQTwuw,4956
5
+ tokenator/create_migrations.py,sha256=k9IHiGK21dLTA8MYNsuhO0-kUVIcMSViMFYtY4WU2Rw,730
6
+ tokenator/migrations/env.py,sha256=JoF5MJ4ae0wJW5kdBHuFlG3ZqeCCDvbMcU8fNA_a6hM,1396
7
+ tokenator/migrations/script.py.mako,sha256=nJL-tbLQE0Qy4P9S4r4ntNAcikPtoFUlvXe6xvm9ot8,635
8
+ tokenator/migrations/versions/f028b8155fed_adding_detailed_input_and_output_token_.py,sha256=WIZN5HdNRXlRdfpUJpJFaPD4G1s-SgRdTMQl4WDB-hA,2189
9
+ tokenator/migrations/versions/f6f1f2437513_initial_migration.py,sha256=4cveHkwSxs-hxOPCm81YfvGZTkJJ2ClAFmyL98-1VCo,1910
10
+ tokenator/migrations.py,sha256=YAf9gZmDzAq36PWWXPtdUQoJFYPXtIDzflC79H6gcJg,1114
11
+ tokenator/models.py,sha256=p4uoFqJYGMlygotxip_HZcfM16Jm4LoyFLFTsM1Z8a4,2132
12
+ tokenator/openai/client_openai.py,sha256=pbdJ-aZPuJs-7OT1VEv0DW36cCYbRAVKhSQEprxVIdY,9686
13
+ tokenator/openai/stream_interceptors.py,sha256=ez1MnjRZW_rEalv2SIPAvrU9oMD6OJoD9vht-057fDM,5243
14
+ tokenator/schemas.py,sha256=kBmShqgpQ3W-ILAP1NuCaFgqFplQM4OH0MmJteLqrwI,2371
15
+ tokenator/state.py,sha256=xdqDC-rlEA88-VgqQqHnAOXQ5pNTpnHcgOtohDIImPY,262
16
+ tokenator/usage.py,sha256=YnV4fZo0prUC4oPKNZjyN7misn1od6ANwXcLKCuN21Y,24982
17
+ tokenator/utils.py,sha256=djoWmAhqH-O2Su3qIcuY-_3Vj1-qPwMcdzwq9IlwiDc,2435
18
+ tokenator-0.1.16.dist-info/LICENSE,sha256=wdG-B6-ODk8RQ4jq5uXSn0w1UWTzCH_MMyvh7AwtGns,1074
19
+ tokenator-0.1.16.dist-info/METADATA,sha256=B8sy9h8PaDG075-FYjSCz8rMOqoTdy3eOJsUQlxA9Lk,6257
20
+ tokenator-0.1.16.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
21
+ tokenator-0.1.16.dist-info/RECORD,,
@@ -1,20 +0,0 @@
1
- tokenator/__init__.py,sha256=AEPE73UGB_TeNLhro3eY0hU8yy6T-_6AyDls8vWApnE,465
2
- tokenator/anthropic/client_anthropic.py,sha256=uWUrRId7vJlMG6hVKLUzaA3PoOT6mJwTqSRIhAidRFY,6163
3
- tokenator/anthropic/stream_interceptors.py,sha256=4VHC_-WkG3Pa10YizmFLrHcbz0Tm2MR_YB5-uohKp5A,5221
4
- tokenator/base_wrapper.py,sha256=UoS3cOuPa3HpuXPTawybvAtwufgZwzzKBj0BhyB-z6w,3160
5
- tokenator/create_migrations.py,sha256=k9IHiGK21dLTA8MYNsuhO0-kUVIcMSViMFYtY4WU2Rw,730
6
- tokenator/migrations/env.py,sha256=JoF5MJ4ae0wJW5kdBHuFlG3ZqeCCDvbMcU8fNA_a6hM,1396
7
- tokenator/migrations/script.py.mako,sha256=nJL-tbLQE0Qy4P9S4r4ntNAcikPtoFUlvXe6xvm9ot8,635
8
- tokenator/migrations/versions/f6f1f2437513_initial_migration.py,sha256=4cveHkwSxs-hxOPCm81YfvGZTkJJ2ClAFmyL98-1VCo,1910
9
- tokenator/migrations.py,sha256=YAf9gZmDzAq36PWWXPtdUQoJFYPXtIDzflC79H6gcJg,1114
10
- tokenator/models.py,sha256=AlNC5NVrycLg0LhDJIww9HXQ3lwM8CoKvRSqXU6iw-k,1225
11
- tokenator/openai/client_openai.py,sha256=LhD1IbpzPXRK9eSqtcfUfoM9vBsyw6OHA0_a7N_tS9U,6230
12
- tokenator/openai/stream_interceptors.py,sha256=ez1MnjRZW_rEalv2SIPAvrU9oMD6OJoD9vht-057fDM,5243
13
- tokenator/schemas.py,sha256=zIgfmSsFJV9ziJdKrpV8p2P1f-BVWUVIpWoqCLpzhEU,2225
14
- tokenator/state.py,sha256=xdqDC-rlEA88-VgqQqHnAOXQ5pNTpnHcgOtohDIImPY,262
15
- tokenator/usage.py,sha256=ghnZ7pQuIxeI38O63xDAbEm6jOSmkYE7MChHBGPxbyM,11229
16
- tokenator/utils.py,sha256=xg9l2GV1yJL1BlxKL1r8CboABWDslf3G5rGQEJSjFrE,1973
17
- tokenator-0.1.14.dist-info/LICENSE,sha256=wdG-B6-ODk8RQ4jq5uXSn0w1UWTzCH_MMyvh7AwtGns,1074
18
- tokenator-0.1.14.dist-info/METADATA,sha256=L93LfqCfqvhES92COaQZpX5w9_c2aDaX8pj2wT74Sxw,6018
19
- tokenator-0.1.14.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
20
- tokenator-0.1.14.dist-info/RECORD,,