python-fastllm 0.0.29__tar.gz → 0.0.31__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.
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/PKG-INFO +1 -1
- python_fastllm-0.0.31/fastllm/__init__.py +1 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/_modidx.py +2 -1
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/acomplete.py +17 -2
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/chat.py +7 -1
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/python_fastllm.egg-info/PKG-INFO +1 -1
- python_fastllm-0.0.29/fastllm/__init__.py +0 -1
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/README.md +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/anthropic.py +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/codex.py +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/gemini.py +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/openai_chat.py +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/openai_responses.py +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/specs/anthropic.json +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/specs/anthropic.yml +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/specs/gemini.json +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/specs/openai.with-code-samples.json +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/specs/openai.with-code-samples.yml +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/specs/spec_manifest.json +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/streaming.py +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/fastllm/types.py +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/pyproject.toml +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/python_fastllm.egg-info/SOURCES.txt +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/python_fastllm.egg-info/dependency_links.txt +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/python_fastllm.egg-info/entry_points.txt +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/python_fastllm.egg-info/requires.txt +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/python_fastllm.egg-info/top_level.txt +0 -0
- {python_fastllm-0.0.29 → python_fastllm-0.0.31}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.31"
|
|
@@ -16,7 +16,8 @@ d = { 'settings': { 'branch': 'main',
|
|
|
16
16
|
'fastllm.acomplete._retry_call': ('acomplete.html#_retry_call', 'fastllm/acomplete.py'),
|
|
17
17
|
'fastllm.acomplete._retry_stream': ('acomplete.html#_retry_stream', 'fastllm/acomplete.py'),
|
|
18
18
|
'fastllm.acomplete.acomplete': ('acomplete.html#acomplete', 'fastllm/acomplete.py'),
|
|
19
|
-
'fastllm.acomplete.mk_client': ('acomplete.html#mk_client', 'fastllm/acomplete.py')
|
|
19
|
+
'fastllm.acomplete.mk_client': ('acomplete.html#mk_client', 'fastllm/acomplete.py'),
|
|
20
|
+
'fastllm.acomplete.split_vendor': ('acomplete.html#split_vendor', 'fastllm/acomplete.py')},
|
|
20
21
|
'fastllm.anthropic': { 'fastllm.anthropic._ant_cc': ('anthropic.html#_ant_cc', 'fastllm/anthropic.py'),
|
|
21
22
|
'fastllm.anthropic._ant_part_type': ('anthropic.html#_ant_part_type', 'fastllm/anthropic.py'),
|
|
22
23
|
'fastllm.anthropic._sanid': ('anthropic.html#_sanid', 'fastllm/anthropic.py'),
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/06_acomplete.ipynb.
|
|
4
4
|
|
|
5
5
|
# %% auto #0
|
|
6
|
-
__all__ = ['specs_path', 'ant_spec', 'oai_spec', 'gem_spec', 'vendor_mapping', 'api2spec', 'defaults', '
|
|
7
|
-
'ContextWindowExceededError', 'acomplete']
|
|
6
|
+
__all__ = ['specs_path', 'ant_spec', 'oai_spec', 'gem_spec', 'vendor_mapping', 'api2spec', 'defaults', 'split_vendor',
|
|
7
|
+
'mk_client', 'ContextWindowExceededError', 'acomplete']
|
|
8
8
|
|
|
9
9
|
# %% ../nbs/06_acomplete.ipynb #f2f57253
|
|
10
10
|
import asyncio,json,httpx
|
|
@@ -51,11 +51,22 @@ vendor_mapping = {
|
|
|
51
51
|
# %% ../nbs/06_acomplete.ipynb #77d27ea7
|
|
52
52
|
api2spec = {'openai':oai_spec, 'openai_chat':oai_spec, 'anthropic':ant_spec, 'gemini':gem_spec}
|
|
53
53
|
|
|
54
|
+
# %% ../nbs/06_acomplete.ipynb #e3ed40fb
|
|
55
|
+
def split_vendor(model):
|
|
56
|
+
"Split a `'vendor/model'` path into `(vendor_name, model)`: the prefix must name a known vendor or a registered api, else `(None, model)`."
|
|
57
|
+
if model and '/' in model:
|
|
58
|
+
v, m = model.split('/', 1)
|
|
59
|
+
if v in vendor_mapping or v in api_registry.apis: return v, m
|
|
60
|
+
return None, model
|
|
61
|
+
|
|
54
62
|
# %% ../nbs/06_acomplete.ipynb #79075d95
|
|
55
63
|
@flexicache()
|
|
56
64
|
def mk_client(model=None, vendor_name=None, api_name=None, api_key=None, base_url=None, xtra_hdrs=None,
|
|
57
65
|
timeout=httpx.Timeout(connect=30, read=300, write=30, pool=10)):
|
|
58
66
|
err_msg = f"please pass a valid one vendor: {', '.join(list(vendor_mapping))} or pass `api_name`,`base_url` and `api_key`"
|
|
67
|
+
if not vendor_name and not api_name and not (base_url and api_key):
|
|
68
|
+
v, m = split_vendor(model)
|
|
69
|
+
if v in vendor_mapping: vendor_name, model = v, m
|
|
59
70
|
if vendor_name:
|
|
60
71
|
override_base_url = base_url
|
|
61
72
|
try:
|
|
@@ -145,6 +156,10 @@ async def acomplete(msgs, model, api_name=None, vendor_name=None, api_key=None,
|
|
|
145
156
|
base_url=None, xtra_body=None, xtra_hdrs=None, stream=False,
|
|
146
157
|
stop_callables=None, retries=2, retry_delay=0.5, **kwargs):
|
|
147
158
|
"Unified completion across different APIs."
|
|
159
|
+
if not vendor_name and not api_name and not (base_url and api_key):
|
|
160
|
+
v, m = split_vendor(model)
|
|
161
|
+
if v in vendor_mapping: vendor_name, model = v, m
|
|
162
|
+
elif v: api_name, model = v, m # a registered transport api (e.g. claude_code): not an HTTP vendor
|
|
148
163
|
if api_name == 'claude_code':
|
|
149
164
|
if not stream: raise NotImplementedError("claude_code backend supports stream=True only for now")
|
|
150
165
|
api = api_registry.apis[api_name]
|
|
@@ -319,12 +319,12 @@ def _has_stop(tres_parts): return any(isinstance(p.text, StopResponse) for p in
|
|
|
319
319
|
# %% ../nbs/07_chat.ipynb #f58ce348
|
|
320
320
|
def _trunc_str(s, mx=2000, skip=10, replace="TRUNCATED"):
|
|
321
321
|
"Truncate `s` to `mx` chars max, adding `replace` if truncated; `mx=None` disables truncation"
|
|
322
|
+
if mx is None or isinstance_str(s, ('FullResponse','Safe','PrettyString')): return s
|
|
322
323
|
if not isinstance(s, str): s = str(s)
|
|
323
324
|
s = type(s)(s.rstrip())
|
|
324
325
|
if len(s)>2 and s[0]=='𝍁' and s[-1]=='𝍁':
|
|
325
326
|
s = s[1:-1]
|
|
326
327
|
if replace: return s
|
|
327
|
-
if isinstance_str(s, ('FullResponse','Safe','PrettyString')): return s
|
|
328
328
|
if mx is None or len(s)<=mx: return s
|
|
329
329
|
s = s[skip:mx-skip]
|
|
330
330
|
ss = s.split(' ')
|
|
@@ -406,12 +406,17 @@ class AsyncChat:
|
|
|
406
406
|
default_cbs=True # Whether to include default callbacks
|
|
407
407
|
):
|
|
408
408
|
"LiteLLM chat client."
|
|
409
|
+
if not vendor_name and not api_name and not (base_url and api_key):
|
|
410
|
+
v, model = split_vendor(model)
|
|
411
|
+
if v in vendor_mapping: vendor_name = v
|
|
412
|
+
elif v: api_name = v # a registered transport api (e.g. claude_code)
|
|
409
413
|
self.model = model
|
|
410
414
|
hist,tools = mk_msgs(hist,cache,cache_idxs,ttl),listify(tools)
|
|
411
415
|
if ns is None and tools: ns = mk_ns(tools)
|
|
412
416
|
elif ns is None: ns = globals()
|
|
413
417
|
self.tool_schemas = [lite_mk_func(t) for t in tools] if tools else None
|
|
414
418
|
self.use = UsageStats()
|
|
419
|
+
self.last_req_use = None # usage of the latest request only; `use` accumulates across a turn's tool-call steps
|
|
415
420
|
store_attr(but='cbs')
|
|
416
421
|
self.cbs = L()
|
|
417
422
|
if default_cbs: self.add_cbs(defaults.chat_callbacks)
|
|
@@ -435,6 +440,7 @@ class AsyncChat:
|
|
|
435
440
|
def _track(self, res):
|
|
436
441
|
u = UsageStats.from_response(res)
|
|
437
442
|
u.cost *= (1 + self.markup)
|
|
443
|
+
self.last_req_use = u
|
|
438
444
|
self.use += u
|
|
439
445
|
|
|
440
446
|
def add_cb(self, cb):
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.29"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_fastllm-0.0.29 → python_fastllm-0.0.31}/python_fastllm.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|