Changes
1 changed files (+23/-0)
-
sage/init.sage (new)
-
@@ -0,0 +1,23 @@from IPython.core.magic import register_line_magic import requests @register_line_magic def nl(line): """ Natural language input for Sage using Ollama Do not use with untrusted input! Example usage: %nl "Invert the 4x4 matrix with 0s on the diagonal and 1s off diagonal" """ r = requests.post("http://localhost:11434/api/generate", json={ "model": "gemma3:27b", "prompt": f"Translate this request directly into SageMath code. Be very concise and don't output Markdown code blocks or anything extraneous, only output the raw SageMath code. Request: {line}", "stream": false }) code = r.json()["response"] print(code) if input("Run? (y/N) ") == "y": shell = get_ipython() shell.run_cell(code)
-