python-fastllm 0.0.55__py3-none-any.whl → 0.0.57__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.
fastllm/__init__.py CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  - `fastllm.responses`: Provider-independent Responses resources and streaming over FastLLM"""
4
4
 
5
- __version__ = "0.0.55"
5
+ __version__ = "0.0.57"
fastllm/anthropic.py CHANGED
@@ -44,7 +44,8 @@ def norm_usage(resp):
44
44
  pt = int(usg.get("input_tokens", 0) or 0) + cached + cache_creation
45
45
  ct = int(usg.get("output_tokens", 0) or 0)
46
46
  return Usage(prompt_tokens=pt, completion_tokens=ct, total_tokens=pt + ct,
47
- cached_tokens=cached, cache_creation_tokens=cache_creation, reasoning_tokens=0, raw=usg)
47
+ cached_tokens=cached, cache_creation_tokens=cache_creation, reasoning_tokens=0, raw=usg,
48
+ search_queries=int(nested_idx(usg, 'server_tool_use', 'web_search_requests') or 0))
48
49
 
49
50
  def finalize_usage(usg, parts):
50
51
  "Split reasoning tokens out of `output_tokens`: the reported `thinking_tokens`, else an estimate from the thinking text."
@@ -53,7 +54,7 @@ def finalize_usage(usg, parts):
53
54
  ct = int(usg.raw.get('output_tokens', usg.completion_tokens) or 0)
54
55
  rt = int(nested_idx(usg.raw, 'output_tokens_details', 'thinking_tokens') or 0) or (min(int(len(rc.split())*1.5), ct) if rc else 0)
55
56
  return Usage(prompt_tokens=usg.prompt_tokens, completion_tokens=ct-rt, total_tokens=usg.prompt_tokens+ct,
56
- cached_tokens=usg.cached_tokens, cache_creation_tokens=usg.cache_creation_tokens, reasoning_tokens=rt, raw=usg.raw)
57
+ cached_tokens=usg.cached_tokens, cache_creation_tokens=usg.cache_creation_tokens, reasoning_tokens=rt, search_queries=usg.search_queries, raw=usg.raw)
57
58
 
58
59
  # %% ../nbs/04_anthropic.ipynb #7a8b1f8f
59
60
  def norm_finish(resp, tcs=None):
fastllm/gemini.py CHANGED
@@ -67,7 +67,7 @@ def norm_usage(resp):
67
67
  if call := grounding(cand)[1]: stu['google_search'] = len(call.arguments['queries'] or [1])
68
68
  if stu: usg['server_tool_use'] = stu
69
69
  return Usage(prompt_tokens=pt, completion_tokens=ct, total_tokens=tt,
70
- cached_tokens=cached, reasoning_tokens=reasoning, raw=usg)
70
+ cached_tokens=cached, reasoning_tokens=reasoning, search_queries=stu.get('google_search', 0), raw=usg)
71
71
 
72
72
  # %% ../nbs/05_gemini.ipynb #7a8b1f8f
73
73
  def norm_finish(resp, tcs=None):