GitHub - hopafoot/arabian-sand-boa: A new python interpreter that supports inline frontier intelligence powered conditionals with native performance · GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
hopafoot
arabian-sand-boa
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>3 Commits<br>3 Commits
.example.env
.example.env
.gitignore
.gitignore
LICENSE
LICENSE
README.md
README.md
arabian_sand_boa
arabian_sand_boa
example.py
example.py
View all files
Repository files navigation
arabian_sand_boa
Run a Python file where string if conditions are decided by an LLM .
arabian_sand_boa is a single, dependency-free script (standard library only).<br>It reads your target file, rewrites every if/elif at the AST level, and runs<br>it. When a condition resolves to a non-empty string , the string is treated as<br>a natural-language clause and sent to an LLM along with the variables currently<br>in scope; the model's True/False answer decides which branch runs. Every<br>other condition resolves the normal way via bool().
Usage
[args...] # it's executable">./arabian_sand_boa file.py> [args...] # it's executable
--debug (or -d) prints, to stderr, the exact prompt sent to the LLM and the<br>raw reply for each clause it evaluates.
The target file runs with __name__ == "__main__", so its main block executes.
Configuration
The LLM endpoint is configured entirely through environment variables, read<br>lazily — a target that only uses ordinary (non-string) conditions never needs<br>them.
Variable<br>Meaning
BOA_LLM_URL<br>Full chat-completions endpoint URL
BOA_LLM_API_KEY<br>Bearer token for that endpoint
BOA_LLM_MODEL<br>Model name to request
The endpoint is expected to speak the OpenAI-style chat-completions protocol<br>(POST a JSON body with model and messages, get back<br>choices[0].message.content).
Copy .example.env to .env, fill in your values, and load it:
cp .example.env .env<br># edit .env<br>set -a; source .env; set +a
python3 arabian_sand_boa example.py
.env is gitignored; .example.env is the tracked template. If any required<br>variable is missing when an LLM call is needed, the run fails with a clear error<br>naming the missing variable(s).
How it works
Rewrite. An ast.NodeTransformer replaces each if : with<br>if __if_hook__(, ""):.
Decide. __if_hook__ evaluates . If it's a non-empty string, the<br>hook gathers the caller's non-dunder local variables and asks the LLM whether<br>the clause holds. Otherwise it returns bool() and no API call is made.
Parse. The reply is lower-cased and stripped: true → take the branch,<br>false → skip it, anything else → take the branch (cautious default).
Privacy and safety
Your local variables leave the machine. For every string condition, the<br>in-scope (non-dunder) local variables are serialized and sent to the<br>configured LLM endpoint. Do not run this over sensitive data.
An LLM call fires for every executed string condition , so loops with<br>string clauses are slow and chatty against the endpoint.
Decisions are only as reliable as the model and the wording of your clause,<br>and may vary between runs.
Example
See example.py for a runnable showcase mixing natural-language clauses<br>(drinking age, admin privileges, account health) with an ordinary boolean<br>condition.
About
A new python interpreter that supports inline frontier intelligence powered conditionals with native performance
Resources
Readme
License
MIT license
Uh oh!
There was an error while loading. Please reload this page.
Activity
Stars
star
Watchers
watching
Forks
forks
Report repository
Releases
No releases published
Packages
Uh oh!
There was an error while loading. Please reload this page.
Contributors
Uh oh!
There was an error while loading. Please reload this page.
Languages
Python<br>100.0%
You can’t perform that action at this time.