toolslm 0.2.2__tar.gz → 0.2.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolslm
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Tools to make language models a bit easier to use
5
5
  Home-page: https://github.com/AnswerDotAI/toolslm
6
6
  Author: Jeremy Howard
@@ -1,7 +1,7 @@
1
1
  [DEFAULT]
2
2
  repo = toolslm
3
3
  lib_name = toolslm
4
- version = 0.2.2
4
+ version = 0.2.3
5
5
  min_python = 3.9
6
6
  license = apache2
7
7
  black_formatting = False
@@ -0,0 +1 @@
1
+ __version__ = "0.2.3"
@@ -183,18 +183,20 @@ def python(
183
183
  finally: signal.alarm(0)
184
184
 
185
185
  # %% ../01_funccall.ipynb
186
- def mk_ns(*funcs_or_objs):
186
+ def mk_ns(fs):
187
+ if isinstance(fs, abc.Mapping): return fs
187
188
  merged = {}
188
- for o in funcs_or_objs:
189
- if isinstance(o, type): merged |= {n:getattr(o,n) for n,m in o.__dict__.items() if isinstance(m, (staticmethod, classmethod))}
190
- if isinstance(o, object): merged |= {n:getattr(o,n) for n, m in inspect.getmembers(o, inspect.ismethod)} | {n:m for n,m in o.__class__.__dict__.items() if isinstance(m, staticmethod)}
191
- if callable(o) and hasattr(o, '__name__'): merged |= {o.__name__: o}
189
+ for o in listify(fs):
190
+ if isinstance(o, dict): merged |= o
191
+ elif isinstance(o, type): merged |= {n:getattr(o,n) for n,m in o.__dict__.items() if isinstance(m, (staticmethod, classmethod))}
192
+ elif callable(o) and hasattr(o, '__name__'): merged |= {o.__name__: o}
193
+ merged |= {n:getattr(o,n) for n, m in inspect.getmembers(o, inspect.ismethod)} | {n:m for n,m in o.__class__.__dict__.items() if isinstance(m, staticmethod)}
192
194
  return merged
193
195
 
194
196
  # %% ../01_funccall.ipynb
195
197
  def call_func(fc_name, fc_inputs, ns, raise_on_err=True):
196
198
  "Call the function `fc_name` with the given `fc_inputs` using namespace `ns`."
197
- if not isinstance(ns, abc.Mapping): ns = mk_ns(*ns)
199
+ if not isinstance(ns, abc.Mapping): ns = mk_ns(ns)
198
200
  func = ns[fc_name]
199
201
  # Clean up bad param names
200
202
  inps = {re.sub(r'\W', '', k):v for k,v in fc_inputs.items()}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolslm
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Tools to make language models a bit easier to use
5
5
  Home-page: https://github.com/AnswerDotAI/toolslm
6
6
  Author: Jeremy Howard
@@ -1 +0,0 @@
1
- __version__ = "0.2.2"
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