python-fastllm 0.0.56__py3-none-any.whl → 0.0.58__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.56"
5
+ __version__ = "0.0.58"
fastllm/acomplete.py CHANGED
@@ -39,7 +39,7 @@ vendor_mapping = {
39
39
  "fireworks_ai": ('openai_chat', "https://api.fireworks.ai/inference/v1", "FIREWORKS_API_KEY"),
40
40
  "qwen": ('openai_chat', "https://dashscope.aliyuncs.com/compatible-mode/v1", "QWEN_API_KEY"),
41
41
  "minimax": ('anthropic', "https://api.minimax.io/anthropic", "MINIMAX_API_KEY"),
42
- "meta": ('openai', "https://api.meta.ai/v1", "META_API_KEY"),
42
+ "meta": ('openai_chat', "https://api.meta.ai/v1", "META_API_KEY"),
43
43
  "zai": ('openai_chat', "https://api.z.ai/api/paas/v4", "ZAI_API_KEY")}
44
44
 
45
45
  # %% ../nbs/06_acomplete.ipynb #e3ed40fb
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):
@@ -53,8 +53,7 @@ def norm_usage(resp):
53
53
  server_tool_use = dict(Counter(o['type'] for o in resp.get('output', []) if o.get('type') != 'function_call' and o.get('type', '').endswith('_call')))
54
54
  if server_tool_use: usg['server_tool_use'] = server_tool_use
55
55
  return Usage(prompt_tokens=pt, completion_tokens=ct, total_tokens=tt,
56
- cached_tokens=cached, reasoning_tokens=reasoning, raw=usg)
57
-
56
+ cached_tokens=cached, reasoning_tokens=reasoning, search_queries=server_tool_use.get('web_search_call', 0), raw=usg)
58
57
 
59
58
  # %% ../nbs/02_oai_responses.ipynb #95102df4
60
59
  def norm_finish(resp, tcs=None):
fastllm/types.py CHANGED
@@ -26,16 +26,15 @@ from aidialog.msg_parts import Msg, Thinking, ToolUse, Completion, StopResponse,
26
26
  class Usage(BasicRepr):
27
27
  "Normalized usage."
28
28
  def __init__(self, prompt_tokens=0, completion_tokens=0, total_tokens=0, cached_tokens=0,
29
- cache_creation_tokens=0, reasoning_tokens=0, raw=None):
29
+ cache_creation_tokens=0, reasoning_tokens=0, search_queries=0, raw=None):
30
30
  if raw is None: raw = {}
31
31
  store_attr()
32
32
  def __eq__(self, o): return type(o) is type(self) and self.__dict__ == o.__dict__
33
33
 
34
-
35
34
  # %% ../nbs/00_types.ipynb #bae1c130
36
35
  @patch
37
36
  def __add__(self:Usage, o):
38
- fields = 'prompt_tokens completion_tokens total_tokens cached_tokens cache_creation_tokens reasoning_tokens'.split()
37
+ fields = 'prompt_tokens completion_tokens total_tokens cached_tokens cache_creation_tokens reasoning_tokens search_queries'.split()
39
38
  return Usage(**{k: getattr(self, k)+getattr(o, k) for k in fields}, raw=o.raw)
40
39
 
41
40
  # %% ../nbs/00_types.ipynb #4901e693
@@ -366,4 +365,5 @@ def cost(self:Completion):
366
365
  api = api_registry[self.api_name]
367
366
  if not hasattr(api, 'cost'): raise NotImplementedError(f"API: {self.api_name} doesn't have a registered `cost` function in ns")
368
367
  res = api.cost(self.usage, meta)
368
+ if (n := self.usage.search_queries) and (rates := meta.get('search_context_cost_per_query')): res += n * rates['search_context_size_medium']
369
369
  return res*2 if self.vendor_name=='deepseek' and self.model.startswith('deepseek-v4') and is_deepseek_peak_hour() else res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fastllm
3
- Version: 0.0.56
3
+ Version: 0.0.58
4
4
  Author-email: Kerem Turgutlu <keremturgutlu@gmail.com>
5
5
  License: Apache-2.0
6
6
  Project-URL: Repository, https://github.com/AnswerDotAI/fastllm
@@ -0,0 +1,18 @@
1
+ fastllm/__init__.py,sha256=uDoIIuBjxZKcbyRrdFaaGJlfJwWkr9dF7dNA3b04A9k,131
2
+ fastllm/_modidx.py,sha256=qzUtLbjOche-GNbeNun3VRIQdcm5g4dUOCLJ6T9fG-w,46374
3
+ fastllm/acomplete.py,sha256=CusLue35xiaswpmTZyLkJj6t4CVsNDeeY3Sk7hzVNoY,10777
4
+ fastllm/anthropic.py,sha256=ktH-EuQMQnp8O2_6VmSrvvDCIe2QTeSR7jNpWfqf3L4,18884
5
+ fastllm/chat.py,sha256=klji3SOYs5xyzrSFbNhy3uoQ2TSZ3a-8HTjvdRtaG5Q,25036
6
+ fastllm/codex.py,sha256=r6auZ8egia83aGkWcF4132AzW4SsBvKeDwg_CxyXj9E,5808
7
+ fastllm/gemini.py,sha256=vpY_f4Jqn344l9CANm6_c7Cmhjq2URXxWhdVv_LswSg,17615
8
+ fastllm/model_prices.json,sha256=pa0j96LZgklYii8howX443QbukUP1iFr3lBcucS-6Yo,2133018
9
+ fastllm/openai_chat.py,sha256=n5INfDCsAZIiKUImWeaX6SJ_OAJ_uMhw20HUkgFgdgM,12379
10
+ fastllm/openai_responses.py,sha256=NrvzNCKkSQabbAMnxYCSPdROaT1u8Vp2eoRzbzAA-4M,15345
11
+ fastllm/responses.py,sha256=9gh-UlhfswCcP0RCzLuPT5meWNh9mF_OIivzCzZU94I,22726
12
+ fastllm/streaming.py,sha256=DrqNJkMhyntFKokY6GF6oW3CjELrk5XWmnxwcApJUyM,8770
13
+ fastllm/types.py,sha256=OznlKQZUx2DrLE_O-sbIBsT6q6EBeVDlH9kXxhsGBSE,19445
14
+ python_fastllm-0.0.58.dist-info/METADATA,sha256=scQa4XA1Oh28m6HO6knQtPmOwV_E0ppqFdXuMH8GTA8,18537
15
+ python_fastllm-0.0.58.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
16
+ python_fastllm-0.0.58.dist-info/entry_points.txt,sha256=WkWd04F3xVYFP5bsexaQe9Se6uelwE5ULoTtHWreO0s,133
17
+ python_fastllm-0.0.58.dist-info/top_level.txt,sha256=F8qodL7nEGUHGmzzqfhNKCTIr1i0D6cvudOnm3z7o0Y,8
18
+ python_fastllm-0.0.58.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- fastllm/__init__.py,sha256=OWNw1jlF14M2QUzFV9voeL-APa-sSFSfenIVDvWhGFQ,131
2
- fastllm/_modidx.py,sha256=qzUtLbjOche-GNbeNun3VRIQdcm5g4dUOCLJ6T9fG-w,46374
3
- fastllm/acomplete.py,sha256=64-k3LgLoX1EoWcHBS_-epZ-JvX5JL-As9QTo-WSzDc,10772
4
- fastllm/anthropic.py,sha256=vsWkmIxIh8j7LTPfLzgrNggOl_2LuRKKcdVhLfDDdRE,18748
5
- fastllm/chat.py,sha256=klji3SOYs5xyzrSFbNhy3uoQ2TSZ3a-8HTjvdRtaG5Q,25036
6
- fastllm/codex.py,sha256=r6auZ8egia83aGkWcF4132AzW4SsBvKeDwg_CxyXj9E,5808
7
- fastllm/gemini.py,sha256=978x7WDug5nSNvTOacap3bglgQhddahykFQvoOKOvhs,17571
8
- fastllm/model_prices.json,sha256=pa0j96LZgklYii8howX443QbukUP1iFr3lBcucS-6Yo,2133018
9
- fastllm/openai_chat.py,sha256=n5INfDCsAZIiKUImWeaX6SJ_OAJ_uMhw20HUkgFgdgM,12379
10
- fastllm/openai_responses.py,sha256=O30JBRG0kTI31FPnzAOMEE8iiIsMBdAxVGoZys58Jn4,15288
11
- fastllm/responses.py,sha256=9gh-UlhfswCcP0RCzLuPT5meWNh9mF_OIivzCzZU94I,22726
12
- fastllm/streaming.py,sha256=DrqNJkMhyntFKokY6GF6oW3CjELrk5XWmnxwcApJUyM,8770
13
- fastllm/types.py,sha256=hET6SNjqC8Z5PasrZ4uU-OObIfs3QyI0ZPY4jE2rh1Q,19268
14
- python_fastllm-0.0.56.dist-info/METADATA,sha256=NhRX9Fj4A7nRSg-bjmytouLTvjaE5TIYVLnZc3prEvM,18537
15
- python_fastllm-0.0.56.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
16
- python_fastllm-0.0.56.dist-info/entry_points.txt,sha256=WkWd04F3xVYFP5bsexaQe9Se6uelwE5ULoTtHWreO0s,133
17
- python_fastllm-0.0.56.dist-info/top_level.txt,sha256=F8qodL7nEGUHGmzzqfhNKCTIr1i0D6cvudOnm3z7o0Y,8
18
- python_fastllm-0.0.56.dist-info/RECORD,,