load¶
load(path, *, trust=False, check_env='refuse', node=None)
Load a saved program, ready to call.
Checks before running anything: the files' hashes (catching accidental edits) and the packages this environment has. After loading, checks that every AI function renders the same requests as when it was saved.
A folder written in another language (TypeScript, R, Julia) holds no
Python code: its AI functions load from functai.json alone, as data
(from_manifest), and need no trust.
Parameters¶
| Name | Type | Description | Default |
|---|---|---|---|
| path | str or path | The saved folder. | required |
| trust | bool | Must be True: loading runs the saved code. The hashes catch accidents, not someone who edits both the code and functai.json. |
False |
| node | str | The program to load, by key ("module:name"); the entry by default. For a folder of another language, an AI function. |
None |
| check_env | str | "refuse" (default) refuses on version or request differences; "warn" loads anyway, with warnings. Missing packages always refuse. |
'refuse' |
Returns¶
| Name | Type | Description |
|---|---|---|
| AI function or module | The program, as it was saved. |
Raises¶
| Name | Type | Description |
|---|---|---|
| LoadRefused | When a check fails, saying which and why. |
See Also¶
Examples¶
import functai
from functai import *
import tempfile, os
@ai
def capital(country: str) -> str:
"""The country's capital city."""
...
folder = os.path.join(tempfile.mkdtemp(), "capital")
save(capital, folder)
loaded = load(folder, trust=True)
loaded("Peru")
functai: no model chosen, so using gpt-4.1-mini (environment ($OPENAI_API_KEY)). Choose one with functai.configure(lm=...).
'Lima'