toolslm 0.3.20__tar.gz → 0.3.23__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.3.20
3
+ Version: 0.3.23
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.3.20
4
+ version = 0.3.23
5
5
  min_python = 3.9
6
6
  license = apache2
7
7
  black_formatting = False
@@ -35,6 +35,7 @@ clean_ids = True
35
35
  clear_all = False
36
36
  conda_user = fastai
37
37
  console_scripts = folder2ctx=toolslm.xml:folder2ctx_cli
38
+ repo2ctx=toolslm.xml:repo2ctx_cli
38
39
  cell_number = False
39
40
  skip_procs =
40
41
  update_pyproject = True
@@ -0,0 +1 @@
1
+ __version__ = "0.3.23"
@@ -55,6 +55,7 @@ d = { 'settings': { 'branch': 'main',
55
55
  'toolslm.xml.py2sigs': ('xml.html#py2sigs', 'toolslm/xml.py'),
56
56
  'toolslm.xml.read_file': ('xml.html#read_file', 'toolslm/xml.py'),
57
57
  'toolslm.xml.repo2ctx': ('xml.html#repo2ctx', 'toolslm/xml.py'),
58
+ 'toolslm.xml.repo2ctx_cli': ('xml.html#repo2ctx_cli', 'toolslm/xml.py'),
58
59
  'toolslm.xml.sym2file': ('xml.html#sym2file', 'toolslm/xml.py'),
59
60
  'toolslm.xml.sym2folderctx': ('xml.html#sym2folderctx', 'toolslm/xml.py'),
60
61
  'toolslm.xml.sym2pkgctx': ('xml.html#sym2pkgctx', 'toolslm/xml.py'),
@@ -144,7 +144,7 @@ def get_schema(
144
144
  has_type = (ret.anno is not empty) and (ret.anno is not None)
145
145
  has_doc = ret.docment
146
146
  if has_type or has_doc:
147
- type_str = f'type: {_types(ret.anno)[0]}'
147
+ type_str = f'type: {_types(ret.anno)[0]}' if has_type else None
148
148
  ret_str = f'{ret.docment} ({type_str})' if has_type and has_doc else (type_str if has_type else ret.docment)
149
149
  desc += f'\n\nReturns:\n- {ret_str}'
150
150
  return {"name": f.__name__, "description": desc, pname: schema}
@@ -3,7 +3,7 @@
3
3
  # %% auto 0
4
4
  __all__ = ['doctype', 'json_to_xml', 'get_mime_text', 'cell2out', 'cell2xml', 'cells2xml', 'nb2xml', 'get_docstring', 'py2sigs',
5
5
  'mk_doctype', 'mk_doc', 'docs_xml', 'read_file', 'files2ctx', 'folder2ctx', 'sym2file', 'sym2folderctx',
6
- 'sym2pkgpath', 'sym2pkgctx', 'folder2ctx_cli', 'parse_gh_url', 'repo2ctx']
6
+ 'sym2pkgpath', 'sym2pkgctx', 'folder2ctx_cli', 'parse_gh_url', 'repo2ctx', 'repo2ctx_cli']
7
7
 
8
8
  # %% ../00_xml.ipynb
9
9
  import hashlib, inspect, xml.etree.ElementTree as ET, ast
@@ -175,9 +175,9 @@ def files2ctx(
175
175
  return docs_xml(contents, srcs or fnames, **kwargs)
176
176
 
177
177
  # %% ../00_xml.ipynb
178
- @delegates(globtastic)
178
+ @delegates(globtastic, but='func')
179
179
  def folder2ctx(
180
- folder:Union[str,Path], # Folder to read
180
+ path:Union[str,Path], # Folder to read
181
181
  prefix:bool=False, # Include Anthropic's suggested prose intro?
182
182
  out:bool=True, # Include notebook cell outputs?
183
183
  include_base:bool=True, # Include full path in src?
@@ -191,7 +191,7 @@ def folder2ctx(
191
191
  **kwargs
192
192
  )->Union[str,dict]:
193
193
  "Convert folder contents to XML context, handling notebooks"
194
- folder = Path(folder).expanduser()
194
+ folder = Path(path).expanduser()
195
195
  fnames = pglob(folder, **kwargs)
196
196
  if files_only: return {str(f.relative_to(folder)): f.stat().st_size for f in fnames}
197
197
  if readme_first: fnames = sorted(fnames, key=lambda f: (0 if 'readme' in f.name.lower() else 1, f))
@@ -233,12 +233,12 @@ def sym2pkgctx(sym, types:str|list='py', skip_file_re=r'^_mod', **kwargs):
233
233
  @call_parse
234
234
  @delegates(folder2ctx)
235
235
  def folder2ctx_cli(
236
- folder:str, # Folder name containing files to add to context
236
+ path:str='.', # Folder name containing files to add to context
237
237
  out:bool=True, # Include notebook cell outputs?
238
238
  **kwargs # Passed to `folder2ctx`
239
239
  )->str: # XML for Claude context
240
240
  "CLI to convert folder contents to XML context, handling notebooks"
241
- print(folder2ctx(folder, out=out, **kwargs))
241
+ print(folder2ctx(path, out=out, **kwargs))
242
242
 
243
243
  # %% ../00_xml.ipynb
244
244
  def parse_gh_url(url):
@@ -280,3 +280,17 @@ def repo2ctx(
280
280
  subdir = Path(tmp) / tf.getmembers()[0].name.split('/')[0]
281
281
  if folder: subdir = subdir/folder
282
282
  return folder2ctx(subdir, include_base=False, title=title, readme_first=True, **kwargs)
283
+
284
+ # %% ../00_xml.ipynb
285
+ @call_parse
286
+ @delegates(repo2ctx, but='include_base,title,readme_first')
287
+ def repo2ctx_cli(
288
+ owner:str, # GitHub repo owner or "owner/repo" or a full github URL
289
+ repo:str=None, # GitHub repo name (leave empty if using "owner/repo" or URL format)
290
+ ref:str=None, # Git ref (branch/tag/sha)
291
+ folder:str=None, # Only include files under this path
292
+ out:bool=True, # Include notebook cell outputs?
293
+ **kwargs # Passed to `repo2ctx`
294
+ )->str: # XML for Claude context
295
+ "CLI to convert GitHub repo contents to XML context"
296
+ print(repo2ctx(owner, repo, ref=ref, folder=folder, out=out, **kwargs))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: toolslm
3
- Version: 0.3.20
3
+ Version: 0.3.23
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,5 +1,6 @@
1
1
  [console_scripts]
2
2
  folder2ctx = toolslm.xml:folder2ctx_cli
3
+ repo2ctx = toolslm.xml:repo2ctx_cli
3
4
 
4
5
  [nbdev]
5
6
  toolslm = toolslm._modidx:d
@@ -1 +0,0 @@
1
- __version__ = "0.3.20"
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