doimport('fastcore.utils')
fastcore.__version__'1.8.17'
This module provides LLM tools for Solveit to dynamically inspect source code, types, and module capabilities. Functions take string arguments (dotted symbol paths) rather than Python objects because LLM tool interfaces can only pass serializable values—not live Python references.
doimport (mod:str)
Import a module into the caller’s global namespace
doimport lets the LLM dynamically import modules by name. Here we import fastcore.utils and verify it’s available.
resolve (sym:str)
*Resolve a dotted symbol string to its Python object, with optional [n] indexing. Sets global _last to the resolved object for chaining. Pass "_last" to reference the result of the previous tool call.
Examples:
resolve("sympy.sets.sets.Interval") -> <class 'sympy.sets.sets.Interval'>resolve("mylist[2]") -> third element of mylist*| Type | Details | |
|---|---|---|
| sym | str | Dotted symbol path, with optional [n] indexing, e.g. “module.attr.subattr[1]” or “_last” for previous result |
resolve navigates dotted paths like "a.argfirst" to reach the actual Python object.
It also sets _last for chaining. Since it’s used internally by all get* tools in this module, the tools all set _last too.
It works on both objects and classes:
<function fastcore.foundation.L.argfirst(self, f, negate=False)>
symsrc (sym:str)
*Get the source code for a symbol.
Examples:
symsrc("sympy.sets.sets.Interval") -> source code of Interval classsymsrc("_last") -> source of object from previous tool callgetnth("module.dispatcher.funcs", n) then symsrc("_last")*| Type | Details | |
|---|---|---|
| sym | str | Dotted symbol path or “_last” for previous result |
symsrc retrieves the source code of any symbol by path—essential for letting the LLM understand how functions work.
def argfirst(self, f, negate=False):
if negate: f = not_(f)
return first(i for i,o in self.enumerate() if f(o))
gettype (sym:str)
*Get the type of a symbol and set _last.
Examples:
gettype("sympy.sets.sets.Interval") -> <class 'type'>gettype("_last") -> type of previous result*| Type | Details | |
|---|---|---|
| sym | str | Dotted symbol path or “_last” for previous result |
gettype returns the type of a symbol—useful for the LLM to understand what kind of object it’s dealing with.
getdir (sym:str)
Get dir() listing of a symbol’s attributes and set _last. E.g: getdir("sympy.Interval") -> ['__add__', '__and__', ...]
| Type | Details | |
|---|---|---|
| sym | str | Dotted symbol path or “_last” for previous result |
getdir lists all attributes of an object (i.e it calls dir(). Here we filter out private names to see the public API of an L list.
'append argfirst argwhere attrgot clear concat copy copy count cycle enumerate extend filter groupby index insert itemgot items map map_dict map_first map_zip map_zipwith pop product range reduce remove renumerate reverse setattrs shuffle sort sorted split splitlines starmap sum unique val2idx zip zipwith'
getval (sym:str)
*Get repr of a symbol’s value and set _last.
Examples:
getval("sympy.sets.sets.Interval") -> <class 'sympy.sets.sets.Interval'>getval("some_dict.keys") -> dict_keys([...])*| Type | Details | |
|---|---|---|
| sym | str | Dotted symbol path or “_last” for previous result |
getval returns the repr() of a symbol’s value—handy for inspecting data without needing to execute arbitrary code.
getnth (sym:str, n:int)
*Get the nth value from a dict (or any object with .values()). Sets _last so you can chain with symsrc("_last") etc.
Examples:
getnth("dispatcher.funcs", 12) -> 13th registered functiongetnth("dispatcher.funcs", 0); symsrc("_last") -> source of first handler*| Type | Details | |
|---|---|---|
| sym | str | Dotted symbol path to a dict or object with .values() |
| n | int | Index into the values (0-based) |
getnth extracts the nth value from a dict (or anything with .values()).
<function __main__.<lambda>(x)>
Combined with _last, this lets the LLM drill into registries of handlers/dispatchers and then inspect their source.
'handlers = dict(int=lambda x: x*2, str=lambda x: x.upper(), list=lambda x: len(x))\n'
inspect_tool_info ()
Tools available from inspecttools: &[symsrc,gettype,getdir,doimport,getval,getnth]