tokenator 0.1.0__py3-none-any.whl → 0.1.1__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/schemas.py CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import uuid
4
4
  from datetime import datetime
5
+ import os
5
6
 
6
7
  from sqlalchemy import create_engine, Column, Integer, String, DateTime, Float, Index
7
8
  from sqlalchemy.orm import sessionmaker, scoped_session, declarative_base
@@ -12,7 +13,12 @@ Base = declarative_base()
12
13
 
13
14
  def get_engine(db_path: str = None):
14
15
  """Create SQLAlchemy engine with the given database path."""
15
- db_path = db_path or get_default_db_path()
16
+ if db_path is None:
17
+ try:
18
+ import google.colab # type: ignore
19
+ db_path = '/content/tokenator.db'
20
+ except ImportError:
21
+ db_path = get_default_db_path()
16
22
  return create_engine(f"sqlite:///{db_path}", echo=False)
17
23
 
18
24
  def get_session(db_path: str = None):
tokenator/utils.py CHANGED
@@ -23,13 +23,16 @@ def get_default_db_path() -> str:
23
23
  xdg_data_home = os.environ.get("XDG_DATA_HOME", "")
24
24
  if not xdg_data_home:
25
25
  xdg_data_home = os.path.join(str(Path.home()), ".local", "share")
26
- return os.path.join(xdg_data_home, "tokenator", "usage.db")
26
+ db_path = os.path.join(xdg_data_home, "tokenator", "usage.db")
27
27
  elif system == "windows":
28
28
  # Use %LOCALAPPDATA% on Windows
29
29
  local_app_data = os.environ.get("LOCALAPPDATA", "")
30
30
  if not local_app_data:
31
31
  local_app_data = os.path.join(str(Path.home()), "AppData", "Local")
32
- return os.path.join(local_app_data, "tokenator", "usage.db")
32
+ db_path = os.path.join(local_app_data, "tokenator", "usage.db")
33
33
  else:
34
- # Fallback for other systems
35
- return os.path.join(str(Path.home()), ".tokenator", "usage.db")
34
+ db_path = os.path.join(str(Path.home()), ".tokenator", "usage.db")
35
+
36
+ # Create directory if it doesn't exist
37
+ os.makedirs(os.path.dirname(db_path), exist_ok=True)
38
+ return db_path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: tokenator
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: Token usage tracking wrapper for LLMs
5
5
  License: MIT
6
6
  Author: Ujjwal Maheshwari
@@ -7,10 +7,10 @@ tokenator/migrations/env.py,sha256=eFTw66gG464JV53740RKU32wqEL8uZFReS_INrvkFrU,1
7
7
  tokenator/migrations/script.py.mako,sha256=nJL-tbLQE0Qy4P9S4r4ntNAcikPtoFUlvXe6xvm9ot8,635
8
8
  tokenator/migrations.py,sha256=GH84M6AzidTcscMP0nQspBaQ1v6bjx00V4FeN-v5XAo,1354
9
9
  tokenator/models.py,sha256=EprE_MMJxDS-YXlcIQLZzfekH7xTYbeOC3bx3B2osVw,1171
10
- tokenator/schemas.py,sha256=KQrKv_9Euoai3hBZcuiVclU3BlxQkdfEbwYoFV8MKXY,2112
10
+ tokenator/schemas.py,sha256=eVdBWi6_hTETnPw50glq0OvSh3PbP2pLl_aHdf3fi-M,2278
11
11
  tokenator/usage.py,sha256=aHjGwzDzaiVznahNk5HqVyk3IxDo5FtFVfOUCeE7DZ4,7833
12
- tokenator/utils.py,sha256=VF-t6eL16_KokICMfZvO1rIJX9Hm7rexUcaeuLI2iRA,1311
13
- tokenator-0.1.0.dist-info/LICENSE,sha256=wdG-B6-ODk8RQ4jq5uXSn0w1UWTzCH_MMyvh7AwtGns,1074
14
- tokenator-0.1.0.dist-info/METADATA,sha256=dlsCQKC_2qVw4OEfj8ISrt5QwIY774PO_H2S3ilj92g,2444
15
- tokenator-0.1.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
16
- tokenator-0.1.0.dist-info/RECORD,,
12
+ tokenator/utils.py,sha256=WAMRY78d2g0PGSQZzPGoEuhJvQO5Iabgx4Wb6ykYp0Q,1407
13
+ tokenator-0.1.1.dist-info/LICENSE,sha256=wdG-B6-ODk8RQ4jq5uXSn0w1UWTzCH_MMyvh7AwtGns,1074
14
+ tokenator-0.1.1.dist-info/METADATA,sha256=ot6LXHhCJ6JrPOU6o18D-rgoarh2ZT0mn4uhPgJbcXU,2444
15
+ tokenator-0.1.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
16
+ tokenator-0.1.1.dist-info/RECORD,,