export JAVA_HOME=$(/usr/libexec/java_home -v 17)
sbt clean assemblymacOS:
mkdir -p "/Applications/NetLogo 7.0.0/extensions/llm"
cp target/scala-3.7.0/llm.jar "/Applications/NetLogo 7.0.0/extensions/llm/"Windows:
mkdir "C:\Program Files\NetLogo 7.0.0\extensions\llm"
copy target\scala-3.7.0\llm.jar "C:\Program Files\NetLogo 7.0.0\extensions\llm\"Linux:
mkdir -p "/usr/local/NetLogo-7.0.0/extensions/llm"
cp target/scala-3.7.0/llm.jar "/usr/local/NetLogo-7.0.0/extensions/llm/"If you have a pre-built llm-0.1.0.zip:
unzip llm-0.1.0.zipmacOS:
cp -r llm-0.1.0 "/Applications/NetLogo 7.0.0/extensions/llm"Windows:
xcopy llm-0.1.0 "C:\Program Files\NetLogo 7.0.0\extensions\llm" /E /ILinux:
cp -r llm-0.1.0 "/usr/local/NetLogo-7.0.0/extensions/llm"Launch NetLogo 7.0.0 (or newer)
Open the Command Center and type:
extensions [llm]If no error appears, the extension is installed correctly.
Create a config.txt file next to your NetLogo model with your API keys:
provider = openai
api_key = sk-your-api-key-here
model = gpt-4o
temperature = 0.7
max_tokens = 500
See demos/config-reference.txt for all options.
In your NetLogo code:
extensions [llm]
to setup
llm:load-config "config.txt"
end
to test-llm
let response llm:chat "Hello, what is 2+2?"
print response
endClick Setup, then run test-llm from the Command Center.
The extension must be in NetLogo's extensions/llm/ folder:
macOS:
/Applications/NetLogo 7.0.0/extensions/llm/
Windows:
C:\Program Files\NetLogo 7.0.0\extensions\llm\
Linux:
/usr/local/NetLogo-7.0.0/extensions/llm/
Expected structure:
NetLogo 7.0.0/
└── extensions/
└── llm/
└── llm.jar (for Fat JAR install)
OR
NetLogo 7.0.0/
└── extensions/
└── llm/
├── llm.jar
├── cats-core_3-2.9.0.jar
├── circe-yaml_3-0.15.0.jar
└── [other JARs] (for ZIP install)
Problem: "Extension llm not found" Solution: Check that you have:
- Created the folder:
extensions/llm/ - Copied the file:
extensions/llm/llm.jar
Problem: "NoClassDefFoundError: ujson/Value" Solution: You're using an old JAR. Rebuild with:
sbt clean assemblyProblem: Config file not found
Solution: Make sure config.txt is in the same folder as your .nlogo file, or use the full path:
llm:load-config "/full/path/to/config.txt"