python-fastllm 0.0.64__tar.gz → 0.0.65__tar.gz

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.
Files changed (23) hide show
  1. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/PKG-INFO +1 -1
  2. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/__init__.py +1 -1
  3. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/anthropic.py +9 -12
  4. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/model_prices.json +3890 -964
  5. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/openai_chat.py +4 -8
  6. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/types.py +19 -15
  7. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/python_fastllm.egg-info/PKG-INFO +1 -1
  8. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/README.md +0 -0
  9. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/_modidx.py +0 -0
  10. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/acomplete.py +0 -0
  11. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/chat.py +0 -0
  12. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/codex.py +0 -0
  13. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/gemini.py +0 -0
  14. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/openai_responses.py +0 -0
  15. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/responses.py +0 -0
  16. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/fastllm/streaming.py +0 -0
  17. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/pyproject.toml +0 -0
  18. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/python_fastllm.egg-info/SOURCES.txt +0 -0
  19. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/python_fastllm.egg-info/dependency_links.txt +0 -0
  20. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/python_fastllm.egg-info/entry_points.txt +0 -0
  21. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/python_fastllm.egg-info/requires.txt +0 -0
  22. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/python_fastllm.egg-info/top_level.txt +0 -0
  23. {python_fastllm-0.0.64 → python_fastllm-0.0.65}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-fastllm
3
- Version: 0.0.64
3
+ Version: 0.0.65
4
4
  Author-email: Kerem Turgutlu <keremturgutlu@gmail.com>
5
5
  License-Expression: Apache-2.0
6
6
  Project-URL: Repository, https://github.com/AnswerDotAI/fastllm
@@ -2,4 +2,4 @@
2
2
 
3
3
  - `fastllm.responses`: Provider-independent Responses resources and streaming over FastLLM"""
4
4
 
5
- __version__ = "0.0.64"
5
+ __version__ = "0.0.65"
@@ -11,7 +11,6 @@ __all__ = ['ant_tc_types', 'norm_tool_call', 'norm_tool_calls', 'norm_usage', 'f
11
11
 
12
12
  # %% ../nbs/06_anthropic.ipynb #02afd3d7
13
13
  import json, copy
14
- from collections import Counter
15
14
  from fastcore.utils import *
16
15
  from fastcore.meta import *
17
16
  from fasttransport.errors import api_error_from_event
@@ -337,7 +336,9 @@ def apply_cache_idxs(
337
336
  def mk_payload(msgs, model, **kwargs):
338
337
  sp = kwargs.get('system')
339
338
  if (ci:=kwargs.get('cache_idxs')) is not None: sp = apply_cache_idxs(msgs, ci, sp, kwargs.get('ttl'))
340
- payload = dict(model=model, messages=denorm_msgs(msgs), max_tokens=kwargs.get('max_tokens') or 1024)
339
+ max_tokens = kwargs.get('max_tokens')
340
+ if max_tokens is None: max_tokens = get_model_info(model, 'anthropic').get('max_output_tokens') or 1024
341
+ payload = dict(model=model, messages=denorm_msgs(msgs), max_tokens=max_tokens)
341
342
  if kwargs.get('stream'): payload['stream'] = True
342
343
  if sp: payload['system'] = denorm_system(sp)
343
344
  if tools:=kwargs.get('tools'): payload['tools'] = denorm_tool_schs(tools)
@@ -358,17 +359,13 @@ def get_hdrs(api_key=None, oauth_token=None):
358
359
  # %% ../nbs/06_anthropic.ipynb #0d03643a
359
360
  def cost(usage, m):
360
361
  raw = usage.raw
361
- in_tok = raw['input_tokens']
362
- cache_read = raw.get('cache_read_input_tokens', 0)
363
362
  cc = raw.get('cache_creation', {}) or {}
364
- cache_5m = cc.get('ephemeral_5m_input_tokens', raw.get('cache_creation_input_tokens', 0))
365
- cache_1h = cc.get('ephemeral_1h_input_tokens', 0)
366
- cost = in_tok * m.input_cost_per_token
367
- cost += raw['output_tokens'] * m.output_cost_per_token
368
- cost += cache_read * m.get('cache_read_input_token_cost', 0)
369
- cost += cache_5m * m.get('cache_creation_input_token_cost', 0)
370
- cost += cache_1h * m.get('cache_creation_input_token_cost_above_1hr', 0)
371
- return cost
363
+ prompt = dict(input_cost_per_token=raw['input_tokens'], cache_read_input_token_cost=raw.get('cache_read_input_tokens', 0),
364
+ cache_creation_input_token_cost=cc.get('ephemeral_5m_input_tokens', raw.get('cache_creation_input_tokens', 0)),
365
+ cache_creation_input_token_cost_above_1hr=cc.get('ephemeral_1h_input_tokens', 0))
366
+ tier = price_tier(m, sum(prompt.values()))
367
+ toks = prompt | dict(output_cost_per_token=raw['output_tokens'])
368
+ return sum(n * tier_rate(m, k, tier) for k,n in toks.items())
372
369
 
373
370
  # %% ../nbs/06_anthropic.ipynb #f7c0b989
374
371
  api_registry.register('anthropic', norm_tool_calls=norm_tool_calls, norm_parts=norm_parts, norm_finish=norm_finish, norm_usage=norm_usage,